Skip to content

Commit

Permalink
Merge pull request #1008 from burnash/feature/list_protected_ranges
Browse files Browse the repository at this point in the history
add method list protected ranges
  • Loading branch information
lavigne958 authored Mar 9, 2022
2 parents d9ffc30 + 8f76c8f commit 6cce36c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gspread/spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,18 @@ def update_locale(self, locale):
}

return self.batch_update(body)

def list_protected_ranges(self, sheetid):
"""Lists the spreadsheet's protected named ranges"""
sheets = self.fetch_sheet_metadata(
params={"fields": "sheets.properties,sheets.protectedRanges"}
)["sheets"]

try:
sheet = finditem(
lambda sheet: sheet["properties"]["sheetId"] == sheetid, sheets
)

return sheet["protectedRanges"]
except (StopIteration, KeyError):
return []

0 comments on commit 6cce36c

Please sign in to comment.