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.
Inputs
Name | Type | Default | Description |
---|---|---|---|
api_name | str | The name of the API to use | |
api_params | dict | None | Additional parameters to pass to the API build call |
api_version | str | The version of the API to use | |
args | list | None | Positional arguments to pass to the method call |
collection | str | The collection of the API to use. Can take the form of <resource>.<subresource>[...] | |
encoding | str | utf-8 | The encoding to use when binary data is returned by the server |
grant | str | None | the name of an oauth grant to use for authentication |
ignore_decoding_errors | bool | True | If set, decoding errors will be ignored. Binary data which cannot be decoded into strings will be returned as bytes:base64:[base64-string] . |
key | dict | None | The content of the key file of the service account to use |
kwargs | dict | None | Keyword arguments to pass to the method call |
params | dict | None | Deprecated. Replaced by kwargs . Additional parameters to pass to the request call |
request | str | The request to use | |
scopes | list | None | Oauth2 scopes to request |
Outputs
Name | Type | Default | Description |
---|---|---|---|
execution_id | int | The ID of the connection execution | |
message | str | The ended message for the connection. If the connection ended with an error, the message will contain information about what went wrong | |
result | dict | ||
status | str | The ended status for the connection. Either "success" or "error". |
Constants
input_list = ['api_name', 'api_params', 'api_version', 'args', 'collection', 'encoding', 'grant', 'ignore_decoding_errors', 'key', 'kwargs', 'params', 'request', 'scopes'] output_list = ['result'] ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca'] version = 1Methods
execute ()
log (message)
one_of_inputs (options)
run ()
Example
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
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):
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):
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):
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')