### Install Smartsheet Python SDK Manually (Shell) Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/README.md This command illustrates how to install the Smartsheet Python SDK manually after downloading or cloning the source code. It requires navigating to the source directory and executing the setup script using a Python interpreter. ```Shell python setup.py install ``` -------------------------------- ### Setting up Smartsheet Python SDK for Development | shell Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/tests/integration/README.md Provides the shell command to install the Smartsheet Python SDK in development mode, which is necessary before running tests. This allows changes to the source code to be immediately reflected without reinstallation. ```shell python setup.py develop ``` -------------------------------- ### Running Smartsheet Python SDK Unit Tests | shell Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/tests/integration/README.md Outlines the command used to execute the complete test suite for the Smartsheet Python SDK. Ensure the SDK is set up using `setup.py develop` and required environment variables are configured beforehand. ```shell python setup.py test ``` -------------------------------- ### Install Smartsheet Python SDK via pip (Shell) Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/README.md This command shows the standard way to install the Smartsheet Python SDK using the pip package manager. It downloads and installs the library from the Python Package Index (PyPI), assuming pip is installed and configured. ```Shell pip install smartsheet-python-sdk ``` -------------------------------- ### Importing the Smartsheet Python Module Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/docs/_sources/index.rst.txt This snippet shows the basic Python code required to import the installed Smartsheet Python SDK module. This is typically the first step to access the SDK's functionalities after installation and environment setup. No specific parameters are required for this basic import statement. ```Python >>> import smartsheet ``` -------------------------------- ### Importing Smartsheet SDK Module in Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/docs-source/index.rst This Python snippet demonstrates the basic step of importing the installed Smartsheet SDK module into your script or interactive session. It makes all the classes and functions provided by the SDK available for use in interacting with the Smartsheet API. ```Python import smartsheet ``` -------------------------------- ### Upgrade Smartsheet Python SDK via pip (Shell) Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/README.md This command demonstrates how to upgrade an existing installation of the Smartsheet Python SDK using the pip package manager. It fetches and installs the latest version available from PyPI, requiring pip to be installed and in the system's PATH. ```Shell pip install smartsheet-python-sdk --upgrade ``` -------------------------------- ### Configuring Smartsheet Python SDK Test Environment Variables | shell Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/tests/integration/README.md Shows the shell commands required to set environment variables necessary for running Smartsheet Python SDK acceptance tests against the real service. This includes your Smartsheet access token, an optional logging level, and a JSON string mapping user nicknames to required user IDs. ```shell export SMARTSHEET_ACCESS_TOKEN="SSSSSSSSSSSSSSSSSSSSSSSSSS" export LOG_CFG="debug" # optional export SMARTSHEET_FIXTURE_USERS='{"admin":{"id":9999999999999999},"larry":{"id":0000000000000000},"curly":{"id":1111111111111111},"moe":{"id":2222222222222222}}' ``` -------------------------------- ### Consuming Event Reporting Stream Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md Provides a sample implementation for consuming the Smartsheet Event Reporting stream. It includes a helper function to process events and a loop to fetch pages of events starting from a specific time or a stream position, handling `more_available`. Requires the `smartsheet`, `datetime`, and `timedelta` modules. ```python # this example is looking specifically for new sheet events def print_new_sheet_events_in_list(events_list): # enumerate all events in the list of returned events for event in events_list.data: # find all created sheets if event.object_type == smartsheet.models.enums.EventObjectType.SHEET and event.action == smartsheet.models.enums.EventAction.CREATE: # additional details are available for some events, they can be accessed as a Python dictionary # in the additional_details attribute print(event.additional_details['sheetName']) smartsheet_client = smartsheet.Smartsheet() smartsheet_client.errors_as_exceptions() # begin listing events in the stream starting with the `since` parameter last_week = datetime.now() - timedelta(days=7) # this example looks at the previous 7 days of events by providing a `since` argument set to last week's date in ISO format events_list = smartsheet_client.Events.list_events(since=last_week.isoformat(), max_count=1000) print_new_sheet_events_in_list(events_list) # continue listing events in the stream by using the stream_position, if the previous response indicates that more # data is available. while events_list.more_available: events_list = smartsheet_client.Events.list_events(stream_position=events_list.next_stream_position, max_count=10000, numeric_dates=True) print_new_sheet_events_in_list(events_list) ``` -------------------------------- ### Updating Cell and Clearing Hyperlink using ExplicitNull in Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/CHANGELOG.md This example demonstrates how to update a cell's value and specifically clear its hyperlink using the ExplicitNull model. This model is required to force the serialization of a null value for properties like hyperlink when the default serializer ignores null values, as changed in version 1.3.0. ```Python first_row = Row() first_row.id = 10 first_row.cells.append({ "columnId": 101, "value": "", "hyperlink": ExplicitNull() }) response = self.client.Sheets.update_rows(1, [first_row]) ``` -------------------------------- ### Initializing Client with HTTP Proxy Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md Shows how to initialize the Smartsheet client with an HTTP proxy configuration. It defines a dictionary mapping protocol to proxy address and passes it to the `smartsheet.Smartsheet` constructor via the `proxies` argument. Requires the `smartsheet` library. ```python # Initialize client proxies = { 'https': 'http://127.0.0.1:8888' } smartsheet_client = smartsheet.Smartsheet(proxies=proxies) ``` -------------------------------- ### Initializing Client for Smartsheet Regions Europe Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md Shows how to connect the Smartsheet Python SDK to the Smartsheet Regions Europe environment. It initializes the client by passing the predefined EU API base URI constant (`smartsheet._eu_base_`) to the `api_base` parameter of the constructor. Requires the `smartsheet` library. ```python client = smartsheet.Smartsheet(api_base=smartsheet._eu_base_) ``` -------------------------------- ### Initializing Client for Smartsheetgov Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md Explains how to connect the Smartsheet Python SDK to the Smartsheetgov.com environment. It initializes the client by passing the predefined government API base URI constant (`smartsheet.__gov_base__`) to the `api_base` parameter of the constructor. Requires the `smartsheet` library. ```python client = smartsheet.Smartsheet(api_base=smartsheet.__gov_base__) ``` -------------------------------- ### Configuring Basic Logging Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md Configures basic logging for the Smartsheet Python SDK. It sets the output file and the minimum logging level. Dependencies include the built-in `logging` module. The output is logging messages written to the specified file. ```python import logging logging.basicConfig(filename='mylog.log', level=logging.DEBUG) ``` -------------------------------- ### Using Passthrough POST Request Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md Demonstrates how to use the passthrough option to make a POST request to an API endpoint not directly supported by the SDK. It constructs a payload dictionary and sends it using `client.Passthrough.post`. Requires an initialized `client` object. ```python payload = {"name": "my new sheet", "columns": [ {"title": "Favorite", "type": "CHECKBOX", "symbol": "STAR"}, {"title": "Primary Column", "primary": True, "type": "TEXT_NUMBER"} ] } response = client.Passthrough.post('/sheets', payload) ``` -------------------------------- ### Checking Sheet Access Level using EnumeratedValue in Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/CHANGELOG.md This snippet demonstrates how to check the access_level property of a Smartsheet sheet object using the AccessLevel enumerated type. It highlights the new recommended approach for programmatic clarity and better code completion introduced in version 1.3.1. ```Python sheet = smartsheet.Sheets.get_sheet(sheet_id) if sheet.access_level == AccessLevel.OWNER: # perform some task for OWNER ... ``` -------------------------------- ### Checking Sheet Access Level using String Comparison in Python Source: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/CHANGELOG.md This snippet shows an alternative way to check the access_level property of a Smartsheet sheet object using a simple string comparison. The changelog notes that this method remains supported for backward compatibility after the introduction of EnumeratedValue. ```Python sheet = smartsheet.Sheets.get_sheet(sheet_id) if sheet.access_level == 'OWNER': # perform some task for OWNER ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.