or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/cloud.google.com/go/storage@1.59.x

docs

access-control.mdadvanced-features.mdclient-and-buckets.mdcontrol-api.mdexperimental-features.mdindex.mdobject-operations.mdperformance-features.md
tile.json

tessl/golang-cloud-google-com-go-storage

tessl install tessl/golang-cloud-google-com-go-storage@1.59.0

Google Cloud Storage client library for Go providing comprehensive APIs for bucket and object operations, access control, and advanced features

control-api.mddocs/

Storage Control API

This document covers the Storage Control API for managing folders, managed folders, anywhere caches, storage layouts, and intelligence configurations.

Import path: cloud.google.com/go/storage/control/apiv2

Capabilities

Storage Control Client

Main client for control plane operations.

/**
 * Creates a new Storage Control client.
 * @param ctx - Context for the operation
 * @param opts - Optional client configuration options
 * @returns StorageControlClient and error
 */
func NewStorageControlClient(ctx context.Context, opts ...option.ClientOption) (*StorageControlClient, error)

/**
 * Creates a REST-based Storage Control client.
 * @param ctx - Context for the operation
 * @param opts - Optional client configuration options
 * @returns StorageControlClient and error
 */
func NewStorageControlRESTClient(ctx context.Context, opts ...option.ClientOption) (*StorageControlClient, error)

/**
 * Returns default authentication scopes for the Control API.
 * @returns Slice of scope strings
 */
func DefaultAuthScopes() []string

Folder Operations

Manage hierarchical namespace folders.

/**
 * StorageControlClient provides Storage Control API operations.
 */
type StorageControlClient struct {
    // contains filtered or unexported fields
}

/**
 * Creates a new folder in a hierarchical namespace bucket.
 * @param ctx - Context for the operation
 * @param req - CreateFolderRequest
 * @param opts - Optional call options
 * @returns Folder and error
 */
func (c *StorageControlClient) CreateFolder(ctx context.Context, req *controlpb.CreateFolderRequest, opts ...gax.CallOption) (*controlpb.Folder, error)

/**
 * Deletes a folder.
 * @param ctx - Context for the operation
 * @param req - DeleteFolderRequest
 * @param opts - Optional call options
 * @returns Error if deletion fails
 */
func (c *StorageControlClient) DeleteFolder(ctx context.Context, req *controlpb.DeleteFolderRequest, opts ...gax.CallOption) error

/**
 * Retrieves folder metadata.
 * @param ctx - Context for the operation
 * @param req - GetFolderRequest
 * @param opts - Optional call options
 * @returns Folder and error
 */
func (c *StorageControlClient) GetFolder(ctx context.Context, req *controlpb.GetFolderRequest, opts ...gax.CallOption) (*controlpb.Folder, error)

/**
 * Lists folders in a bucket.
 * @param ctx - Context for the operation
 * @param req - ListFoldersRequest
 * @param opts - Optional call options
 * @returns FolderIterator
 */
func (c *StorageControlClient) ListFolders(ctx context.Context, req *controlpb.ListFoldersRequest, opts ...gax.CallOption) *FolderIterator

/**
 * Renames a folder (long-running operation).
 * @param ctx - Context for the operation
 * @param req - RenameFolderRequest
 * @param opts - Optional call options
 * @returns RenameFolderOperation and error
 */
func (c *StorageControlClient) RenameFolder(ctx context.Context, req *controlpb.RenameFolderRequest, opts ...gax.CallOption) (*RenameFolderOperation, error)

/**
 * FolderIterator iterates over folders.
 */
type FolderIterator struct {
    // contains filtered or unexported fields
}

/**
 * Returns the next folder.
 * @returns Folder and error (iterator.Done when complete)
 */
func (it *FolderIterator) Next() (*controlpb.Folder, error)

/**
 * Returns pagination information.
 * @returns iterator.PageInfo
 */
func (it *FolderIterator) PageInfo() *iterator.PageInfo

/**
 * Returns an iterator over all folders.
 * Go 1.23+ only.
 * @returns Iterator sequence
 */
func (it *FolderIterator) All() iter.Seq2[*controlpb.Folder, error]

Managed Folder Operations

Manage managed folders with IAM policies.

/**
 * Creates a managed folder.
 * @param ctx - Context for the operation
 * @param req - CreateManagedFolderRequest
 * @param opts - Optional call options
 * @returns ManagedFolder and error
 */
func (c *StorageControlClient) CreateManagedFolder(ctx context.Context, req *controlpb.CreateManagedFolderRequest, opts ...gax.CallOption) (*controlpb.ManagedFolder, error)

