RPA.Cloud.Google

module RPA.Google

class RPA.Cloud.Google.Google

Google(service_account: Optional[str] = None, vault_name: Optional[str] = None, vault_secret_key: Optional[str] = None, cloud_auth_type: str = 'serviceaccount')

Google is a library for operating with Google API endpoints.

Installation

Usage requires the following steps:

  • Create a GCP project
  • Enable approriate APIs
  • Create credentials (OAuth or service account)
  • Install rpaframework-google package

Check the latest package version from PyPI.

Google authentication

Authentication for Google is set with service account JSON file which can be given to the library in three different ways or with OAuth2 token, which is used for OAuth authentication.

See library authentication examples for more information.

Basic usage examples

Python

from RPA.Cloud.Google import Google library = Google() service_account = '/path/to/service_account.json' library.init_vision(service_account) library.init_text_to_speech(service_account) response = library.detect_text('imagefile.png', 'result.json') library.synthesize_speech('I want this said aloud', target_file='said.mp3')

Robot Framework


variable ROBOT_LIBRARY_DOC_FORMAT

ROBOT_LIBRARY_DOC_FORMAT = 'REST'

variable ROBOT_LIBRARY_SCOPE

ROBOT_LIBRARY_SCOPE = 'GLOBAL'

method add_attachment_to_message

add_attachment_to_message(mimeMessage, attachment)

method add_drive_share

add_drive_share(file_id: Optional[str] = None, file_dict: Optional[dict] = None, query: Optional[str] = None, source: Optional[str] = None, email: Optional[str] = None, domain: Optional[str] = None, role: DriveRole = DriveRole.READER, share_type: DriveType = DriveType.USER, notification: bool = False, notification_message: Optional[str] = None)

Keyword for sharing drive file or folder.

Parameters file_id, file_dict, query and source can be used to select files to which sharing is added to.

If share is added to a folder, all files within that folder get same sharing permissions.

Parameters
  • file_id – drive file id
  • file_dict – file dictionary returned by Search Drive Files
  • query – drive query string to find target file, needs to match 1 file
  • source – name of the folder to search files in, is by default drive’s root folder
  • email – user or group email address if share type is DriveType.USER or DriveType.GROUP
  • domain – domain name if share type is DriveType.DOMAIN
  • role – see DriveRole enum for possible values, defaults to DriveRole.READER
  • share_type – see DriveType enum for possible values, defaults to DriveType.USER
  • notification – whether to send notificatin email, defaults to False
  • notification_message – optional message to include with the notification
  • Returns: share response dictionary containing β€˜file_id’ and β€˜permission_id’


method analyze_sentiment

analyze_sentiment(text: Optional[str] = None, text_file: Optional[str] = None, file_type: TextType = TextType.TEXT, json_file: Optional[str] = None, lang: Optional[str] = None)

Analyze sentiment in a text file

Parameters
  • text – source text
  • text_file – source text file
  • file_type – type of text, PLAIN_TEXT (default) or HTML
  • json_file – json target to save result, defaults to None
  • lang – language code of the source, defaults to None
  • Returns: analysis response

For list of supported languages: https://cloud.google.com/natural-language/docs/languages

Examples

Robot Framework


method annotate_image

annotate_image(image_file: str, image_uri: str, json_file: Optional[str] = None)

Annotate image

Parameters
  • image_file – source image file path
  • image_uri – Google Cloud Storage URI
  • json_file – json target to save result
  • Returns: detection response

Examples

Robot Framework


method annotate_video

annotate_video(video_file: Optional[str] = None, video_uri: Optional[str] = None, features: Optional[str] = None, output_uri: Optional[str] = None, json_file: Optional[str] = None, timeout: int = 300)

Annotate video

Possible values for features:

  • FEATURE_UNSPECIFIED, Unspecified.
  • LABEL_DETECTION, Label detection. Detect objects, such as dog or flower.
  • SHOT_CHANGE_DETECTION, Shot change detection.
  • EXPLICIT_CONTENT_DETECTION, Explicit content detection.
  • SPEECH_TRANSCRIPTION, Speech transcription.
  • TEXT_DETECTION, OCR text detection and tracking.
  • OBJECT_TRACKING, Object detection and tracking.
  • LOGO_RECOGNITION, Logo detection, tracking, and recognition.

If video_uri is given then that is used even if video_file is given.

