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_nameThe name of the API to use.
Type:
string -
api_versionThe version of the API to use.
Type:
string -
api_paramsAdditional parameters to pass to the API build call.
Type:
objectAdditional Properties:
TruePattern Properties:
-
.*Data
-
-
collectionThe collection of the API to use. Can take the form of
<resource>.<subresource>[...].Type:
string -
requestThe request to send.
Type:
string -
argsPositional arguments to pass to the method call.
Type:
arrayItems: -
kwargsKeyword arguments to pass to the method call.
Type:
objectAdditional Properties:
TruePattern Properties:
-
.*Data
-
-
encodingThe encoding to use when binary data is returned by the server.
Type:
stringDefault:
utf-8 -
ignore_decoding_errorsIf set, decoding errors will be ignored.
Binary data which cannot be decoded into strings will be returned as
bytes:base64:<base64-string>.Type:
booleanDefault:
True -
keyType:
anyOfOptions: -
scopesOauth2 scopes to request.
Type:
arrayItems: -
paramsDEPRECATED. Replaced by
Keyword arguments(kwargs).
Output Schema
-
resultData
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 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',
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 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',
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')