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 and url_encode_plus functions to encode applicable characters when they appear in either the object name or query string of a request URL. If you don't url-encode your object name and your storage bucket has folders, the request will fail. For more information, see Encoding URL path parts and Cloud Storage naming considerations.

Cloud Storage JSON connector sample

YAML

# This workflow demonstrates how to use the Cloud Storage connector:
# Create a bucket and upload an object to the bucket
# Delete the bucket and the object
# Expected output: "SUCCESS"
- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - bucket_name: "BUCKET_NAME"  # replace BUCKET_NAME and FILE_NAME placeholders
      - object_name: ${text.url_encode("FILE_NAME.txt")}  # URL-encode object names to be path safe
- create_bucket:
    call: googleapis.storage.v1.buckets.insert
    args:
      project: ${project_id}
      body:
        name: ${bucket_name}
- upload_object_media:
    call: googleapis.storage.v1.objects.insert
    args:
      bucket: ${bucket_name}
      uploadType: "media"  # uploads object data
      name: ${object_name}
      body: "hello world"
- download_object_media:
    call: googleapis.storage.v1.objects.get
    args:
      bucket: ${bucket_name}
      object: ${object_name}
      alt: "media"  # gets object data
    result: object_data
# If `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
- get_bucket:
    call: googleapis.storage.v1.buckets.get
    args:
      bucket: ${bucket_name}
- delete_object:
    call: googleapis.storage.v1.objects.delete
    args:
      bucket: ${bucket_name}
      object: ${object_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": "${text.url_encode(\"FILE_NAME.txt\")}"
        }
      ]
    }
  },
  {
    "create_bucket": {
      "call": "googleapis.storage.v1.buckets.insert",
      "args": {
        "project": "${project_id}",
        "body": {
          "name": "${bucket_name}"
        }
      }
    }
  },
  {
    "upload_object_media": {
      "call": "googleapis.storage.v1.objects.insert",
      "args": {
        "bucket": "${bucket_name}",
        "uploadType": "media",
        "name": "${object_name}",
        "body": "hello world"
      }
    }
  },
  {
    "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"
    }
  },
  {
    "get_bucket": {
      "call": "googleapis.storage.v1.buckets.get",
      "args": {
        "bucket": "${bucket_name}"
      }
    }
  },
  {
    "delete_object": {
      "call": "googleapis.storage.v1.objects.delete",
      "args": {
        "bucket": "${bucket_name}",
        "object": "${object_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.