aliyun

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrCodeInvalidRegion is returned by RegionVerifier.Verify when the
	// Location service reports no endpoints for a region. Treat this as a
	// hard failure — the user almost certainly typed the region wrong.
	ErrCodeInvalidRegion = "InvalidRegion"
	// ErrCodeVerificationUnavailable is returned when the verification check
	// cannot be performed (missing credentials, network error, etc.). Callers
	// should fall back to a warning rather than blocking the operation.
	ErrCodeVerificationUnavailable = "VerificationUnavailable"
)

Location service used to validate region IDs without depending on a static list. The API is public but undocumented; the call shape mirrors what the aliyun-cli does internally.

Variables

View Source
var ErrCredentialAccountMismatch = errors.New("credential account does not match the configured account")
View Source
var ErrCredentialIdentityChanged = errors.New("credential identity changed during operation")
View Source
var ErrCredentialLeaseExpired = errors.New("credential lease expired")
View Source
var ErrCredentialProfileChanged = errors.New("credential profile changed during refresh")
View Source
var ErrCredentialStatePersistenceFailed = errors.New("credential state could not be persisted")

Functions

func OpenAPIOperationName

func OpenAPIOperationName(product OpenAPIProduct, operation string) (string, bool)

func VerifyRegion

func VerifyRegion(profileName, configPath, region, serviceCode string, getenv func(string) string) error

VerifyRegion is a convenience wrapper that constructs a RegionVerifier and validates the region in one step.

Types

type CLICommandCaller

type CLICommandCaller struct {
	Product    string
	Region     string
	Profile    string
	ConfigPath string
	// contains filtered or unexported fields
}

func NewCLICommandCaller

func NewCLICommandCaller(profileName, configPath, product, region string, getenv func(string) string) (*CLICommandCaller, error)

func (*CLICommandCaller) Call

func (c *CLICommandCaller) Call(ctx context.Context, operation string, request map[string]any) (map[string]any, error)

func (*CLICommandCaller) CallWithArgs

func (c *CLICommandCaller) CallWithArgs(ctx context.Context, operation string, request map[string]any, passthrough []string) (map[string]any, error)

type CLICommandRunner

type CLICommandRunner interface {
	Run(ctx context.Context, name string, args []string, env []string) ([]byte, []byte, error)
}

type OSSUtilCaller added in v0.2.0

type OSSUtilCaller struct {
	Region  string
	Profile resolvedOpenAPIProfile
	// contains filtered or unexported fields
}

OSSUtilCaller adapts the OSSUtil API commands exposed by aliyun CLI to the generic ecctl call contract. Credentials are resolved by ecctl and passed to the child process through environment variables, never command arguments.

func NewOSSUtilCaller added in v0.2.0

func NewOSSUtilCaller(profileName, configPath, region string, getenv func(string) string) (*OSSUtilCaller, error)

func NewOSSUtilCallerWithRegionSource added in v0.2.1

func NewOSSUtilCallerWithRegionSource(profileName, configPath string, region ecconfig.ResolvedRegion, getenv func(string) string) (*OSSUtilCaller, error)

func (*OSSUtilCaller) Call added in v0.2.0

func (c *OSSUtilCaller) Call(ctx context.Context, operation string, request map[string]any) (map[string]any, error)

func (*OSSUtilCaller) CallWithArgs added in v0.2.0

func (c *OSSUtilCaller) CallWithArgs(ctx context.Context, operation string, request map[string]any, passthrough []string) (result map[string]any, resultErr error)

type OpenAPICaller

type OpenAPICaller struct {
	Product  string
	Resource string
	Region   string
	Profile  resolvedOpenAPIProfile
	// contains filtered or unexported fields
}

func NewOpenAPICaller

func NewOpenAPICaller(profileName, configPath, product, region string, getenv func(string) string) (*OpenAPICaller, error)

func NewOpenAPICallerWithRegionSource added in v0.2.1

func NewOpenAPICallerWithRegionSource(profileName, configPath, product string, region ecconfig.ResolvedRegion, getenv func(string) string) (*OpenAPICaller, error)

func (*OpenAPICaller) Call

func (c *OpenAPICaller) Call(ctx context.Context, operation string, request map[string]any) (map[string]any, error)

func (*OpenAPICaller) CallRaw

func (c *OpenAPICaller) CallRaw(ctx context.Context, operation string, request map[string]any) (map[string]any, error)

func (*OpenAPICaller) PrepareOperationContext added in v0.2.1

func (c *OpenAPICaller) PrepareOperationContext(ctx context.Context) (context.Context, error)

PrepareOperationContext pins one logical credential source and executor for the complete engine operation. Temporary material may renew before later requests, while profile identity and endpoint policy remain fixed.

type OpenAPIEndpoint

type OpenAPIEndpoint struct {
	RegionID string
	Name     string
	Public   string
	VPC      string
}