Parameters
  • video_file – local file path to input video
  • video_uri – Google Cloud Storage URI to input video
  • features – list of annotation features to detect, defaults to LABEL_DETECTION,SHOT_CHANGE_DETECTION
  • output_uri – Google Cloud Storage URI to store response json
  • json_file – json target to save result
  • timeout – timeout for operation in seconds
  • Returns: annotate result

Examples

Robot Framework


method classify_text

classify_text(text: Optional[str] = None, text_file: Optional[str] = None, file_type: TextType = TextType.TEXT, json_file: Optional[str] = None, lang: Optional[str] = None)

Classify text

Parameters
  • text – source text
  • text_file – source text file
  • file_type – type of text, PLAIN_TEXT (default) or HTML
  • json_file – json target to save result, defaults to None
  • lang – language code of the source, defaults to None
  • Returns: classify response

For list of supported languages: https://cloud.google.com/natural-language/docs/languages

Examples

Robot Framework


method clear_sheet_values

clear_sheet_values(spreadsheet_id: str, sheet_range: str)

Clear cell values for range of cells within a spreadsheet

Parameters
  • spreadsheet_id – target spreadsheet
  • sheet_range – target sheet range
  • Returns: operation result

Examples

Python

result = GOOGLE.clear_sheet_values(spreadsheet_id, "A1:C1")

Robot Framework


method copy_sheet

copy_sheet(spreadsheet_id: str, source_sheet_name: str, new_sheet_name: str, insertSheetIndex: Optional[int] = None)

Copy sheet into the spreadsheet as new sheet

Parameters
  • spreadsheet_id – id of the spreadsheet
  • source_sheet_name – name of the source sheet
  • new_sheet_name – name for the new sheet
  • insertSheetIndex – zero based index where the new sheet should be inserted, defaults to None
  • Returns: operation result as an dictionary

Examples

Python

result = GOOGLE.copy_sheet( spreadsheet_id, "Existing sheet", "Copy of existing sheet" )

Robot Framework


method copy_spreadsheet

copy_spreadsheet(spreadsheet_id: str, target_spreadsheet_id: str)

Copy spreadsheet to target spreadsheet

NOTE: service account user must have access also to target spreadsheet

Parameters
  • spreadsheet_id – ID of the spreadsheet to copy
  • target_spreadsheet_id – ID of the target spreadsheet
  • Returns: operation result

Examples

Python

result = GOOGLE.copy_spreadsheet( spreadsheet_id, source_spreadsheet_id, target_spreadsheet_id)

Robot Framework


method create_drive_directory

create_drive_directory(folder: Optional[str] = None, parent_folder: Optional[str] = None)

Create new directory to Google Drive

Parameters
  • folder – name for the new directory
  • parent_folder – top level directory for new directory
  • Returns: dictionary containing folder ID and folder URL


method create_message

create_message(to: str, subject: str, message_text: str, attachments: Optional[list] = None, html: bool = False)

Create a message for an email.

Parameters
  • to – message recipient
  • subject – message subject
  • message_text – message body text
  • attachment – list of files to add as message attachments
  • html – set to True if message body is HTML (default False, plain text)
  • Returns: An object containing a base64url encoded email object

method create_sheet

create_sheet(spreadsheet_id: str, sheet_name: str)

Create sheet into the spreadsheet

Parameters
  • spreadsheet_id – id of the spreadsheet
  • sheet_name – name for the new sheet
  • Returns: operation result as an dictionary

Examples

Python

result = GOOGLE.create_sheet(spreadsheet_id, "New sheet")

Robot Framework


method create_spreadsheet

create_spreadsheet(title: str)

Create empty sheet with a title

  • Parameters: title – name as string
  • Returns: created spreadsheet_id

Examples

Python

result = GOOGLE.create_spreadsheet("name of the spreadsheet")

Robot Framework


method create_storage_bucket

create_storage_bucket(bucket_name: str)

Create Google Cloud Storage bucket

  • Parameters: bucket_name – name as string
  • Returns: bucket

Examples

Robot Framework


method delete_drive_file

delete_drive_file(file_id: Optional[str] = None, file_dict: Optional[dict] = None, query: Optional[str] = None, multiple_ok: bool = False, suppress_errors: bool = False)

Delete file specified by id, file dictionary or query string

Note. Be extra careful when calling this keyword!

Parameters
  • file_id – drive file id
  • file_dict – file dictionary returned by Search Drive Files
  • query – drive query string to find target file, needs to match 1 file unless parameter multiple_ok is set to True
  • multiple_ok – set to True if it is ok to perform delete on more than 1 file
  • suppress_errors – on True will log warning message instead of raising an exception, defaults to False
  • Returns: how many files where deleted