/**
 * Deletes a managed folder.
 * @param ctx - Context for the operation
 * @param req - DeleteManagedFolderRequest
 * @param opts - Optional call options
 * @returns Error if deletion fails
 */
func (c *StorageControlClient) DeleteManagedFolder(ctx context.Context, req *controlpb.DeleteManagedFolderRequest, opts ...gax.CallOption) error

/**
 * Retrieves managed folder metadata.
 * @param ctx - Context for the operation
 * @param req - GetManagedFolderRequest
 * @param opts - Optional call options
 * @returns ManagedFolder and error
 */
func (c *StorageControlClient) GetManagedFolder(ctx context.Context, req *controlpb.GetManagedFolderRequest, opts ...gax.CallOption) (*controlpb.ManagedFolder, error)

/**
 * Lists managed folders.
 * @param ctx - Context for the operation
 * @param req - ListManagedFoldersRequest
 * @param opts - Optional call options
 * @returns ManagedFolderIterator
 */
func (c *StorageControlClient) ListManagedFolders(ctx context.Context, req *controlpb.ListManagedFoldersRequest, opts ...gax.CallOption) *ManagedFolderIterator

/**
 * ManagedFolderIterator iterates over managed folders.
 */
type ManagedFolderIterator struct {
    // contains filtered or unexported fields
}

/**
 * Returns the next managed folder.
 * @returns ManagedFolder and error
 */
func (it *ManagedFolderIterator) Next() (*controlpb.ManagedFolder, error)

/**
 * Returns pagination information.
 * @returns iterator.PageInfo
 */
func (it *ManagedFolderIterator) PageInfo() *iterator.PageInfo

/**
 * Returns an iterator over all managed folders.
 * Go 1.23+ only.
 * @returns Iterator sequence
 */
func (it *ManagedFolderIterator) All() iter.Seq2[*controlpb.ManagedFolder, error]

Anywhere Cache Operations

Manage Anywhere Cache instances for edge caching.

/**
 * Creates an Anywhere Cache instance (long-running operation).
 * @param ctx - Context for the operation
 * @param req - CreateAnywhereCacheRequest
 * @param opts - Optional call options
 * @returns CreateAnywhereCacheOperation and error
 */
func (c *StorageControlClient) CreateAnywhereCache(ctx context.Context, req *controlpb.CreateAnywhereCacheRequest, opts ...gax.CallOption) (*CreateAnywhereCacheOperation, error)

/**
 * Updates an Anywhere Cache instance (long-running operation).
 * @param ctx - Context for the operation
 * @param req - UpdateAnywhereCacheRequest
 * @param opts - Optional call options
 * @returns UpdateAnywhereCacheOperation and error
 */
func (c *StorageControlClient) UpdateAnywhereCache(ctx context.Context, req *controlpb.UpdateAnywhereCacheRequest, opts ...gax.CallOption) (*UpdateAnywhereCacheOperation, error)

/**
 * Disables an Anywhere Cache instance.
 * @param ctx - Context for the operation
 * @param req - DisableAnywhereCacheRequest
 * @param opts - Optional call options
 * @returns AnywhereCache and error
 */
func (c *StorageControlClient) DisableAnywhereCache(ctx context.Context, req *controlpb.DisableAnywhereCacheRequest, opts ...gax.CallOption) (*controlpb.AnywhereCache, error)

/**
 * Pauses an Anywhere Cache instance.
 * @param ctx - Context for the operation
 * @param req - PauseAnywhereCacheRequest
 * @param opts - Optional call options
 * @returns AnywhereCache and error
 */
func (c *StorageControlClient) PauseAnywhereCache(ctx context.Context, req *controlpb.PauseAnywhereCacheRequest, opts ...gax.CallOption) (*controlpb.AnywhereCache, error)

/**
 * Resumes an Anywhere Cache instance.
 * @param ctx - Context for the operation
 * @param req - ResumeAnywhereCacheRequest
 * @param opts - Optional call options
 * @returns AnywhereCache and error
 */
func (c *StorageControlClient) ResumeAnywhereCache(ctx context.Context, req *controlpb.ResumeAnywhereCacheRequest, opts ...gax.CallOption) (*controlpb.AnywhereCache, error)

/**
 * Retrieves Anywhere Cache metadata.
 * @param ctx - Context for the operation
 * @param req - GetAnywhereCacheRequest
 * @param opts - Optional call options
 * @returns AnywhereCache and error
 */
func (c *StorageControlClient) GetAnywhereCache(ctx context.Context, req *controlpb.GetAnywhereCacheRequest, opts ...gax.CallOption) (*controlpb.AnywhereCache, error)

/**
 * Lists Anywhere Cache instances.
 * @param ctx - Context for the operation
 * @param req - ListAnywhereCachesRequest
 * @param opts - Optional call options
 * @returns AnywhereCacheIterator
 */
