generated from cds-snc/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/refactor incident helper with integrations (#616)
* feat: support broader query pattern * fix: handle fields param * fix: return response and update docs * fix: handle delegated user and 'fields' param * feat: add Google Sheets module * chore: lint * fix: refactor using integrations instead of google_drive custom module
- Loading branch information
Showing
9 changed files
with
391 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""Google Sheets API calls.""" | ||
|
||
from integrations.google_workspace.google_service import ( | ||
handle_google_api_errors, | ||
execute_google_api_call, | ||
) | ||
|
||
|
||
@handle_google_api_errors | ||
def get_values( | ||
spreadsheetId: str, range: str | None = None, includeGridData=None, fields=None | ||
): | ||
"""Gets the values from a Google Sheet. | ||
Args: | ||
spreadsheetId (str): The id of the Google Sheet. | ||
range (str, optional): The range of the values to retrieve. | ||
includeGridData (bool, optional): Whether to include grid data. | ||
fields (str, optional): The fields to include in the response. | ||
Returns: | ||
dict: The response from the Google Sheets API. | ||
""" | ||
return execute_google_api_call( | ||
"sheets", | ||
"v4", | ||
"spreadsheets.values", | ||
"get", | ||
spreadsheetId=spreadsheetId, | ||
range=range, | ||
includeGridData=includeGridData, | ||
fields=fields, | ||
) | ||
|
||
|
||
def batch_update_values( | ||
spreadsheetId: str, | ||
range: str, | ||
values: list, | ||
valueInputOption: str = "USER_ENTERED", | ||
) -> dict: | ||
"""Updates values in a Google Sheet. | ||
Args: | ||
spreadsheetId (str): The id of the Google Sheet. | ||
range (str): The range to update. | ||
values (list): The values to update. | ||
valueInputOption (str, optional): The value input option. | ||
Returns: | ||
dict: The response from the Google Sheets API. | ||
""" | ||
return execute_google_api_call( | ||
"sheets", | ||
"v4", | ||
"spreadsheets.values", | ||
"batchUpdate", | ||
spreadsheetId=spreadsheetId, | ||
body={ | ||
"valueInputOption": valueInputOption, | ||
"data": [{"range": range, "values": values}], | ||
}, | ||
) |
Oops, something went wrong.