Help us shape the future of Go! Take the 2026 Go Developer Survey

cloudcontrol

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Code generated by generate-cached. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAttributes

func ParseAttributes(resource types.ResourceDescription) (data map[string]interface{}, tags map[string]string, err error)

func ParseTags

func ParseTags(attrs map[string]interface{}) (map[string]string, error)

Types

type AwsClient

type AwsClient interface {
	GetRegion() ptypes.AwsRegion
	GetAccountID() ptypes.AwsAccountID
}

type CloudControlRepository

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

func NewCloudControlRepository

func NewCloudControlRepository(ctx context.Context, client *v3.Client) *CloudControlRepository

func (*CloudControlRepository) CancelResourceRequest added in v0.14.0

func (r *CloudControlRepository) CancelResourceRequest(requestToken string) (*types.ProgressEvent, error)

CancelResourceRequest asks Cloud Control to cancel a pending or in-progress request. Only CREATE and UPDATE requests can be cancelled, and a cancelled create may leave the resource behind in whatever state the handler reached.

func (*CloudControlRepository) CreateResource added in v0.14.0

func (r *CloudControlRepository) CreateResource(resourceType cfg.ResourceType, desiredState string) (*types.ProgressEvent, error)

CreateResource asks Cloud Control to create a resource of the given type. desiredState is the JSON document of the resource's properties, in the shape the type's CloudFormation schema defines.

func (*CloudControlRepository) CreateResourceAndWait added in v0.14.0

func (r *CloudControlRepository) CreateResourceAndWait(resourceType cfg.ResourceType, desiredState string, maxWait time.Duration) (*Resource, error)

CreateResourceAndWait is CreateResource followed by WaitForResourceRequest, then a GetResource for the created resource's properties, so the caller gets the same Resource the read path produces. The returned Resource is nil when the request did not succeed; the error then explains why, and a *RequestFailedError in it means AWS rejected the change rather than the call.

func (*CloudControlRepository) CreateResourceByInput added in v0.14.0

CreateResourceByInput is CreateResource with the full SDK input, for callers that need RoleArn, TypeVersionId or their own ClientToken.

func (*CloudControlRepository) DeleteResource added in v0.14.0

func (r *CloudControlRepository) DeleteResource(resourceType cfg.ResourceType, identifier string) (*types.ProgressEvent, error)

DeleteResource asks Cloud Control to delete the resource with the given primary identifier, the same value Resource.Identifier carries.

func (*CloudControlRepository) DeleteResourceAndWait added in v0.14.0

func (r *CloudControlRepository) DeleteResourceAndWait(resourceType cfg.ResourceType, identifier string, maxWait time.Duration) (*types.ProgressEvent, error)

DeleteResourceAndWait is DeleteResource followed by WaitForResourceRequest. There is nothing to describe afterwards, so it returns the final event.

func (*CloudControlRepository) DeleteResourceByInput added in v0.14.0

DeleteResourceByInput is DeleteResource with the full SDK input.

func (*CloudControlRepository) DescribeResource

func (r *CloudControlRepository) DescribeResource(resourceType cfg.ResourceType, identifier *string) (*awscloudcontrol.GetResourceOutput, error)

func (*CloudControlRepository) DescribeResourceRequest added in v0.14.0

func (r *CloudControlRepository) DescribeResourceRequest(requestToken string) (*awscloudcontrol.GetResourceRequestStatusOutput, error)

DescribeResourceRequest returns the current status of a resource request by the RequestToken a write returned. The output also carries the hook invocations the request triggered, which is why it is the SDK output rather than the bare ProgressEvent.

func (*CloudControlRepository) FindResourceRequests added in v0.14.0

func (r *CloudControlRepository) FindResourceRequests(statuses ...types.OperationStatus) ([]types.ProgressEvent, error)

FindResourceRequests lists the account's resource requests in the client's region, newest first as AWS returns them. With no statuses it lists every request AWS still holds (about a week); with statuses it lists only those.

func (*CloudControlRepository) FindResources

func (*CloudControlRepository) GetRegion

func (r *CloudControlRepository) GetRegion() ptypes.AwsRegion

func (*CloudControlRepository) ListResourcesByInput added in v0.6.0

func (r *CloudControlRepository) ListResourcesByInput(query *cc.ListResourcesInput, detailed bool) ([]Resource, error)