func (c *StorageControlClient) ListAnywhereCaches(ctx context.Context, req *controlpb.ListAnywhereCachesRequest, opts ...gax.CallOption) *AnywhereCacheIterator

/**
 * AnywhereCacheIterator iterates over Anywhere Cache instances.
 */
type AnywhereCacheIterator struct {
    // contains filtered or unexported fields
}

/**
 * Returns the next cache.
 * @returns AnywhereCache and error
 */
func (it *AnywhereCacheIterator) Next() (*controlpb.AnywhereCache, error)

/**
 * Returns pagination information.
 * @returns iterator.PageInfo
 */
func (it *AnywhereCacheIterator) PageInfo() *iterator.PageInfo

/**
 * Returns an iterator over all caches.
 * Go 1.23+ only.
 * @returns Iterator sequence
 */
func (it *AnywhereCacheIterator) All() iter.Seq2[*controlpb.AnywhereCache, error]

Long-Running Operations

Operations that may take time to complete.

/**
 * CreateAnywhereCacheOperation represents a long-running cache creation.
 */
type CreateAnywhereCacheOperation struct {
    // contains filtered or unexported fields
}

/**
 * Checks if the operation is complete.
 * @returns True if complete
 */
func (op *CreateAnywhereCacheOperation) Done() bool

/**
 * Returns the operation name.
 * @returns Operation name
 */
func (op *CreateAnywhereCacheOperation) Name() string

/**
 * Polls for the latest operation state.
 * @param ctx - Context for the operation
 * @param opts - Optional call options
 * @returns AnywhereCache and error
 */
func (op *CreateAnywhereCacheOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*controlpb.AnywhereCache, error)

/**
 * Waits for the operation to complete.
 * @param ctx - Context for the operation
 * @param opts - Optional call options
 * @returns AnywhereCache and error
 */
func (op *CreateAnywhereCacheOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*controlpb.AnywhereCache, error)

/**
 * Returns operation metadata.
 * @returns CreateAnywhereCacheMetadata and error
 */
func (op *CreateAnywhereCacheOperation) Metadata() (*controlpb.CreateAnywhereCacheMetadata, error)

/**
 * UpdateAnywhereCacheOperation represents a long-running cache update.
 * Methods: Done, Name, Poll, Wait, Metadata (same signatures as CreateAnywhereCacheOperation)
 */
type UpdateAnywhereCacheOperation struct {
    // contains filtered or unexported fields
}

/**
 * RenameFolderOperation represents a long-running folder rename.
 * Methods: Done, Name, Poll, Wait, Metadata
 * Returns *controlpb.Folder and *controlpb.RenameFolderMetadata
 */
type RenameFolderOperation struct {
    // contains filtered or unexported fields
}

/**
 * Gets a long-running operation handle by name.
 * @param name - Operation name
 * @returns CreateAnywhereCacheOperation
 */
func (c *StorageControlClient) CreateAnywhereCacheOperation(name string) *CreateAnywhereCacheOperation

/**
 * Gets a long-running operation handle by name.
 * @param name - Operation name
 * @returns UpdateAnywhereCacheOperation
 */
func (c *StorageControlClient) UpdateAnywhereCacheOperation(name string) *UpdateAnywhereCacheOperation

/**
 * Gets a long-running operation handle by name.
 * @param name - Operation name
 * @returns RenameFolderOperation
 */
func (c *StorageControlClient) RenameFolderOperation(name string) *RenameFolderOperation

Storage Layout and Intelligence

Bucket layout information and intelligence configurations.

/**
 * Retrieves the storage layout for a bucket.
 * @param ctx - Context for the operation
 * @param req - GetStorageLayoutRequest
 * @param opts - Optional call options
 * @returns StorageLayout and error
 */
func (c *StorageControlClient) GetStorageLayout(ctx context.Context, req *controlpb.GetStorageLayoutRequest, opts ...gax.CallOption) (*controlpb.StorageLayout, error)

/**
 * Retrieves project intelligence configuration.
 * @param ctx - Context for the operation
 * @param req - GetProjectIntelligenceConfigRequest
 * @param opts - Optional call options
 * @returns IntelligenceConfig and error
 */
func (c *StorageControlClient) GetProjectIntelligenceConfig(ctx context.Context, req *controlpb.GetProjectIntelligenceConfigRequest, opts ...gax.CallOption) (*controlpb.IntelligenceConfig, error)

/**
 * Updates project intelligence configuration.
 * @param ctx - Context for the operation
 * @param req - UpdateProjectIntelligenceConfigRequest
 * @param opts - Optional call options
 * @returns IntelligenceConfig and error
 */