type OpenAPIMetadataResolver added in v0.2.1

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

OpenAPIMetadataResolver is an immutable, fail-closed view of the current OpenAPI metadata for a declared product set. Construct it with NewOpenAPIMetadataResolver so current-versus-legacy provenance cannot be lost by copying or reconstructing individual OpenAPIProduct values.

func NewOpenAPIMetadataResolver added in v0.2.1

func NewOpenAPIMetadataResolver(lang string, requiredCodes []string) (*OpenAPIMetadataResolver, error)

NewOpenAPIMetadataResolver loads every required product from the current catalog. Missing products and broken current version manifests are fatal; unrelated incomplete catalog entries are not read.

func (*OpenAPIMetadataResolver) OperationLeaves added in v0.2.1

func (r *OpenAPIMetadataResolver) OperationLeaves(productCode, operation string, allowLegacy bool) ([]OpenAPIParameter, string, error)

OperationLeaves resolves and flattens one operation from the immutable snapshot. allowLegacy must be true only for an explicitly reviewed legacy-only operation; an unapproved omission from the current manifest is treated as metadata corruption.

type OpenAPIOperationDetail

type OpenAPIOperationDetail struct {
	Name        string
	Deprecated  bool
	Protocol    string
	Method      string
	PathPattern string
	Style       string
	Parameters  []OpenAPIParameter
}

func OpenAPIOperationDetailFor

func OpenAPIOperationDetailFor(lang string, product OpenAPIProduct, operation string) (OpenAPIOperationDetail, bool)

func (*OpenAPIOperationDetail) FindParameter

func (d *OpenAPIOperationDetail) FindParameter(name string) *OpenAPIParameter

type OpenAPIOperationSummary

type OpenAPIOperationSummary struct {
	Title      string
	Summary    string
	Deprecated bool
}

func OpenAPIOperationSummaryFor

func OpenAPIOperationSummaryFor(lang string, productCode string, operation string) (OpenAPIOperationSummary, bool)

type OpenAPIParameter

type OpenAPIParameter struct {
	Name          string
	Description   string
	Position      string
	Type          string
	Required      bool
	SubParameters []OpenAPIParameter
}

func OpenAPIOperationLeaves added in v0.2.1

func OpenAPIOperationLeaves(lang string, product OpenAPIProduct, operation string) ([]OpenAPIParameter, bool)

OpenAPIOperationLeaves returns the flattened leaf request parameters of an OpenAPI operation. Group parameters are expanded into their children:

  • a parameter with sub-parameters (for example RepeatList groups such as DataDisk) contributes one leaf per child, named Parent.Child;
  • a Struct placeholder whose children are declared as dotted flat names (for example SystemDisk plus SystemDisk.Category) contributes only the dotted leaves, not the bare parent;
  • a parameter with no child information (a bare Struct or RepeatList) contributes a single leaf under its own name.

OpenAPIOperationDetailFor supplies the authoritative current parameter set and falls back to legacy metadata only when the current operation is absent. When the current detail exposes a bare group without dotted children, the legacy subtree enriches that group so drift detection retains field-level coverage. Legacy-only top-level parameters are never copied into the current set, so newly added and removed parameters remain observable.

type OpenAPIProduct

type OpenAPIProduct struct {
	Code         string
	Name         string
	Version      string
	EndpointType string
	Style        string
	Endpoints    map[string]OpenAPIEndpoint
	APINames     []string
	// contains filtered or unexported fields
}

func OpenAPIProductByCode

func OpenAPIProductByCode(code string, lang string) (OpenAPIProduct, bool)

func OpenAPIProducts

func OpenAPIProducts(lang string) ([]OpenAPIProduct, error)

type RegionVerifier

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

RegionVerifier checks that a region ID is recognized by the Alibaba Cloud Location service. Build one with NewRegionVerifier; inject a fake processor via newRegionVerifierWithProcessor in tests.

func NewRegionVerifier

func NewRegionVerifier(profileName, configPath string, getenv func(string) string) (*RegionVerifier, error)

NewRegionVerifier constructs a RegionVerifier using the dynamic credential provider from the resolved profile. Returns a typed VerificationUnavailable error when no credentials are available — the CLI should treat that as a soft skip rather than a hard failure during initial setup.

func (*RegionVerifier) Verify

func (v *RegionVerifier) Verify(region, serviceCode string) error

Verify calls Location/DescribeEndpoints and reports whether the region is known to Alibaba Cloud. serviceCode defaults to "ecs" — the universal probe because every region with any public API exposes ECS endpoints.

func (*RegionVerifier) VerifyContext added in v0.2.0

func (v *RegionVerifier) VerifyContext(ctx context.Context, region, serviceCode string) error

VerifyContext is Verify with the command context used for telemetry parentage and cancellation.

Jump to

Keyboard shortcuts

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