ListResourcesByInput is the workhorse behind the two methods above. Passing the input directly gives callers ResourceModel (required to list nested types such as AWS::ApiGateway::Method) and MaxResults.

Neither a failed detail fetch nor unparsable properties drops the resource: both degrade to what was already known and log, because a silently shorter list is worse than a resource with missing attributes — the caller cannot tell the difference between "dropped" and "does not exist".

func (*CloudControlRepository) ListResourcesByType added in v0.6.0

func (r *CloudControlRepository) ListResourcesByType(resourceType cfg.ResourceType) ([]Resource, error)

ListResourcesByType lists every resource of resourceType through the Cloud Control API, using only the properties the LIST handler returns.

This is the generic path: it works for any AWS::*::* type whose Cloud Control registry entry implements LIST, with no per-type Go code. Types that only implement READ (or that need parent identifiers to be listed) come back as a Cloud Control error rather than an empty list — use ListResourcesByInput with a ResourceModel for the latter.

func (*CloudControlRepository) ListResourcesByTypeDetailed added in v0.6.0

func (r *CloudControlRepository) ListResourcesByTypeDetailed(resourceType cfg.ResourceType) ([]Resource, error)

ListResourcesByTypeDetailed is ListResourcesByType plus a GetResource per item, for types whose LIST handler returns only identifiers.

That is one extra API call per resource, so it is a separate method rather than the default: callers should reach for it only when they actually need full properties (S3 buckets need it, EC2 instances do not).

func (*CloudControlRepository) SetResourceTags added in v0.14.0

func (r *CloudControlRepository) SetResourceTags(resourceType cfg.ResourceType, identifier string, tags map[string]string) (*types.ProgressEvent, error)

SetResourceTags adds or replaces the given tags on a resource, keeping every other tag it carries. It reads the current properties, merges, and submits one UpdateResource; the returned event's RequestToken feeds WaitForResourceRequest. An empty tags map is a no-op returning nil, nil.

func (*CloudControlRepository) UntagResource added in v0.14.0

func (r *CloudControlRepository) UntagResource(resourceType cfg.ResourceType, identifier string, keys ...string) (*types.ProgressEvent, error)

UntagResource removes the given tag keys from a resource, keeping the rest. Keys the resource does not carry are not an error. No keys is a no-op returning nil, nil.

func (*CloudControlRepository) UpdateResource added in v0.14.0

func (r *CloudControlRepository) UpdateResource(resourceType cfg.ResourceType, identifier string, patchDocument string) (*types.ProgressEvent, error)

UpdateResource applies a JSON Patch (RFC 6902) document to the resource's current properties. Cloud Control rejects a patch touching a property the type's schema marks createOnly; such a change needs a delete and a create.

func (*CloudControlRepository) UpdateResourceAndWait added in v0.14.0

func (r *CloudControlRepository) UpdateResourceAndWait(resourceType cfg.ResourceType, identifier string, patchDocument string, maxWait time.Duration) (*Resource, error)

UpdateResourceAndWait is UpdateResource followed by WaitForResourceRequest and a GetResource for the resource's properties after the change.

func (*CloudControlRepository) UpdateResourceByInput added in v0.14.0

UpdateResourceByInput is UpdateResource with the full SDK input.

func (*CloudControlRepository) WaitForResourceRequest added in v0.14.0

func (r *CloudControlRepository) WaitForResourceRequest(requestToken string, maxWait time.Duration) (*types.ProgressEvent, error)

WaitForResourceRequest polls a request until it reaches a terminal status or maxWait elapses, and returns the final ProgressEvent. Poll timing comes from WithPollInterval or WithWaiterOptions, else the SDK defaults.

The SDK waiter alone reports a FAILED request as a bare "waiter state transitioned to Failure", losing the handler's StatusMessage and ErrorCode (AlreadyExists, NotFound, ...), which is the only thing a caller can act on. So on any waiter error the status is fetched once more; a request that ended FAILED or CANCEL_COMPLETE comes back as a *RequestFailedError wrapping that event, and the event is returned alongside the error in every case where the fetch succeeded. The event is nil only when that fetch fails too, which is what a timeout on an unreachable endpoint looks like.

func (*CloudControlRepository) WithCache added in v0.4.0

WithCache returns a CloudControlRepositoryCached that stores/retrieves results via the given DataCache. The cache namespace is set to "<accountID>:<region>:cloudcontrol".