method delete_sheet

delete_sheet(spreadsheet_id: str, sheet_name: str)

Delete a sheet from the spreadsheet.

Parameters
  • spreadsheet_id – id of the spreadsheet
  • sheet_name – name of the sheet to delete
  • Returns: operation result as an dictionary

Examples

Python

result = GOOGLE.delete_sheet(spreadsheet_id, "Sheet1")

Robot Framework


method delete_storage_bucket

delete_storage_bucket(bucket_name: str)

Delete Google Cloud Storage bucket

Bucket needs to be empty before it can be deleted.

  • Parameters: bucket_name – name as string

Examples

Robot Framework


method delete_storage_files

delete_storage_files(bucket_name: str, files: Any)

Delete files in the bucket

Files need to be object name in the bucket.

Parameters
  • bucket_name – name as string
  • files – single file, list of files or comma separated list of files
  • Returns: list of files which could not be deleted

    Examples

Robot Framework


method detect_document

detect_document(image_file: Optional[str] = None, image_uri: Optional[str] = None, json_file: Optional[str] = None)

Detect document

Parameters
  • image_file – source image file path
  • image_uri – Google Cloud Storage URI
  • json_file – json target to save result
  • Returns: detection response

Examples

Robot Framework


method detect_labels

detect_labels(image_file: Optional[str] = None, image_uri: Optional[str] = None, json_file: Optional[str] = None)

Detect labels in the image

Parameters
  • image_file – source image file path
  • image_uri – source image uri
  • json_file – json target to save result
  • Returns: detection response

Examples

Robot Framework


method detect_tables

detect_tables(spreadsheet_id: str, sheet_name: Optional[str] = None)

Detect tables in the sheet.

Parameters
  • spreadsheet_id – id of the spreadsheet
  • sheet_name – name of the sheet, or leave None for all sheets
  • Returns: tables arranged by sheets

method detect_text

detect_text(image_file: Optional[str] = None, image_uri: Optional[str] = None, json_file: Optional[str] = None)

Detect text in the image

Parameters
  • image_file – source image file path
  • image_uri – Google Cloud Storage URI
  • json_file – json target to save result
  • Returns: detection response

Examples

Robot Framework


method download_drive_files

download_drive_files(file_dict: Optional[dict] = None, query: Optional[str] = None, source: Optional[str] = None, limit: Optional[int] = None, timeout: Optional[float] = None)

Download files specified by file dictionary or query string

Parameters start, limit and timeout are used only when downloading files defined by query parameter.

Parameters
  • file_dict – file dictionary returned by Search Drive Files
  • query – drive query string to find target files, defaults to None
  • source – source directory where query is executed
  • limit – maximum amount of files that are downloaded, defaults to None
  • timeout – maximum allowed time in seconds for download process
  • Returns: list of downloaded files


method download_storage_files

download_storage_files(bucket_name: str, files: Any)

Download files from a bucket

Example files: files = {β€œmytestimg”: β€œimage1.png”, β€œmydoc”: β€œgoogle.pdf”}

Parameters
  • bucket_name – name as string
  • files – list of object names or dictionary of object names and target files
  • Returns: list of files which could not be downloaded

Examples

Robot Framework


method export_drive_file

export_drive_file(file_id: Optional[str] = None, file_dict: Optional[dict] = None, target_file: Optional[str] = None, mimetype: str = 'application/pdf')

Export Google Drive file using Drive export links

Parameters
  • file_id – drive file id
  • file_dict – file dictionary returned by Search Drive Files
  • target_file – name for the exported file
  • mimetype – export mimetype, defaults to β€œapplication/pdf”
  • Returns: file path to the exported file


method face_detection

face_detection(image_file: Optional[str] = None, image_uri: Optional[str] = None, json_file: Optional[str] = None)

Detect faces

Parameters
  • image_file – source image file path
  • image_uri – Google Cloud Storage URI
  • json_file – json target to save result
  • Returns: detection response

Examples

Robot Framework


method generic_spreadsheet_batch_update

generic_spreadsheet_batch_update(spreadsheet_id: str, body: Dict)

This keyword allows to do generic batch update to the spreadsheet.

For more information on the batch update: https://googleapis.github.io/google-api-python-client/docs/dyn/sheets_v4.spreadsheets.html#create

