From 0d5a0289e7705d86b617905c5be8e0e15408cd5b Mon Sep 17 00:00:00 2001 From: Curtis Mitchell Date: Fri, 23 Aug 2024 12:27:00 -0700 Subject: [PATCH] Example using Smartsheet Python SDK --- _data/test_smartsheet.yaml | 126 +++++++++++++++++++++++++++++++++++++ smartsheet_cms.py | 35 +++++++++++ 2 files changed, 161 insertions(+) create mode 100644 _data/test_smartsheet.yaml create mode 100644 smartsheet_cms.py diff --git a/_data/test_smartsheet.yaml b/_data/test_smartsheet.yaml new file mode 100644 index 000000000..c79b8b773 --- /dev/null +++ b/_data/test_smartsheet.yaml @@ -0,0 +1,126 @@ +- Name: 'Responsible AI: Model Cards' + Status: Inactive + Description: Working with the GSA AI COE to develop guidance for creating model + cards. + Participants: Willow Hagen + xD's Role: Participant + Meeting Frequency: null + Start Date: '2021-10-01' + End Date: null + Contacts: null +- Name: 'Transformation: Data Management & Technology Track' + Status: Active + Description: To identify opportunities to improve how Census manages data an deploys + technology. + Participants: Luke Keller + xD's Role: Lead + Meeting Frequency: Bi-weekly + Start Date: '2021-09-01' + End Date: null + Contacts: null +- Name: 'Transformation: Data Futures Studio' + Status: Active + Description: "Creating a new way/model for successful \ninvesting in innovation\ + \ at the Bureau" + Participants: Kate McCall-Kiley, Luke Keller + xD's Role: Lead + Meeting Frequency: Monthly + Start Date: '2021-09-01' + End Date: null + Contacts: null +- Name: COIL Collaboratory + Status: Inactive + Description: Sharing success stories of how to navigate red tape at Census. + Participants: Luke Keller + xD's Role: Participant + Meeting Frequency: One-time Event + Start Date: '2021-09-30' + End Date: '2021-09-30' + Contacts: null +- Name: NITRD Privacy FTAC Co-Chair Meeting + Status: Active + Description: Setting all of gov strategy for Privacy-Enhancing Technologies. Draft + due to OSTP/WH by Oct 1 2022 + Participants: Kate McCall-Kiley, Luke Keller + xD's Role: Co-Chair + Meeting Frequency: Weekly + Start Date: '2022-01-06' + End Date: null + Contacts: James Joshi,Naomi Levkovitz,Tess DeBlanc-Knowles +- Name: NITRD Privacy FTAC Full Meeting + Status: Active + Description: Setting all of gov strategy for Privacy-Enhancing Technologies. Draft + due to OSTP/WH by Oct 1 2022 + Participants: Kate McCall-Kiley, Luke Keller + xD's Role: Co-Chair + Meeting Frequency: Bi-weekly + Start Date: '2022-01-06' + End Date: null + Contacts: James Joshi,Josh Baron,Simson Garfinkel +- Name: Data Equity Executive Order Working Group + Status: Active + Description: A group supporting the implementation of the Data Equity EO from the + Biden administration. + Participants: Kate McCall-Kiley + xD's Role: Participant + Meeting Frequency: null + Start Date: '2021-06-01' + End Date: null + Contacts: null +- Name: AI Steering Committee - AI CoP + Status: Active + Description: A group of 6 advisors for the AI CoP at GSA https://digital.gov/communities/artificial-intelligence/ + Participants: Kate McCall-Kiley, Luke Keller + xD's Role: Advisory + Meeting Frequency: Monthly + Start Date: null + End Date: null + Contacts: null +- Name: AI Working Group (TTC) + Status: Active + Description: AI subgoup of the EU-US Trade and Tech Council (https://ec.europa.eu/commission/presscorner/detail/en/STATEMENT_21_4951) + Participants: Kate McCall-Kiley, Luke Keller + xD's Role: Participant + Meeting Frequency: Quarterly + Start Date: null + End Date: null + Contacts: Teddy Collins +- Name: UN PET Lab + Status: Active + Description: Discussing the UN PETs Pilot project(s). + Participants: Kate McCall-Kiley, Luke Keller + xD's Role: Participant + Meeting Frequency: Weekly + Start Date: null + End Date: null + Contacts: null +- Name: Chief Data Officer Council + Status: Active + Description: Mostly Data Sharing Working Group that would like to use our work as + a pilot + Participants: Kate McCall-Kiley, Luke Keller + xD's Role: Participant + Meeting Frequency: Monthly + Start Date: null + End Date: null + Contacts: null +- Name: 'NITRD Privacy FTAC: Adoption Subgroup' + Status: Active + Description: Conducting industry research and reporting findings on how best to + promote adoption of PETs nationally. + Participants: Luke Keller + xD's Role: Lead + Meeting Frequency: Weekly + Start Date: '2022-04-05' + End Date: null + Contacts: null +- Name: Data Visualization Standards Working Group + Status: Inactive + Description: Developing a set of data visualization standards across the Census + Bureau. + Participants: Luke Keller + xD's Role: Lead + Meeting Frequency: Monthly + Start Date: '2017-03-01' + End Date: '2017-10-01' + Contacts: null diff --git a/smartsheet_cms.py b/smartsheet_cms.py new file mode 100644 index 000000000..6f429c80e --- /dev/null +++ b/smartsheet_cms.py @@ -0,0 +1,35 @@ +import os +import yaml +from dotenv import load_dotenv +import smartsheet + +load_dotenv() # load env variables to get Smartsheet token +dirname = os.path.dirname(__file__) +filename = os.path.join(dirname, '_data/test_smartsheet.yaml') +# access gov instance at https://api.smartsheetgov.com/2.0/ +api_base = smartsheet.__gov_base__ +smart = smartsheet.Smartsheet( # Create a Smartsheet client + access_token=os.environ.get('SMARTSHEET_ACCESS_TOKEN'), + api_base=api_base + ) + +response = ( + smart.Sheets.list_sheets() +) # Call the list_sheets() function and store the response object +sheetId = response.data[27].id # Get the ID of the 10x working groups sheet in the response +sheet = smart.Sheets.get_sheet(sheetId) # Load the sheet by using its ID +rows = [sheet.get_row(row.id) for row in sheet.rows] +cells = [row.cells for row in rows] +data = [] +# create list of data points where each entry is the row of the working groups sheet with column +# title as the key and cell text as the value, i.e. 'Portfolio: Responsible AI' +for cell in cells: + data_point = {} + for cell_value in cell: + column = sheet.get_column(cell_value.column_id) + data_point[column.title] = cell_value.value + data.append(data_point) + +with open(filename, 'w') as outfile: + # the default_flow_style and sort_keys attrs set to False to ensure consistent data order + yaml.dump(data, outfile, default_flow_style=False, sort_keys=False)