The service name is part of the namespace because cache.Key renders a parameterless call as the bare method name, and several services expose the same one: ListClustersAll on ecs/eks/emr, ListTablesAll on dynamodb/glue. Sharing a namespace makes those repositories overwrite each other's entries, so every read decodes another service's payload, fails, and refetches from AWS.

func (*CloudControlRepository) WithPollInterval added in v0.14.0

func (r *CloudControlRepository) WithPollInterval(min, max time.Duration) *CloudControlRepository

WithPollInterval bounds the delay between two status polls while waiting on a request. The SDK grows the delay from min towards max with jitter; passing the same value for both polls at a fixed rate. Zero keeps the SDK default for that bound.

func (*CloudControlRepository) WithWaiterOptions added in v0.14.0

WithWaiterOptions sets the SDK waiter options used by every wait in this repository and returns the repository for chaining. Later calls replace earlier ones.

type CloudControlRepositoryCached added in v0.4.0

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

CloudControlRepositoryCached wraps CloudControlRepository and caches results of Get*/List* calls.

func (*CloudControlRepositoryCached) CancelResourceRequest added in v0.14.0

func (c *CloudControlRepositoryCached) CancelResourceRequest(requestToken string) (*types.ProgressEvent, error)

func (*CloudControlRepositoryCached) CreateResource added in v0.14.0

func (c *CloudControlRepositoryCached) CreateResource(resourceType cfg.ResourceType, desiredState string) (*types.ProgressEvent, error)

CreateResource delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) CreateResourceAndWait added in v0.14.0

func (c *CloudControlRepositoryCached) CreateResourceAndWait(resourceType cfg.ResourceType, desiredState string, maxWait time.Duration) (*Resource, error)

CreateResourceAndWait delegates, evicting cached lists both when the request is accepted and after it completes.

func (*CloudControlRepositoryCached) CreateResourceByInput added in v0.14.0

CreateResourceByInput delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) DeleteResource added in v0.14.0

func (c *CloudControlRepositoryCached) DeleteResource(resourceType cfg.ResourceType, identifier string) (*types.ProgressEvent, error)

DeleteResource delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) DeleteResourceAndWait added in v0.14.0

func (c *CloudControlRepositoryCached) DeleteResourceAndWait(resourceType cfg.ResourceType, identifier string, maxWait time.Duration) (*types.ProgressEvent, error)

DeleteResourceAndWait delegates, evicting cached lists both when the request is accepted and after it completes.

func (*CloudControlRepositoryCached) DeleteResourceByInput added in v0.14.0

DeleteResourceByInput delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) DescribeResourceRequest added in v0.14.0

func (c *CloudControlRepositoryCached) DescribeResourceRequest(requestToken string) (*awscloudcontrol.GetResourceRequestStatusOutput, error)

func (*CloudControlRepositoryCached) FindResourceRequests added in v0.14.0

func (c *CloudControlRepositoryCached) FindResourceRequests(statuses ...types.OperationStatus) ([]types.ProgressEvent, error)

func (*CloudControlRepositoryCached) InvalidateLists added in v0.14.0

func (c *CloudControlRepositoryCached) InvalidateLists()

InvalidateLists evicts every cached list in this repository's namespace. The write methods call it; it is exported for a caller that changed a resource through some other path and knows the cache is stale.

func (*CloudControlRepositoryCached) ListResourcesByInput added in v0.6.0

func (c *CloudControlRepositoryCached) ListResourcesByInput(query *awscloudcontrol.ListResourcesInput, detailed bool) ([]Resource, error)

ListResourcesByInput returns cached results when available, otherwise delegates to the underlying repository.

func (*CloudControlRepositoryCached) ListResourcesByType added in v0.6.0

func (c *CloudControlRepositoryCached) ListResourcesByType(resourceType cfg.ResourceType) ([]Resource, error)

ListResourcesByType returns cached results when available, otherwise delegates to the underlying repository.

func (*CloudControlRepositoryCached) ListResourcesByTypeDetailed added in v0.6.0

func (c *CloudControlRepositoryCached) ListResourcesByTypeDetailed(resourceType cfg.ResourceType) ([]Resource, error)

ListResourcesByTypeDetailed returns cached results when available, otherwise delegates to the underlying repository.

func (*CloudControlRepositoryCached) Repository added in v0.14.0

Repository returns the inner, uncached repository.

func (*CloudControlRepositoryCached) SetResourceTags added in v0.14.0