func (c *StorageControlClient) UpdateProjectIntelligenceConfig(ctx context.Context, req *controlpb.UpdateProjectIntelligenceConfigRequest, opts ...gax.CallOption) (*controlpb.IntelligenceConfig, error)

/**
 * Retrieves folder intelligence configuration.
 * @param ctx - Context for the operation
 * @param req - GetFolderIntelligenceConfigRequest
 * @param opts - Optional call options
 * @returns IntelligenceConfig and error
 */
func (c *StorageControlClient) GetFolderIntelligenceConfig(ctx context.Context, req *controlpb.GetFolderIntelligenceConfigRequest, opts ...gax.CallOption) (*controlpb.IntelligenceConfig, error)

/**
 * Updates folder intelligence configuration.
 * @param ctx - Context for the operation
 * @param req - UpdateFolderIntelligenceConfigRequest
 * @param opts - Optional call options
 * @returns IntelligenceConfig and error
 */
func (c *StorageControlClient) UpdateFolderIntelligenceConfig(ctx context.Context, req *controlpb.UpdateFolderIntelligenceConfigRequest, opts ...gax.CallOption) (*controlpb.IntelligenceConfig, error)

/**
 * Retrieves organization intelligence configuration.
 * @param ctx - Context for the operation
 * @param req - GetOrganizationIntelligenceConfigRequest
 * @param opts - Optional call options
 * @returns IntelligenceConfig and error
 */
func (c *StorageControlClient) GetOrganizationIntelligenceConfig(ctx context.Context, req *controlpb.GetOrganizationIntelligenceConfigRequest, opts ...gax.CallOption) (*controlpb.IntelligenceConfig, error)

/**
 * Updates organization intelligence configuration.
 * @param ctx - Context for the operation
 * @param req - UpdateOrganizationIntelligenceConfigRequest
 * @param opts - Optional call options
 * @returns IntelligenceConfig and error
 */
func (c *StorageControlClient) UpdateOrganizationIntelligenceConfig(ctx context.Context, req *controlpb.UpdateOrganizationIntelligenceConfigRequest, opts ...gax.CallOption) (*controlpb.IntelligenceConfig, error)

IAM Operations

IAM policy management for control plane resources.

/**
 * Retrieves the IAM policy.
 * @param ctx - Context for the operation
 * @param req - GetIamPolicyRequest
 * @param opts - Optional call options
 * @returns Policy and error
 */
func (c *StorageControlClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

/**
 * Sets the IAM policy.
 * @param ctx - Context for the operation
 * @param req - SetIamPolicyRequest
 * @param opts - Optional call options
 * @returns Policy and error
 */
func (c *StorageControlClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

/**
 * Tests IAM permissions.
 * @param ctx - Context for the operation
 * @param req - TestIamPermissionsRequest
 * @param opts - Optional call options
 * @returns TestIamPermissionsResponse and error
 */
func (c *StorageControlClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)

Client Management

Connection and lifecycle management.

/**
 * Closes the client and releases resources.
 * @returns Error if close fails
 */
func (c *StorageControlClient) Close() error

/**
 * Returns the underlying gRPC connection.
 * @returns ClientConn
 */
func (c *StorageControlClient) Connection() *grpc.ClientConn

Usage Example:

import (
    "context"
    control "cloud.google.com/go/storage/control/apiv2"
    controlpb "cloud.google.com/go/storage/control/apiv2/controlpb"
    "google.golang.org/api/iterator"
)

ctx := context.Background()

// Create control client
client, err := control.NewStorageControlClient(ctx)
if err != nil {
    log.Fatal(err)
}
defer client.Close()

// Create a folder
req := &controlpb.CreateFolderRequest{
    Parent:   "projects/_/buckets/my-bucket",
    FolderId: "my-folder",
}
folder, err := client.CreateFolder(ctx, req)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Created folder: %s\n", folder.Name)

// List folders
listReq := &controlpb.ListFoldersRequest{
    Parent: "projects/_/buckets/my-bucket",
}
it := client.ListFolders(ctx, listReq)
for {
    folder, err := it.Next()
    if err == iterator.Done {
        break
    }
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Folder: %s\n", folder.Name)
}

// Rename folder (long-running operation)
renameReq := &controlpb.RenameFolderRequest{
    Name:              "projects/_/buckets/my-bucket/folders/old-name",
    DestinationFolder: "projects/_/buckets/my-bucket/folders/new-name",
}
op, err := client.RenameFolder(ctx, renameReq)
if err != nil {
    log.Fatal(err)
}

// Wait for operation to complete
folder, err = op.Wait(ctx)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Renamed folder: %s\n", folder.Name)