| :py:mod:`airflow.providers.google.suite.hooks.sheets` |
| ===================================================== |
| |
| .. py:module:: airflow.providers.google.suite.hooks.sheets |
| |
| .. autoapi-nested-parse:: |
| |
| This module contains a Google Sheets API hook |
| |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.providers.google.suite.hooks.sheets.GSheetsHook |
| |
| |
| |
| |
| .. py:class:: GSheetsHook(gcp_conn_id = 'google_cloud_default', api_version = 'v4', delegate_to = None, impersonation_chain = None) |
| |
| Bases: :py:obj:`airflow.providers.google.common.hooks.base_google.GoogleBaseHook` |
| |
| Interact with Google Sheets via Google Cloud connection |
| Reading and writing cells in Google Sheet: |
| https://developers.google.com/sheets/api/guides/values |
| |
| :param gcp_conn_id: The connection ID to use when fetching connection info. |
| :param api_version: API Version |
| :param delegate_to: The account to impersonate using domain-wide delegation of authority, |
| if any. For this to work, the service account making the request must have |
| domain-wide delegation enabled. |
| :param impersonation_chain: Optional service account to impersonate using short-term |
| credentials, or chained list of accounts required to get the access_token |
| of the last account in the list, which will be impersonated in the request. |
| If set as a string, the account must grant the originating account |
| the Service Account Token Creator IAM role. |
| If set as a sequence, the identities from the list must grant |
| Service Account Token Creator IAM role to the directly preceding identity, with first |
| account from the list granting this role to the originating account. |
| |
| .. py:method:: get_conn(self) |
| |
| Retrieves connection to Google Sheets. |
| |
| :return: Google Sheets services object. |
| :rtype: Any |
| |
| |
| .. py:method:: get_values(self, spreadsheet_id, range_, major_dimension = 'DIMENSION_UNSPECIFIED', value_render_option = 'FORMATTED_VALUE', date_time_render_option = 'SERIAL_NUMBER') |
| |
| Gets values from Google Sheet from a single range |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get |
| |
| :param spreadsheet_id: The Google Sheet ID to interact with |
| :param range_: The A1 notation of the values to retrieve. |
| :param major_dimension: Indicates which dimension an operation should apply to. |
| DIMENSION_UNSPECIFIED, ROWS, or COLUMNS |
| :param value_render_option: Determines how values should be rendered in the output. |
| FORMATTED_VALUE, UNFORMATTED_VALUE, or FORMULA |
| :param date_time_render_option: Determines how dates should be rendered in the output. |
| SERIAL_NUMBER or FORMATTED_STRING |
| :return: An array of sheet values from the specified sheet. |
| :rtype: List |
| |
| |
| .. py:method:: batch_get_values(self, spreadsheet_id, ranges, major_dimension = 'DIMENSION_UNSPECIFIED', value_render_option = 'FORMATTED_VALUE', date_time_render_option = 'SERIAL_NUMBER') |
| |
| Gets values from Google Sheet from a list of ranges |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchGet |
| |
| :param spreadsheet_id: The Google Sheet ID to interact with |
| :param ranges: The A1 notation of the values to retrieve. |
| :param major_dimension: Indicates which dimension an operation should apply to. |
| DIMENSION_UNSPECIFIED, ROWS, or COLUMNS |
| :param value_render_option: Determines how values should be rendered in the output. |
| FORMATTED_VALUE, UNFORMATTED_VALUE, or FORMULA |
| :param date_time_render_option: Determines how dates should be rendered in the output. |
| SERIAL_NUMBER or FORMATTED_STRING |
| :return: Google Sheets API response. |
| :rtype: Dict |
| |
| |
| .. py:method:: update_values(self, spreadsheet_id, range_, values, major_dimension = 'ROWS', value_input_option = 'RAW', include_values_in_response = False, value_render_option = 'FORMATTED_VALUE', date_time_render_option = 'SERIAL_NUMBER') |
| |
| Updates values from Google Sheet from a single range |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update |
| |
| :param spreadsheet_id: The Google Sheet ID to interact with. |
| :param range_: The A1 notation of the values to retrieve. |
| :param values: Data within a range of the spreadsheet. |
| :param major_dimension: Indicates which dimension an operation should apply to. |
| DIMENSION_UNSPECIFIED, ROWS, or COLUMNS |
| :param value_input_option: Determines how input data should be interpreted. |
| RAW or USER_ENTERED |
| :param include_values_in_response: Determines if the update response should |
| include the values of the cells that were updated. |
| :param value_render_option: Determines how values should be rendered in the output. |
| FORMATTED_VALUE, UNFORMATTED_VALUE, or FORMULA |
| :param date_time_render_option: Determines how dates should be rendered in the output. |
| SERIAL_NUMBER or FORMATTED_STRING |
| :return: Google Sheets API response. |
| :rtype: Dict |
| |
| |
| .. py:method:: batch_update_values(self, spreadsheet_id, ranges, values, major_dimension = 'ROWS', value_input_option = 'RAW', include_values_in_response = False, value_render_option = 'FORMATTED_VALUE', date_time_render_option = 'SERIAL_NUMBER') |
| |
| Updates values from Google Sheet for multiple ranges |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate |
| |
| :param spreadsheet_id: The Google Sheet ID to interact with |
| :param ranges: The A1 notation of the values to retrieve. |
| :param values: Data within a range of the spreadsheet. |
| :param major_dimension: Indicates which dimension an operation should apply to. |
| DIMENSION_UNSPECIFIED, ROWS, or COLUMNS |
| :param value_input_option: Determines how input data should be interpreted. |
| RAW or USER_ENTERED |
| :param include_values_in_response: Determines if the update response should |
| include the values of the cells that were updated. |
| :param value_render_option: Determines how values should be rendered in the output. |
| FORMATTED_VALUE, UNFORMATTED_VALUE, or FORMULA |
| :param date_time_render_option: Determines how dates should be rendered in the output. |
| SERIAL_NUMBER or FORMATTED_STRING |
| :return: Google Sheets API response. |
| :rtype: Dict |
| |
| |
| .. py:method:: append_values(self, spreadsheet_id, range_, values, major_dimension = 'ROWS', value_input_option = 'RAW', insert_data_option = 'OVERWRITE', include_values_in_response = False, value_render_option = 'FORMATTED_VALUE', date_time_render_option = 'SERIAL_NUMBER') |
| |
| Append values from Google Sheet from a single range |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append |
| |
| :param spreadsheet_id: The Google Sheet ID to interact with |
| :param range_: The A1 notation of the values to retrieve. |
| :param values: Data within a range of the spreadsheet. |
| :param major_dimension: Indicates which dimension an operation should apply to. |
| DIMENSION_UNSPECIFIED, ROWS, or COLUMNS |
| :param value_input_option: Determines how input data should be interpreted. |
| RAW or USER_ENTERED |
| :param insert_data_option: Determines how existing data is changed when new data is input. |
| OVERWRITE or INSERT_ROWS |
| :param include_values_in_response: Determines if the update response should |
| include the values of the cells that were updated. |
| :param value_render_option: Determines how values should be rendered in the output. |
| FORMATTED_VALUE, UNFORMATTED_VALUE, or FORMULA |
| :param date_time_render_option: Determines how dates should be rendered in the output. |
| SERIAL_NUMBER or FORMATTED_STRING |
| :return: Google Sheets API response. |
| :rtype: Dict |
| |
| |
| .. py:method:: clear(self, spreadsheet_id, range_) |
| |
| Clear values from Google Sheet from a single range |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear |
| |
| :param spreadsheet_id: The Google Sheet ID to interact with |
| :param range_: The A1 notation of the values to retrieve. |
| :return: Google Sheets API response. |
| :rtype: Dict |
| |
| |
| .. py:method:: batch_clear(self, spreadsheet_id, ranges) |
| |
| Clear values from Google Sheet from a list of ranges |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchClear |
| |
| :param spreadsheet_id: The Google Sheet ID to interact with |
| :param ranges: The A1 notation of the values to retrieve. |
| :return: Google Sheets API response. |
| :rtype: Dict |
| |
| |
| .. py:method:: get_spreadsheet(self, spreadsheet_id) |
| |
| Retrieves spreadsheet matching the given id. |
| |
| :param spreadsheet_id: The spreadsheet id. |
| :return: An spreadsheet that matches the sheet filter. |
| |
| |
| .. py:method:: get_sheet_titles(self, spreadsheet_id, sheet_filter = None) |
| |
| Retrieves the sheet titles from a spreadsheet matching the given id and sheet filter. |
| |
| :param spreadsheet_id: The spreadsheet id. |
| :param sheet_filter: List of sheet title to retrieve from sheet. |
| :return: An list of sheet titles from the specified sheet that match |
| the sheet filter. |
| |
| |
| .. py:method:: create_spreadsheet(self, spreadsheet) |
| |
| Creates a spreadsheet, returning the newly created spreadsheet. |
| |
| :param spreadsheet: an instance of Spreadsheet |
| https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#Spreadsheet |
| :return: An spreadsheet object. |
| |
| |
| |