src/connectors/connector_storage.workflows.yaml (46 lines of code) (raw):

# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # [START workflows_connector_storage] # 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 - encoded_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: ${encoded_object_name} body: "hello world" - download_object_media: call: googleapis.storage.v1.objects.get args: bucket: ${bucket_name} object: ${encoded_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: ${encoded_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: ${encoded_object_name} - delete_bucket: call: googleapis.storage.v1.buckets.delete args: bucket: ${bucket_name} - the_end: return: "SUCCESS" # [END workflows_connector_storage]