gcp-storage
| Kind | kit |
|---|---|
| Categories | cloud web |
| Keywords | gcp google-cloud cloud storage object-storage |
GCP Cloud Storage client for Kit
Files
| File | Description |
|---|---|
kit.toml | Package manifest with metadata and dependencies |
src/storage.kit | Cloud Storage bucket and object operations |
tests/test-live-storage.kit | Live integration tests with real GCS bucket |
examples/basic.kit | List buckets and objects via metadata server auth |
examples/list-with-prefix.kit | Directory-style listing with prefix and delimiter |
examples/upload-download.kit | Upload content, verify metadata, and download it back |
LICENSE | MIT license file |
Dependencies
cryptogcp-corejsonrsa
Installation
kit add gitlab.com/kit-lang/packages/kit-gcp-storage.gitUsage
import Kit.GcpStorageLicense
MIT License - see LICENSE for details.
Exported Functions & Types
GCPStorageError
GCP Storage error type with specific variants for different failure modes.
Variants
GCPStorageNotFoundError {message, resource}GCPStoragePermissionDeniedError {message, resource}GCPStorageConflictError {message, resource}GCPStoragePreconditionFailedError {message}GCPStorageRateLimitError {message, retry-after-ms}GCPStorageServerError {message, status}GCPStorageObjectError {message}GCPStorageBucketError {message}GCPStorageValidationError {message}is-retryable?
Check if a storage error is retryable.
Returns true for transient errors that may succeed on retry: - Rate limit errors (with backoff) - Server errors (5xx)
GCPStorageError -> Bool
client
{project-id: String, service-account: {project-id: String, private-key-id: String, private-key: String, client-email: String, client-id: String, token-uri: String}, access-token: {token: String, expires-at-ms: Int}} -> StorageClient
client-from-metadata
() -> Result StorageClient String
client-from-env
() -> Result StorageClient String
client-with-token
String -> String -> StorageClient
get-object
StorageClient -> String -> String -> Result String GCPStorageError
download-to-file
StorageClient -> String -> String -> String -> Result () GCPStorageError
put-object
StorageClient -> String -> String -> String -> Result () GCPStorageError
put-object-with-type
StorageClient -> String -> String -> String -> String -> Result () GCPStorageError
start-resumable-upload
StorageClient -> String -> String -> String -> Int -> Result String GCPStorageError
resume-upload
String -> String -> String -> Result ObjectInfo GCPStorageError
resumable-upload
StorageClient -> String -> String -> String -> String -> Result ObjectInfo GCPStorageError
resumable-upload-file
StorageClient -> String -> String -> String -> Result ObjectInfo GCPStorageError
default-chunk-size
Int
upload-chunk
String -> String -> Int -> Int -> Int -> String -> Result (Option ObjectInfo) GCPStorageError
get-upload-status
String -> Int -> Result Int GCPStorageError
chunked-upload
StorageClient -> String -> String -> String -> String -> Int -> Result ObjectInfo GCPStorageError
chunked-upload-file
StorageClient -> String -> String -> String -> Int -> Result ObjectInfo GCPStorageError
delete-object
StorageClient -> String -> String -> Result () GCPStorageError
exists?
StorageClient -> String -> String -> Bool
head-object
StorageClient -> String -> String -> Result ObjectInfo GCPStorageError
update-object-metadata
StorageClient -> String -> String -> {content-type: String, cache-control: String, content-disposition: String, content-encoding: String, content-language: String} -> Result ObjectInfo GCPStorageError
set-content-type
StorageClient -> String -> String -> String -> Result ObjectInfo GCPStorageError
set-cache-control
StorageClient -> String -> String -> String -> Result ObjectInfo GCPStorageError
set-custom-metadata
StorageClient -> String -> String -> List (String, String) -> Result ObjectInfo GCPStorageError
copy-object
StorageClient -> String -> String -> String -> String -> Result () GCPStorageError
move-object
StorageClient -> String -> String -> String -> String -> Result () GCPStorageError
compose-objects
StorageClient -> String -> List String -> String -> Result ObjectInfo GCPStorageError
compose-objects-with-generations
StorageClient -> String -> List {name: String, generation: String} -> String -> Result ObjectInfo GCPStorageError
list-objects
StorageClient -> String -> String -> Int -> Result ListObjectsResponse GCPStorageError
list-objects-with-token
StorageClient -> String -> String -> Int -> String -> Result ListObjectsResponse GCPStorageError
list-objects-delimiter
StorageClient -> String -> String -> String -> Int -> Result ListObjectsResponse GCPStorageError
list-buckets
StorageClient -> Result ListBucketsResponse GCPStorageError
list-buckets-with-token
StorageClient -> String -> Result ListBucketsResponse GCPStorageError
get-bucket
StorageClient -> String -> Result BucketInfo GCPStorageError
create-bucket
StorageClient -> String -> Result () GCPStorageError
create-bucket-with-options
StorageClient -> String -> String -> String -> Result () GCPStorageError
delete-bucket
StorageClient -> String -> Result () GCPStorageError
is-versioning-enabled?
StorageClient -> String -> Result Bool GCPStorageError
enable-versioning
StorageClient -> String -> Result () GCPStorageError
disable-versioning
StorageClient -> String -> Result () GCPStorageError
list-object-versions
StorageClient -> String -> String -> Int -> Result ListObjectsResponse GCPStorageError
list-object-versions-with-token
StorageClient -> String -> String -> Int -> String -> Result ListObjectsResponse GCPStorageError
get-object-version
StorageClient -> String -> String -> String -> Result String GCPStorageError
head-object-version
StorageClient -> String -> String -> String -> Result ObjectInfo GCPStorageError
delete-object-version
StorageClient -> String -> String -> String -> Result () GCPStorageError
restore-object-version
StorageClient -> String -> String -> String -> Result ObjectInfo GCPStorageError
delete-after-days
Int -> LifecycleRule
delete-prefix-after-days
String -> Int -> LifecycleRule
transition-after-days
String -> Int -> LifecycleRule
delete-old-versions
Int -> Int -> LifecycleRule
get-lifecycle-rules
StorageClient -> String -> Result (List LifecycleRule) GCPStorageError
set-lifecycle-rules
StorageClient -> String -> List LifecycleRule -> Result () GCPStorageError
delete-lifecycle-rules
StorageClient -> String -> Result () GCPStorageError
CORS rule for cross-origin resource sharing configuration.
cors-allow-all
Int -> CorsRule
cors-for-origins
List String -> List String -> Int -> CorsRule
cors-read-only
List String -> Int -> CorsRule
get-cors
StorageClient -> String -> Result (List CorsRule) GCPStorageError
set-cors
StorageClient -> String -> List CorsRule -> Result () GCPStorageError
delete-cors
StorageClient -> String -> Result () GCPStorageError
Retention policy for a bucket.
retention-days
Int -> RetentionPolicy
retention-years
Int -> RetentionPolicy
retention-seconds
Int -> RetentionPolicy
get-retention-policy
StorageClient -> String -> Result (Option RetentionPolicy) GCPStorageError
set-retention-policy
StorageClient -> String -> RetentionPolicy -> Result () GCPStorageError
remove-retention-policy
StorageClient -> String -> Result () GCPStorageError
lock-retention-policy
StorageClient -> String -> Result () GCPStorageError
has-retention-policy?
StorageClient -> String -> Bool
is-retention-locked?
StorageClient -> String -> Bool
IAM binding representing a role assignment to members.
IAM policy for a bucket.
iam-role-object-viewer
Role for viewing objects (read-only access to objects)
String
iam-role-object-creator
Role for creating objects (can upload but not delete)
String
iam-role-object-admin
Role for full control of objects (read, write, delete objects)
String
iam-role-admin
Role for full control of bucket and objects
String
iam-role-legacy-bucket-reader
Role for viewing bucket metadata and listing objects
String
iam-role-legacy-bucket-writer
Role for creating, replacing, and deleting objects
String
iam-binding
String -> List String -> IamBinding
iam-public-read
() -> IamBinding
get-iam-policy
StorageClient -> String -> Result IamPolicy GCPStorageError
set-iam-policy
StorageClient -> String -> IamPolicy -> Result IamPolicy GCPStorageError
add-iam-binding
StorageClient -> String -> IamBinding -> Result IamPolicy GCPStorageError
remove-iam-binding
StorageClient -> String -> String -> List String -> Result IamPolicy GCPStorageError
is-public?
StorageClient -> String -> Bool
make-public
StorageClient -> String -> Result IamPolicy GCPStorageError
make-private
StorageClient -> String -> Result IamPolicy GCPStorageError
get-labels
Gets labels from a bucket.
Labels are key-value pairs used for organizing and categorizing buckets. They can be used for billing reports, resource management, and filtering.
Parameters:
Returns:
StorageClient -> String -> Result (List (String, String)) GCPStorageError
match Storage.get-labels client "my-bucket"
| Ok labels ->
List.fold (fn(_, pair) =>
match pair | (k, v) -> println " ${k}: ${v}"
) no-op labels
| Err e -> println "Failed: ${e}"set-labels
Sets labels on a bucket, replacing all existing labels.
This replaces all labels on the bucket with the provided labels. To add/update specific labels while preserving others, use update-labels.
Parameters:
Returns:
StorageClient -> String -> List (String, String) -> Result (List (String, String)) GCPStorageError
labels = [("environment", "production"), ("team", "backend")]
match Storage.set-labels client "my-bucket" labels
| Ok _ -> println "Labels set"
| Err e -> println "Failed: ${e}"update-labels
Updates labels on a bucket, merging with existing labels.
This adds or updates the specified labels while preserving existing ones. To remove a label, use remove-label or remove-labels.
Parameters:
Returns:
StorageClient -> String -> List (String, String) -> Result (List (String, String)) GCPStorageError
# Add a new label without removing existing ones
match Storage.update-labels client "my-bucket" [("version", "2.0")]
| Ok labels -> println "Updated labels"
| Err e -> println "Failed: ${e}"remove-label
Removes a single label from a bucket.
Parameters:
Returns:
StorageClient -> String -> String -> Result (List (String, String)) GCPStorageError
match Storage.remove-label client "my-bucket" "deprecated"
| Ok _ -> println "Label removed"
| Err e -> println "Failed: ${e}"remove-labels
Removes multiple labels from a bucket.
Parameters:
Returns:
StorageClient -> String -> List String -> Result (List (String, String)) GCPStorageError
match Storage.remove-labels client "my-bucket" ["temp", "deprecated"]
| Ok labels -> println "Labels removed"
| Err e -> println "Failed: ${e}"clear-labels
Clears all labels from a bucket.
Parameters:
Returns:
StorageClient -> String -> Result () GCPStorageError
match Storage.clear-labels client "my-bucket"
| Ok _ -> println "All labels cleared"
| Err e -> println "Failed: ${e}"get-label
Gets a specific label value from a bucket.
Parameters:
Returns:
StorageClient -> String -> String -> Option String
match Storage.get-label client "my-bucket" "environment"
| Some env -> println "Environment: ${env}"
| None -> println "No environment label"has-label?
Checks if a bucket has a specific label.
Parameters:
Returns:
StorageClient -> String -> String -> Bool
if Storage.has-label? client "my-bucket" "production" then
println "This is a production bucket"upload-file
StorageClient -> String -> String -> String -> Result () GCPStorageError
download-file
StorageClient -> String -> String -> String -> Result () GCPStorageError
signed-url
StorageClient -> String -> String -> Int -> String -> Result String GCPStorageError