Skip to main content
Version: 11 - TBD

ConnectorTypeGOOGLE

class connector_types.connector_type_google.ConnectorTypeGOOGLE

Interact with Google APIs

This connector type enables you to access any Google API. See The official Python client library for Google's discovery based APIs or The Google API Explorer for a description of available APIs and their collections and requests.

Input Schema

  • schema_version

    Type: string

  • authentication

    Type: anyOf

  • mode

    Type: anyOf

  • encoding

    The encoding to use when binary data is returned by the server.

    Type: string

    Default: utf-8

  • ignore_decoding_errors

    If set, decoding errors will be ignored.

    Binary data which cannot be decoded into strings will be returned as bytes:base64:<base64-string>.

    Type: boolean

    Default: True

Output Schema

Example

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='GOOGLE',
name='launch instance',
authentication={
'authentication_method': 'service_account',
'key': '...',
'scopes': ['https://www.googleapis.com/auth/compute'],
},
mode={
'mode_name': 'call_client_method',
'api_name': 'compute',
'api_version': 'v1',
'collection': 'instances',
'method': 'insert',
'kwargs': {
'body': instance_config,
'project': project_id,
'zone': 'europe-west3-b',
},
},
)
this.log('instance was started')

return this.success('all done')

More

Media Upload

Some API methods support uploading media files. All of these methods have a parameter called media_body. Cloudomation Engine supports uploading strings, Cloudomation Engine file objects or base64-encoded binary data.

Uploading Strings

Use the following format for the media_body parameter:

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='GOOGLE',
name='upload a string to a cloud storage bucket',
authentication={
'authentication_method': 'service_account',
'key': '...',
'scopes': ['https://www.googleapis.com/auth/storage'],
},
mode={
'mode_name': 'call_client_method',
'api_name': 'storage',
'api_version': 'v1',
'collection': 'objects',
'method': 'insert',
'kwargs': {
'bucket': 'my-bucket-name',
'body': {
'name': 'the-file-name.ext'
},
'media_body': {
'string': 'the-file-content',
'mimetype': 'text/plain',
},
},
},
)
return this.success('all done')
Uploading Cloudomation Engine Files

Use the following format for the media_body parameter:

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='GOOGLE',
name='upload a Cloudomation Engine file to a cloud storage bucket',
authentication={
'authentication_method': 'service_account',
'key': '...',
'scopes': ['https://www.googleapis.com/auth/storage'],
},
mode={
'mode_name': 'call_client_method',
'api_name': 'storage',
'api_version': 'v1',
'collection': 'objects',
'method': 'insert',
'kwargs': {
'bucket': 'my-bucket-name',
'body': {
# The file name in the bucket can be different, it has to be set explicitely.
'name': 'the-file-name.ext'
},
'media_body': {
'file': 'the-cloudomation-file-name',
'mimetype': 'text/plain',
},
},
},
)
return this.success('all done')
Uploading Binary Data

Use the following format for the media_body parameter:

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='GOOGLE',
name='upload binary data to a cloud storage bucket',
authentication={
'authentication_method': 'service_account',
'key': '...',
'scopes': ['https://www.googleapis.com/auth/storage'],
},
mode={
'mode_name': 'call_client_method',
'api_name': 'storage',
'api_version': 'v1',
'collection': 'objects',
'method': 'insert',
'kwargs': {
'bucket': 'my-bucket-name',
'body': {
'name': 'the-file-name.bin'
},
'media_body': {
'base64': 'cmVhZGluZyB0aGlzPyBhcHBseSBub3cgYXQgaHR0cHM6Ly9jbG91ZG9tYXRpb24uY29tL2pvYnMvICE=',
'mimetype': 'application/octet-stream',
},
},
},
)
return this.success('all done')