Documentation ¶
Overview ¶
Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights resvered.
The common package defines some common functions, which are mainly used for the functions of the following services.
The difference between common package and utils:
- Common functions under common are related to the project, and common functions are placed here.
- Utils are some stored tool functions, which are not related to the project. Such as: date conversion, type conversion.
Index ¶
- func CaseInsensitiveFunc() schema.SchemaDiffSuppressFunc
- func CheckDeleted(d *schema.ResourceData, err error, msg string) error
- func CheckDeletedDiag(d *schema.ResourceData, err error, msg string) diag.Diagnostics
- func CheckForRetryableError(err error) *resource.RetryError
- func GetAutoPay(d *schema.ResourceData) string
- func GetEipIDbyAddress(client *golangsdk.ServiceClient, address, epsID string) (string, error)
- func GetEnterpriseProjectID(d *schema.ResourceData, cfg *config.Config) string
- func GetRegion(d *schema.ResourceData, config *config.Config) string
- func HasFilledOpt(d *schema.ResourceData, param string) bool
- func MigrateEnterpriseProject(ctx context.Context, cfg *config.Config, d *schema.ResourceData, ...) error
- func MigrateEnterpriseProjectWithoutWait(cfg *config.Config, d *schema.ResourceData, ...) error
- func NewCustomClient(insecure bool, endpoints ...string) *golangsdk.ServiceClient
- func RetryContextWithWaitForState(param *RetryContextWithWaitForStateParam) (interface{}, error)
- func SchemaAutoPay(conflicts []string) *schema.Schema
- func SchemaAutoRenew(conflicts []string) *schema.Schema
- func SchemaAutoRenewUpdatable(conflicts []string) *schema.Schema
- func SchemaChargingMode(conflicts []string) *schema.Schema
- func SchemaPeriod(conflicts []string) *schema.Schema
- func SchemaPeriodUnit(conflicts []string) *schema.Schema
- func TagsComputedSchema() *schema.Schema
- func TagsForceNewSchema() *schema.Schema
- func TagsSchema() *schema.Schema
- func UnsubscribePrePaidResource(d *schema.ResourceData, config *config.Config, resourceIDs []string) error
- func UpdateAutoRenew(c *golangsdk.ServiceClient, enabled, resourceId string) error
- func UpdateEcsInstanceKeyPair(ctx context.Context, ecsClient, kmsClient *golangsdk.ServiceClient, ...) error
- func ValidatePrePaidChargeInfo(d *schema.ResourceData) error
- func WaitOrderComplete(ctx context.Context, client *golangsdk.ServiceClient, orderId string, ...) error
- func WaitOrderResourceComplete(ctx context.Context, client *golangsdk.ServiceClient, orderId string, ...) (string, error)
- type ErrorResp
- type KeypairAuthOpts
- type RetryContextWithWaitForStateParam
- type RetryFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaseInsensitiveFunc ¶ added in v1.31.1
func CaseInsensitiveFunc() schema.SchemaDiffSuppressFunc
func CheckDeleted ¶
func CheckDeleted(d *schema.ResourceData, err error, msg string) error
CheckDeleted checks the error to see if it's a 404 (Not Found) and, if so, sets the resource ID to the empty string instead of throwing an error.
func CheckDeletedDiag ¶ added in v1.28.1
func CheckDeletedDiag(d *schema.ResourceData, err error, msg string) diag.Diagnostics
CheckDeletedDiag checks the error to see if it's a 404 (Not Found) and, if so, sets the resource ID to the empty string instead of throwing an error.
func CheckForRetryableError ¶ added in v1.29.0
func CheckForRetryableError(err error) *resource.RetryError
func GetAutoPay ¶ added in v1.37.0
func GetAutoPay(d *schema.ResourceData) string
GetAutoPay is a method to return whether order is auto pay according to the user input. auto_pay parameter inputs and returns:
false: false true, empty: true
Before using this function, make sure the parameter behavior is auto pay (the default value is "true").
func GetEipIDbyAddress ¶ added in v1.30.0
func GetEipIDbyAddress(client *golangsdk.ServiceClient, address, epsID string) (string, error)
GetEipIDbyAddress returns the EIP ID of address when success.
func GetEnterpriseProjectID ¶
func GetEnterpriseProjectID(d *schema.ResourceData, cfg *config.Config) string
GetEnterpriseProjectID returns the enterprise_project_id that was specified in the resource. If it was not set, the provider-level value is checked. The provider-level value can either be set by the `enterprise_project_id` argument or by HW_ENTERPRISE_PROJECT_ID.
func GetRegion ¶
func GetRegion(d *schema.ResourceData, config *config.Config) string
GetRegion returns the region that was specified ina the resource. If a region was not set, the provider-level region is checked. The provider-level region can either be set by the region argument or by HW_REGION_NAME.
func HasFilledOpt ¶ added in v1.41.0
func HasFilledOpt(d *schema.ResourceData, param string) bool
func MigrateEnterpriseProject ¶ added in v1.44.1
func MigrateEnterpriseProject(ctx context.Context, cfg *config.Config, d *schema.ResourceData, opts enterpriseprojects.MigrateResourceOpts) error
MigrateEnterpriseProject is a method used to migrate a resource from an enterprise project to another enterprise project and ensure the success of the EPS side migration. NOTE: Please read the following contents carefully before using this method.
- This method only calls the interfaces of the EPS service. For individual EPS IDs that are not updated due to out-of-synchronization of data on the server side, this method does not perform additional verification and requires developers to manually ensure the reliability of the code through testing.
func MigrateEnterpriseProjectWithoutWait ¶ added in v1.57.0
func MigrateEnterpriseProjectWithoutWait(cfg *config.Config, d *schema.ResourceData, opts enterpriseprojects.MigrateResourceOpts) error
MigrateEnterpriseProjectWithoutWait is a method that used to a migrate resource from an enterprise project to another. NOTE: Please read the following contents carefully before using this method.
- This method only sends an asynchronous request and does not guarantee the result.
func NewCustomClient ¶ added in v1.38.0
func NewCustomClient(insecure bool, endpoints ...string) *golangsdk.ServiceClient
NewCustomClient creates a custom client assembled from user-provided endpoints. URLs will be assembled according to the endpoints array, separated each element by slashes. for example, array ["https://www.example.com", "v2", "test", ...] will form the address "https://www.example.com/v2/test/.../". NOTE: You can decide whether to skip the SSL certificate check with the insecure parameter.
func RetryContextWithWaitForState ¶ added in v1.52.0
func RetryContextWithWaitForState(param *RetryContextWithWaitForStateParam) (interface{}, error)
RetryContextWithWaitForState The RetryFunc will be called first if the error of the return is nil, the retry will be ended and the res of the return will be returned if the retry of the return is true, the RetryFunc will be retried, and the WaitFunc will be called if it is not nil if the retry of the return is false, the retry will be ended and the error of the retry func will be returned
func SchemaAutoPay ¶ added in v1.35.0
func SchemaAutoRenew ¶ added in v1.28.1
func SchemaAutoRenewUpdatable ¶ added in v1.40.2
func SchemaChargingMode ¶ added in v1.35.0
func SchemaPeriod ¶ added in v1.28.1
func SchemaPeriodUnit ¶ added in v1.28.1
func TagsComputedSchema ¶ added in v1.47.0
TagsComputedSchema returns the schema to use for tags as an attribute
func TagsForceNewSchema ¶ added in v1.28.1
TagsForceNewSchema returns the schema to use for tags with ForceNew
func TagsSchema ¶ added in v1.28.0
TagsSchema returns the schema to use for tags.
func UnsubscribePrePaidResource ¶
func UnsubscribePrePaidResource(d *schema.ResourceData, config *config.Config, resourceIDs []string) error
UnsubscribePrePaidResource impl the action of unsubscribe resource
func UpdateAutoRenew ¶ added in v1.40.1
func UpdateAutoRenew(c *golangsdk.ServiceClient, enabled, resourceId string) error
func UpdateEcsInstanceKeyPair ¶ added in v1.44.1
func UpdateEcsInstanceKeyPair(ctx context.Context, ecsClient, kmsClient *golangsdk.ServiceClient, opts *KeypairAuthOpts) error
func ValidatePrePaidChargeInfo ¶ added in v1.28.1
func ValidatePrePaidChargeInfo(d *schema.ResourceData) error
func WaitOrderComplete ¶ added in v1.29.0
func WaitOrderResourceComplete ¶ added in v1.41.0
func WaitOrderResourceComplete(ctx context.Context, client *golangsdk.ServiceClient, orderId string, timeout time.Duration) (string, error)
WaitOrderResourceComplete is the method to wait for the resource to be generated. Notes: Note that this method needs to be used in conjunction with method "WaitOrderComplete", because the ID of some resources may not be generated when the order is not completed.
Types ¶
type ErrorResp ¶ added in v1.41.0
ErrorResp is the response when API failed
func ParseErrorMsg ¶ added in v1.41.0
type KeypairAuthOpts ¶ added in v1.44.1
type KeypairAuthOpts struct { // the ECS instance ID InstanceID string // the keypair name in used InUsedKeyPair string // the replaced keypair name NewKeyPair string // the private key of the keypair name in used, it's used to replace or unbind the keypair InUsedPrivateKey string // the root password of the ECS instance, it's used to bind a new keypair Password string // whether to disable SSH login on the VM DisablePassword bool // the timeout to wait for the task Timeout time.Duration }
type RetryContextWithWaitForStateParam ¶ added in v1.52.0
type RetryContextWithWaitForStateParam struct { Ctx context.Context // The func that need to be retried RetryFunc RetryFunc // The wait func when the retry which returned by the retry func is true WaitFunc resource.StateRefreshFunc // The target of the wait func WaitTarget []string // The pending of the wait func WaitPending []string // The timeout of the retry func and wait func Timeout time.Duration // The delay timeout of the retry func and wait func DelayTimeout time.Duration // The poll interval of the retry func and wait func PollInterval time.Duration }