Cloud Storage JSON API Connector Overview

The Workflows connector defines the built-in functions that can be used to access other Google Cloud products within a workflow.

This page provides an overview of the individual connector. There is no need to import or load connector libraries in a workflow—connectors work out of the box when used in a call step.

Cloud Storage JSON API

Stores and retrieves potentially large, immutable data objects. To learn more, see the Cloud Storage JSON API documentation.

You should URL-encode object names to be path safe. You can use the url_encode function to return a string with percent-encoded reserved characters, including spaces. For more information, see Encoding URI path parts.

Cloud Storage JSON connector sample

YAML

# This workflow demonstrates how to use the Cloud Storage connector.
# The workflow shows how to download/upload simple objects.
# The workflow creates a Cloud Storage bucket and then deletes it.
# Expected successful output: "SUCCESS"

- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - bucket_name: "bucket-name"
      - object_name: "object-name"
# When alt=media, get object data.
- download_object_media:
    call: googleapis.storage.v1.objects.get
    args:
      bucket: ${bucket_name}
      object: ${object_name}
      alt: "media"
    result: object_data
# When alt is not set, get metadata.
- get_object_metadata:
    call: googleapis.storage.v1.objects.get
    args:
      bucket: ${bucket_name}
      object: ${object_name}
    result: object_metadata
# When uploadType=media, upload object data.
# Use objects.update to udpate object metadata.
- upload_object_media:
    call: googleapis.storage.v1.objects.insert
    args:
      bucket: ${bucket_name}
      uploadType: "media"
      name: ${object_name}
      body: "hello world"
- create_bucket:
    call: googleapis.storage.v1.buckets.insert
    args:
      project: ${project_id}
      body:
        name: ${bucket_name}
- get_bucket:
    call: googleapis.storage.v1.buckets.get
    args:
      bucket: ${bucket_name}
- delete_bucket:
    call: googleapis.storage.v1.buckets.delete
    args:
      bucket: ${bucket_name}
- the_end:
    return: "SUCCESS"

JSON

[
  {
    "init": {
      "assign": [
        {
          "project_id": "${sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\")}"
        },
        {
          "bucket_name": "bucket-name"
        },
        {
          "object_name": "object-name"
        }
      ]
    }
  },
  {
    "download_object_media": {
      "call": "googleapis.storage.v1.objects.get",
      "args": {
        "bucket": "${bucket_name}",
        "object": "${object_name}",
        "alt": "media"
      },
      "result": "object_data"
    }
  },
  {
    "get_object_metadata": {
      "call": "googleapis.storage.v1.objects.get",
      "args": {
        "bucket": "${bucket_name}",
        "object": "${object_name}"
      },
      "result": "object_metadata"
    }
  },
  {
    "upload_object_media": {
      "call": "googleapis.storage.v1.objects.insert",
      "args": {
        "bucket": "${bucket_name}",
        "uploadType": "media",
        "name": "${object_name}",
        "body": "hello world"
      }
    }
  },
  {
    "create_bucket": {
      "call": "googleapis.storage.v1.buckets.insert",
      "args": {
        "project": "${project_id}",
        "body": {
          "name": "${bucket_name}"
        }
      }
    }
  },
  {
    "get_bucket": {
      "call": "googleapis.storage.v1.buckets.get",
      "args": {
        "bucket": "${bucket_name}"
      }
    }
  },
  {
    "delete_bucket": {
      "call": "googleapis.storage.v1.buckets.delete",
      "args": {
        "bucket": "${bucket_name}"
      }
    }
  },
  {
    "the_end": {
      "return": "SUCCESS"
    }
  }
]

Module: googleapis.storage.v1.bucketAccessControls

Functions
delete Permanently deletes the ACL entry for the specified entity on the specified bucket.
get Returns the ACL entry for the specified entity on the specified bucket.
insert Creates a new ACL entry on the specified bucket.
list Retrieves ACL entries on the specified bucket.
patch Patches an ACL entry on the specified bucket.
update Updates an ACL entry on the specified bucket.

Module: googleapis.storage.v1.buckets

Functions
delete Permanently deletes an empty bucket.
get Returns metadata for the specified bucket.
getIamPolicy Returns an IAM policy for the specified bucket.
insert Creates a new bucket.
list Retrieves a list of buckets for a given project.
lockRetentionPolicy Locks retention policy on a bucket.
patch Patches a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
setIamPolicy Updates an IAM policy for the specified bucket.
testIamPermissions Tests a set of permissions on the given bucket to see which, if any, are held by the caller.
update Updates a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.

Module: googleapis.storage.v1.channels

Functions
stop Stop watching resources through this channel

Module: googleapis.storage.v1.defaultObjectAccessControls

Functions
delete Permanently deletes the default object ACL entry for the specified entity on the specified bucket.
get Returns the default object ACL entry for the specified entity on the specified bucket.
insert Creates a new default object ACL entry on the specified bucket.
list Retrieves default object ACL entries on the specified bucket.
patch Patches a default object ACL entry on the specified bucket.
update Updates a default object ACL entry on the specified bucket.

Module: googleapis.storage.v1.notifications

Functions
delete Permanently deletes a notification subscription.
get View a notification configuration.
insert Creates a notification subscription for a given bucket.
list Retrieves a list of notification subscriptions for a given bucket.

Module: googleapis.storage.v1.objectAccessControls

Functions
delete Permanently deletes the ACL entry for the specified entity on the specified object.
get Returns the ACL entry for the specified entity on the specified object.
insert Creates a new ACL entry on the specified object.
list Retrieves ACL entries on the specified object.
patch Patches an ACL entry on the specified object.
update Updates an ACL entry on the specified object.

Module: googleapis.storage.v1.objects

Functions
compose Concatenates a list of existing objects into a new object in the same bucket.
copy Copies a source object to a destination object. Optionally overrides metadata.
delete Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.
get Retrieves an object or its metadata.
insert Stores a new object and metadata.
list Retrieves a list of objects matching the criteria.
patch Patches an object's metadata.
rewrite Rewrites a source object to a destination object. Optionally overrides metadata.
update Updates an object's metadata.
watchAll Watch for changes on all objects in a bucket.