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
-
api_name
The name of the API to use.
Type:
string
-
api_version
The version of the API to use.
Type:
string
-
api_params
Additional parameters to pass to the API build call.
Type:
object
Additional Properties:
True
Pattern Properties:
-
.*
Data
-
-
collection
The collection of the API to use. Can take the form of
<resource>.<subresource>[...]
.Type:
string
-
request
The request to send.
Type:
string
-
args
Positional arguments to pass to the method call.
Type:
array
Items: -
kwargs
Keyword arguments to pass to the method call.
Type:
object
Additional Properties:
True
Pattern Properties:
-
.*
Data
-
-
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
-
key
Type:
anyOf
Options: -
scopes
Oauth2 scopes to request.
Type:
array
Items: -
params
DEPRECATED. Replaced by
Keyword arguments
(kwargs).
Output Schema
-
result
Data
Constants
ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca']Example
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='GOOGLE',
name='launch instance',
api_name='compute',
api_version='v1',
collection='instances',
request='insert',
kwargs={
'body': instance_config,
'project': project_id,
'zone': 'europe-west3-b',
}
key=key,
scopes=['https://www.googleapis.com/auth/compute'],
)
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 supports uploading strings, Cloudomation 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',
api_name='storage',
api_version='v1',
collection='objects',
request='insert',
params={
'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 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 file to a cloud storage bucket',
api_name='storage',
api_version='v1',
collection='objects',
request='insert',
params={
'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',
api_name='storage',
api_version='v1',
collection='objects',
request='insert',
params={
'bucket': 'my-bucket-name',
'body': {
'name': 'the-file-name.bin'
},
'media_body': {
'base64': 'cmVhZGluZyB0aGlzPyBhcHBseSBub3cgYXQgaHR0cHM6Ly9jbG91ZG9tYXRpb24uY29tL2pvYnMvICE=',
'mimetype': 'application/octet-stream',
},
},
)
return this.success('all done')