List of possible requests actions (body can contain multiple at the same time):

  • addBanding
  • addChart
  • addConditionalFormatRule
  • addDataSource
  • addDimensionGroup
  • addFilterView
  • addNamedRange
  • addProtectedRange
  • addSheet (keyword Create sheet)
  • addSlicer
  • appendCells
  • appendDimension
  • autoFill
  • autoResizeDimensions
  • clearBasicFilter
  • copyPaste
  • createDeveloperMetadata
  • cutPaste
  • deleteBanding
  • deleteConditionalFormatRule
  • deleteDataSource
  • deleteDeveloperMetadata
  • deleteDimension
  • deleteDimensionGroup
  • deleteDuplicates
  • deleteEmbeddedObject
  • deleteFilterView
  • deleteNamedRange
  • deleteProtectedRange
  • deleteRange
  • deleteSheet (keyword Delete sheet)
  • duplicateFilterView
  • duplicateSheet (keyword Copy sheet)
  • findReplace
  • insertDimension
  • insertRange
  • mergeCells
  • moveDimension
  • pasteData
  • randomizeRange
  • refreshDataSource
  • repeatCell
  • setBasicFilter
  • setDataValidation
  • sortRange
  • textToColumns
  • trimWhitespace
  • unmergeCells
  • updateBanding
  • updateBorders
  • updateCells
  • updateChartSpec
  • updateConditionalFormatRule
  • updateDataSource
  • updateDeveloperMetadata
  • updateDimensionGroup
  • updateDimensionProperties
  • updateEmbeddedObjectBorder
  • updateEmbeddedObjectPosition
  • updateFilterView
  • updateNamedRange
  • updateProtectedRange
  • updateSheetProperties (keyword Rename sheet)
  • updateSlicerSpec
  • updateSpreadsheetProperties
Parameters
  • spreadsheet_id – id of the spreadsheet
  • body – body of the batch update request
  • Returns: operation result as an dictionary

Examples

Python

body = {"requests": {"deleteSheet": {"sheetId": "333555666"}}} result = GOOGLE.generic_spreadsheet_batch_update(spreadsheet_id, body)

Robot Framework


method get_all_sheet_values

get_all_sheet_values(spreadsheet_id: str, sheet_name: Optional[str] = None, value_render_option: str = 'UNFORMATTED_VALUE', datetime_render_option: str = 'FORMATTED_STRING')

Get values from the range in the spreadsheet

Parameters
  • spreadsheet_id – target spreadsheet
  • sheet_name – target sheet (default first sheet)
  • value_render_option – how values should be represented in the output defaults to β€œUNFORMATTED_VALUE”
  • datetime_render_option – how dates, times, and durations should be represented in the output, defaults to β€œFORMATTED_STRING”
  • Returns: operation result

Examples

Python

result = GOOGLE.get_all_sheet_values(spreadsheet_id)

Robot Framework


method get_document_entities

get_document_entities(document: Document)

Helper keyword for getting document entities from a Process Document response object.

For examples. see Process Document keyword

  • Parameters: document – the document response object
  • Returns: detected entities in the document response as a list

method get_document_languages

get_document_languages(document: Document)

Helper keyword for getting detected languages from a Process Document response object.

For examples. see Process Document keyword

  • Parameters: document – the document response object
  • Returns: detected languages in the document response as a list

method get_drive_file_by_id

get_drive_file_by_id(file_id: str, suppress_errors: bool = False)

Get file dictionary by its file id.

Parameters
  • file_id – id of the file in the Google Drive
  • suppress_errors – on True will log warning message instead of raising an exception, defaults to False (exception is raised)
  • Returns: dictionary containing file information


method get_drive_folder_id

get_drive_folder_id(folder: Optional[str] = None, parent_folder: Optional[str] = None, details: bool = False)

Get file id for the folder

Parameters
  • folder – name of the folder to identify, by default returns drive’s root folder id
  • parent_folder – can be used to narrow search by giving parent folder name
  • details – on True will return folder dictionary, on False (default) folder id is returned
  • Returns: file id of the folder or file dictionary when details = True


method get_sheet_by_name

get_sheet_by_name(spreadsheet_id: str, sheet_name: str)

method get_sheet_formulas

get_sheet_formulas(spreadsheet_id: str, sheet_name: str)

Get formulas from the sheet.

Parameters
  • spreadsheet_id – id of the spreadsheet
  • sheet_name – name of the sheet
  • Returns: _description_

method get_sheet_values

get_sheet_values(spreadsheet_id: str, sheet_range: Optional[str] = None, value_render_option: str = 'UNFORMATTED_VALUE', datetime_render_option: str = 'FORMATTED_STRING')

Get values from the range in the spreadhsheet

