michalslowikowski00 commented on a change in pull request #7866: Add 
download/upload operators for GCS and Google Sheets
URL: https://github.com/apache/airflow/pull/7866#discussion_r397846194
 
 

 ##########
 File path: airflow/providers/google/suite/hooks/sheets.py
 ##########
 @@ -375,3 +375,60 @@ def batch_clear(self, spreadsheet_id: str, ranges: List) 
-> Dict:
         ).execute(num_retries=self.num_retries)
 
         return response
+
+    def get_sheet_titles(self, spreadsheet_id: str, sheet_filter: 
Optional[List[str]] = 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.
+        """
+        response = (
+            self.get_conn()  # pylint: disable=no-member
+            .spreadsheets()
+            .get(spreadsheetId=spreadsheet_id)
+            .execute(num_retries=self.num_retries)
+        )
+
+        if sheet_filter:
+            titles = [
+                sh['properties']['title'] for sh in response['sheets']
+                if sh['properties']['title'] in sheet_filter
+            ]
+        else:
+            titles = [sh['properties']['title'] for sh in response['sheets']]
+        return titles
+
+    def get_spreadsheet(self, spreadsheet_id: str):
+        """
+        Retrieves spreadsheet matching the given id.
+
+        :param spreadsheet_id: The spreadsheet id.
+        :return: An spreadsheet that matches the sheet filter.
+        """
+        response = (
+            self.get_conn()  # pylint: disable=no-member
+            .spreadsheets()
+            .get(spreadsheetId=spreadsheet_id)
+            .execute(num_retries=self.num_retries)
+        )
+        return response
+
+    def create_spreadsheet(self, spreadsheet: Dict[str, Any]) -> Dict[str, 
Any]:
+        """
+        Creates a spreadsheet, returning the newly created spreadsheet.
+
+        :param spreadsheet: an instance of Spreadsheet
 
 Review comment:
   Above methods docstrings have `:return:`.  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to