func (c *CloudControlRepositoryCached) SetResourceTags(resourceType cfg.ResourceType, identifier string, tags map[string]string) (*types.ProgressEvent, error)

SetResourceTags delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) UntagResource added in v0.14.0

func (c *CloudControlRepositoryCached) UntagResource(resourceType cfg.ResourceType, identifier string, keys ...string) (*types.ProgressEvent, error)

UntagResource delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) UpdateResource added in v0.14.0

func (c *CloudControlRepositoryCached) UpdateResource(resourceType cfg.ResourceType, identifier string, patchDocument string) (*types.ProgressEvent, error)

UpdateResource delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) UpdateResourceAndWait added in v0.14.0

func (c *CloudControlRepositoryCached) UpdateResourceAndWait(resourceType cfg.ResourceType, identifier string, patchDocument string, maxWait time.Duration) (*Resource, error)

UpdateResourceAndWait delegates, evicting cached lists both when the request is accepted and after it completes.

func (*CloudControlRepositoryCached) UpdateResourceByInput added in v0.14.0

UpdateResourceByInput delegates and evicts cached lists once the request is accepted.

func (*CloudControlRepositoryCached) WaitForResourceRequest added in v0.14.0

func (c *CloudControlRepositoryCached) WaitForResourceRequest(requestToken string, maxWait time.Duration) (*types.ProgressEvent, error)

type RequestFailedError added in v0.14.0

type RequestFailedError struct {
	Event *types.ProgressEvent
}

RequestFailedError is returned when a resource request reached a terminal status other than SUCCESS. It carries the final ProgressEvent so a caller can branch on the handler's error code with errors.As instead of matching text:

var failed *cloudcontrol.RequestFailedError
if errors.As(err, &failed) && failed.Code() == types.HandlerErrorCodeNotFound { ... }

func (*RequestFailedError) Code added in v0.14.0

Code is the handler error code, empty when the event carries none (a cancelled request, for instance).

func (*RequestFailedError) Error added in v0.14.0

func (e *RequestFailedError) Error() string

func (*RequestFailedError) Status added in v0.14.0

Status is the terminal status the request ended in: FAILED or CANCEL_COMPLETE.

type Resource added in v0.6.0

type Resource struct {
	service.AbstractResource
	cc.ResourceDescription

	// Attributes is the parsed Properties JSON object. Nested objects and
	// arrays are preserved as map[string]interface{} and []interface{}; both
	// are gob-registered in this package so they survive the cache.
	Attributes map[string]interface{}

	// Tags is lifted out of Attributes when the type carries a CloudFormation
	// style Tags list. Empty for types that do not.
	Tags map[string]string
}

Resource is a schema-less AWS resource fetched through the Cloud Control API.

Unlike the typed entities in this package (Instance, Bucket, Volume) it embeds no service-specific SDK struct: the resource's own fields stay in Attributes, exactly as Cloud Control returned them. That is what lets one repository method serve any AWS::*::* type whose registry entry implements the LIST handler, with no per-type Go code — the point of the generic path.

Attributes and Tags are exported deliberately. The cache handlers serialize with encoding/gob, which silently ignores unexported fields, so an unexported map here would come back empty from a cache hit rather than erroring — the resource would look real and its properties would have vanished.

func NewResource added in v0.6.0

func NewResource(
	client AwsClient,
	resourceType cfg.ResourceType,
	resource cc.ResourceDescription,
	attributes map[string]interface{},
	tags map[string]string,
) Resource

NewResource builds a generic resource from one Cloud Control list/get result. resourceType is passed in rather than derived because ResourceDescription does not carry the type it belongs to.

func (Resource) GetAttributes added in v0.6.0

func (e Resource) GetAttributes() map[string]interface{}

GetAttributes exposes the parsed Cloud Control properties. Consumers that curate attributes per resource type (e.g. an MCP server's summary view) can type-assert for this method to get a generic fallback for free.

func (Resource) GetName added in v0.6.0

func (e Resource) GetName() string

GetName resolves a display name without type-specific knowledge: the Name tag first (the convention most AWS consoles use), then a Name-ish property, then nothing. Callers still have GetId for identity — this is for humans.

func (Resource) GetTagValue added in v0.6.0

func (e Resource) GetTagValue(tag string) string

func (Resource) GetTags added in v0.6.0

func (e Resource) GetTags() map[string]string

Jump to

Keyboard shortcuts

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