Parameters
  • spreadsheet_id – target spreadsheet
  • sheet_range – target sheet range
  • value_render_option – how values should be represented in the output defaults to β€œUNFORMATTED_VALUE”
  • datetime_render_option – how dates, times, and durations should be represented in the output, defaults to β€œFORMATTED_STRING”
  • Returns: operation result

Examples

Python

result = GOOGLE.get_sheet_values(spreadsheet_id, "A1:C1")

Robot Framework


method get_spreadsheet_basic_information

get_spreadsheet_basic_information(spreadsheet_id: str)

Get title, id, url and sheets information from the spreadsheet.

  • Parameters: spreadsheet_id – ID of the spreadsheet
  • Returns: operation result as an dictionary

method get_spreadsheet_details

get_spreadsheet_details(spreadsheet_id: str)

Returns spreadsheet information as a dictionary.

  • Parameters: spreadsheet_id – ID of the spreadsheet
  • Returns: operation result as an dictionary

method get_storage_bucket

get_storage_bucket(bucket_name: str)

Get Google Cloud Storage bucket

  • Parameters: bucket_name – name as string
  • Returns: bucket

Examples

Robot Framework


method handle_mimetypes

handle_mimetypes(parsed_parts, part, msg, folder_name)

method init_apps_script

init_apps_script(service_account: Optional[str] = None, credentials: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, scopes: Optional[list] = None, token_file: Optional[str] = None)

Initialize Google Apps Script client

Parameters
  • service_account – file path to service account file
  • credentials – file path to credentials file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • scopes – list of extra authentication scopes
  • token_file – file path to token file

method init_document_ai

init_document_ai(service_account: Optional[str] = None, region: Optional[str] = 'us', use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Document AI client

Parameters
  • service_account – file path to service account file
  • region – region of the service
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

Robot Framework example:

Python example:

GOOGLE = Google() GOOGLE.set_robocorp_vault("DocumentAI", "google-sa") GOOGLE.init_document_ai(region="eu", use_robocorp_vault=True)

method init_drive

init_drive(service_account: Optional[str] = None, credentials: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, scopes: Optional[list] = None, token_file: Optional[str] = None)

Initialize Google Drive client

Parameters
  • service_account – file path to service account file
  • credentials – file path to credentials file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • scopes – list of extra authentication scopes
  • token_file – file path to token file

method init_gmail

init_gmail(service_account: Optional[str] = None, credentials: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, scopes: Optional[list] = None, token_file: Optional[str] = None)

Initialize Google Gmail client

Parameters
  • service_account – file path to service account file
  • credentials – file path to credentials file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • scopes – list of extra authentication scopes
  • token_file – file path to token file

method init_natural_language

init_natural_language(service_account: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Natural Language client

Parameters
  • service_account – file path to service account file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

method init_sheets

init_sheets(service_account: Optional[str] = None, credentials: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, scopes: Optional[list] = None, token_file: Optional[str] = None)

Initialize Google Sheets client

Parameters
  • service_account – file path to service account file
  • credentials – file path to credentials file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • scopes – list of extra authentication scopes
  • token_file – file path to token file

method init_speech_to_text

init_speech_to_text(service_account: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Speech to Text client

Parameters
  • service_account – file path to service account file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

method init_storage

init_storage(service_account: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Storage client

Parameters
  • service_account – file path to service account file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

method init_text_to_speech

init_text_to_speech(service_account: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Text to Speech client

Parameters
  • service_account – file path to service account file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

method init_translation

init_translation(project_identifier: str, service_account: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Translation client

Parameters
  • project_identifier – identifier for Translation project
  • service_account – file path to service account file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

method init_video_intelligence

init_video_intelligence(service_account: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Video Intelligence client

Parameters
  • service_account – file path to service account file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

method init_vision

init_vision(service_account: Optional[str] = None, use_robocorp_vault: Optional[bool] = None, token_file: Optional[str] = None)

Initialize Google Cloud Vision client

Parameters
  • service_account – file path to service account file
  • use_robocorp_vault – use credentials in Robocorp Vault
  • token_file – file path to token file

method insert_sheet_values

insert_sheet_values(spreadsheet_id: str, sheet_range: str, values: list, major_dimension: str = 'COLUMNS', value_input_option: str = 'USER_ENTERED')

Insert values into sheet cells

Parameters
  • spreadsheet_id – target spreadsheet
  • sheet_range – target sheet range
  • values – list of values to insert into sheet
  • major_dimension – major dimension of the values, default COLUMNS
  • value_input_option – controls whether input strings are parsed or not, default USER_ENTERED
  • Returns: operation result

Examples

Python

values = [[11, 12, 13], ['aa', 'bb', 'cc']] result = GOOGLE.insert_sheet_values(spreadsheet_id, "A:C", values)

Robot Framework


method list_messages

list_messages(user_id: str, query: str, folder_name: Optional[str] = None, label_ids: Optional[list] = None, max_results: Optional[int] = None, include_json: bool = False, include_spam: bool = False)

List messages

Parameters
  • user_id – user’s email address. The special value me can be used to indicate the authenticated user.
  • query – message query
  • folder_name – path where attachments are saved, default current directory
  • label_ids – message label ids
  • max_results – maximum number of message to return
  • include_json – include original response json
  • include_spam – include messages from SPAM and TRASH
  • Returns: messages


method list_processors

list_processors(project_id: str, region: str)

List existing document AI processors from given project and region.

Requires documentai.processors.list permission.

Parameters
  • project_id – Google Cloud project ID
  • region – Google Cloud region of the processor
  • Returns: list of available processors as a list

Robot Framework example:

Python example:

processors = GOOGLE.list_processors(PROJECT_ID, "eu") for p in processors: print(f"Processor name: {p.name}") print(f"Processor type: {p.type_}") print(f"Processor name: {p.display_name}")

method list_shared_drive_files

list_shared_drive_files(query: Optional[str] = None, source: Optional[str] = None)

Keyword for listing shared files in the source folder.

Alias keyword for Search Drive Files which can be used to list only files which have been shared.

Parameters
  • query – drive query string to find target files
  • source – source directory where query is executed
  • Returns: list of shared files


method list_storage_buckets

list_storage_buckets()

List Google Cloud Storage buckets

  • Returns: list of buckets

Examples

Robot Framework


method list_storage_files

list_storage_files(bucket_name: str)

List files in the bucket

  • Parameters: bucket_name – name as string
  • Returns: list of object names in the bucket

Examples

Robot Framework


method list_supported_voices

list_supported_voices(language_code: Optional[str] = None)

List supported voices for the speech

  • Parameters: language_code – voice languages to list, defaults to None (all)
  • Returns: list of supported voices

Examples

Robot Framework


method load_document_response

load_document_response(filepath: str)

Loads the binary object saved by Save Document Response into documentai.Document format which is accessible by helper keywords.

  • Parameters: filepath – source file to read binary document object from
  • Returns: processed document response object

Robot Framework example:

Python example:

document = GOOGLE.load_document_response("google_doc.response") entities = GOOGLE.get_document_entities(document) for ent in entities: print(ent)

method move_drive_file

move_drive_file(file_id: Optional[str] = None, file_dict: Optional[dict] = None, query: Optional[str] = None, source: Optional[str] = None, target: Optional[str] = None, multiple_ok: bool = False)

Move file specified by id, file dictionary or query string into target folder

Parameters
  • file_id – drive file id
  • file_dict – file dictionary returned by Search Drive Files
  • query – drive query string to find target file, needs to match 1 file
  • source – name of the folder to move file from, is by default drive’s root folder id
  • target – name of the folder to move file into, is by default drive’s root folder id
  • multiple_ok – if True then moving more than 1 file
  • Returns: list of file ids


method parse_parts

parse_parts(msg_id, msg, parts, folder_name)

Utility function that parses the content of an email partition


method process_document

process_document(project_id: str, region: str, processor_id: str, file_path: str, mime_type: Optional[str] = None)

Process document in the Google Cloud platform using given document processor ID within given project and region.

For a full list of Document response object attributes, please reference this page.

Parameters
  • project_id – Google Cloud project ID
  • region – Google Cloud region of the processor
  • processor_id – ID of the document processor
  • file_path – filepath of the document to process
  • mime_type – given mime type of document (optional), if not given it is auto detected
  • Returns: processed document response object

Robot Framework example:

Python example:

document = GOOGLE.process_document( project_id=PROJECT_ID, region="eu", processor_id=PROCESSOR_ID, file_path="./files/mydocument.pdf", ) entities = GOOGLE.get_document_entities(document) for ent in entities: print(ent) languages = GOOGLE.get_document_languages(document) for lang in languages: print(lang)

method recognize_text_from_audio

recognize_text_from_audio(audio_file: Optional[str] = None, audio_uri: Optional[str] = None, encoding: Optional[str] = None, language_code: str = 'en_US', audio_channel_count: int = 2, sample_rate: Optional[int] = None)

Recognize text in the audio file

Parameters
  • audio_file – local audio file path
  • audio_uri – Google Cloud Storage URI
  • encoding – audio file encoding
  • language_code – language in the audio
  • audio_channel_count – number of audio channel
  • sample_rate – rate in hertz, for example 16000
  • Returns: recognized texts

Examples

Robot Framework


method remove_all_drive_shares

remove_all_drive_shares(file_id: Optional[str] = None, file_dict: Optional[dict] = None, query: Optional[str] = None, suppress_errors: bool = False)

Keyword for removing all shares from selected files (only owner permission is retained).

Parameters
  • file_id – drive file id
  • file_dict – file dictionary returned by Search Drive Files
  • query – drive query string to find target files
  • suppress_errors – on True will log warning message instead of raising an exception, defaults to False (exception is raised)
  • Returns: list of dictionaries containing information of file permissions removed


method remove_drive_share_by_criteria

remove_drive_share_by_criteria(email: Optional[str] = None, domain: Optional[str] = None, permission_id: Optional[str] = None, file_id: Optional[str] = None, file_dict: Optional[dict] = None, query: Optional[str] = None, source: Optional[str] = None, suppress_errors: bool = False)

Keyword for removing share from file or folder based on criteria.

Parameters file_id, file_dict, query and source can be used to select files from which sharing is removed.

Parameters email, domain or permission_id can be used to select which share is removed from selected files.

Parameters
  • email – email address of the permission to remove
  • domain – domain name of the permission to remove
  • permission_id – id of the permission to remove
  • file_id – drive file id
  • file_dict – file dictionary returned by Search Drive Files
  • query – drive query string to find target files
  • source – name of the folder to search files in, is by default drive’s root folder
  • suppress_errors – on True will log warning message instead of raising an exception, defaults to False (exception is raised)
  • Returns: list of dictionaries containing information of file permissions removed


method remove_drive_share_by_permission_id

remove_drive_share_by_permission_id(permission_id: str, file_id: Optional[str] = None, file_dict: Optional[dict] = None, query: Optional[str] = None, source: Optional[str] = None, suppress_errors: bool = False)

Keyword for removing share permission of file or folder permission id.

Parameters file_id, file_dict, query and source can be used to select files from which sharing is removed.

Parameters
  • permission_id – id of the permission to remove
  • file_id – drive file id
  • file_dict – file dictionary returned by Search Drive Files
  • query – drive query string to find target file, needs to match 1 file
  • source – name of the folder to search files in, is by default drive’s root folder
  • suppress_errors – on True will log warning message instead of raising an exception, defaults to False (exception is raised)
  • Returns: dictionary of permission response


method rename_sheet

rename_sheet(spreadsheet_id: str, sheet_name: str, new_sheet_name: str)

Rename sheet in the spreadsheet

Parameters
  • spreadsheet_id – id of the spreadsheet
  • sheet_name – existing name of the sheet
  • new_sheet_name – name for the new sheet
  • Returns: operation result as an dictionary

Examples

Python

result = GOOGLE.rename_sheet(spreadsheet_id, "Sheet1", "New name")

Robot Framework


method run_script

run_script(script_id: str, function_name: str, parameters: Optional[dict] = None)

Run the Google Apps Script function

Parameters
  • script_id – Google Script identifier
  • function_name – name of the script function
  • parameters – script function parameters as a dictionary
  • Raises: AssertionError – thrown when Google Script returns errors


method save_document_response

save_document_response(document: Document, filepath: str)

Save Process Document response into a binary file.

Parameters
  • document – response document object
  • filepath – target file to save binary object into

Robot Framework example:

Python example:

document = GOOGLE.process_document( project_id=PROJECT_ID, region="eu", processor_id=PROCESSOR_ID, file_path="./files/receipt1.jpg", ) GOOGLE.save_document_response(document, "receipt.response")

method search_drive_files

search_drive_files(query: Optional[str] = None, recurse: bool = False, source: Optional[str] = None)

Search Google Drive for files matching query string

Parameters
  • query – search string, defaults to None which means that all files and folders are returned
  • recurse – set to True if search should recursive
  • source – source directory where query is executed
  • Returns: list of files


method send_message

send_message(sender: str, to: str, subject: str, message_text: str, attachments: Optional[list] = None, html: bool = False)

Send an email message.

Parameters
  • sender – message sender
  • to – message recipient
  • subject – message subject
  • message_text – message body text
  • attachment – list of files to add as message attachments
  • html – set to True if message body is HTML (default False, plain text)
  • Returns: sent message


method set_audio_type

set_audio_type(audio_file, audio_uri)

method set_headers_to_message_dict

set_headers_to_message_dict(payload, message_id, response)

method set_image_type

set_image_type(image_file: Optional[str] = None, image_uri: Optional[str] = None)

method set_list_parameters

set_list_parameters(user_id, query, label_ids, max_results, include_spam)

method set_robocorp_vault

set_robocorp_vault(vault_name: Optional[str] = None, vault_secret_key: Optional[str] = None, auth_type: str = 'serviceaccount')

Set Robocorp Vault name and secret key name :param vault_name: Robocorp Vault name :param vault_secret_key: Robocorp Vault secret key name :param auth_type: either serviceaccount or token


method synthesize_speech

synthesize_speech(text: str, language: str = 'en-US', name: str = 'en-US-Standard-B', gender: str = 'MALE', encoding: str = 'MP3', target_file: str = 'synthesized.mp3')

Synthesize speech synchronously

Parameters
  • text – input text to synthesize
  • language – voice language, defaults to β€œen-US”
  • name – voice name, defaults to β€œen-US-Standard-B”
  • gender – voice gender, defaults to β€œMALE”
  • encoding – result encoding type, defaults to β€œMP3”
  • target_file – save synthesized output to file, defaults to β€œsynthesized.mp3”
  • Returns: synthesized output in bytes

Examples

Robot Framework


method to_A1_notation

to_A1_notation(column_number: int, row_number: int)

Convert a column number and a row number into a cell reference.

Parameters
  • column_number – column number to convert
  • row_number – row number to convert
  • Returns: cell reference string

method to_column_letter

to_column_letter(number: int)

Convert a column number into a column letter(s).

  • Parameters: number – column number to convert
  • Returns: column letter(s)

method translate

translate(text: Union[list, str], source_language: Optional[str] = None, target_language: Optional[str] = None, mime_type: Optional[TextType] = None)

Translate text

Parameters
  • text – text to translate
  • source_language – language code
  • target_language – language code
  • mime_type – text or html
  • Returns: translated text

Examples

Robot Framework


method update_drive_file

update_drive_file(file_id: Optional[str] = None, file_dict: Optional[dict] = None, query: Optional[str] = None, source: Optional[str] = None, action: UpdateAction = UpdateAction.star, multiple_ok: bool = False)

Update file specified by id, file dictionary or query string

Possible actions:

  • star
  • unstar
  • trash
  • untrash
Parameters
  • file_id – drive file id
  • file_dict – file dictionary returned by Drive Search Files
  • query – drive query string to find target file, needs to match 1 file
  • source – source directory where query is executed
  • action – update action, default star file
  • multiple_ok – set to True if it is ok to perform update on more than 1 file
  • Returns: number of updated files


method update_sheet_values

update_sheet_values(spreadsheet_id: str, sheet_range: str, values: list, major_dimension: str = 'COLUMNS', value_input_option: str = 'USER_ENTERED')

Insert values into sheet cells

Parameters
  • spreadsheet_id – target spreadsheet
  • sheet_range – target sheet range
  • values – list of values to insert into sheet
  • major_dimension – major dimension of the values, default COLUMNS
  • value_input_option – controls whether input strings are parsed or not, default USER_ENTERED
  • Returns: operation result

Examples

Python

row_data = [[11, 12, 13], ['aa', 'bb', 'cc']] result = GOOGLE.update_sheet_values( spreadsheet_id, "A1:C1", row_data, "ROWS )

Robot Framework


method upload_drive_file

upload_drive_file(filename: Optional[str] = None, folder: Optional[str] = None, overwrite: bool = False, make_dir: bool = False)

Upload files into Drive

Parameters
  • filename – name of the file to upload
  • folder – target folder for upload
  • overwrite – set to True if already existing file should be overwritten
  • make_dir – set to True if folder should be created if it does not exist
  • Returns: uploaded file id


method upload_storage_file

upload_storage_file(bucket_name: str, filename: str, target_name: str)

Upload a file into a bucket

Parameters
  • bucket_name – name as string
  • filename – filepath to upload file
  • target_name – target object name

Examples

Robot Framework


method upload_storage_files

upload_storage_files(bucket_name: str, files: dict)

Upload files into a bucket

Example files: files = {β€œmytestimg”: β€œimage1.png”, β€œmydoc”: β€œgoogle.pdf”}

Parameters
  • bucket_name – name as string
  • files – dictionary of object names and filepaths

Examples

Robot Framework