### Install build and twine Source: https://github.com/domoinc/domo-python-sdk/blob/master/UPDATING_PYPI.md Install or upgrade the build and twine packages using pip. These are necessary for packaging and uploading Python projects. ```bash python3 -m pip install --upgrade build python3 -m pip install --upgrade twine ``` -------------------------------- ### Instantiate Domo Client and Get Dataset Source: https://github.com/domoinc/domo-python-sdk/blob/master/README.md Instantiates the Domo client using API credentials and retrieves a dataset from Domo. Ensure your API client ID and secret are correctly provided. ```python from pydomo import Domo domo = Domo('client-id','secret',api_host='api.domo.com') # Download a data set from Domo car_data = domo.ds_get('2f09a073-54a4-4269-8c62-b776e67d59f0') ``` -------------------------------- ### Manage Domo Users Programmatically Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Provides examples for adding, retrieving, listing, updating, and deleting users in Domo. This is useful for synchronizing with external user directories like LDAP/AD. Ensure the correct user ID is used for operations. ```python import pandas as pd from pydomo import Domo domo = Domo('client-id', 'secret') # Create a single user (sendInvite=True sends an email invitation) new_user = domo.users_add( x_name = 'Grace Hopper', x_email = 'g.hopper@example.com', x_role = 'Participant', # roles: Admin, Privileged, Editor, Participant x_sendInvite= False ) user_id = new_user['id'] print(f"Created user {user_id}: {new_user['name']}") # Get a single user user = domo.users_get(user_id) print(user) # {'id': ..., 'name': 'Grace Hopper', 'email': '...', 'role': 'Participant'} # List all users as a DataFrame all_users_df = domo.users_list(df_output=True) print(all_users_df[['id', 'name', 'email', 'role']].head()) # List as raw list all_users_list = domo.users_list(df_output=False) # Update a user's role update_def = {'name': 'Grace Hopper', 'email': 'g.hopper@example.com', 'role': 'Editor'} domo.users_update(user_id, update_def) # Delete a user domo.users_delete(user_id) ``` -------------------------------- ### Get DataSet Metadata with Domo Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Fetch detailed metadata for a specific DataSet, including its schema, owner information, row and column counts, and update method. Requires the DataSet ID. ```python from pydomo import Domo domo = Domo('client-id', 'secret') meta = domo.ds_meta('2f09a073-54a4-4269-8c62-b776e67d59f0') print(meta['name']) # "Pioneer Mathematicians" print(meta['rows']) # 3 print(meta['schema']['columns']) # [{'type': 'STRING', 'name': 'Name'}, {'type': 'LONG', 'name': 'Year'}, ...] ``` -------------------------------- ### Get DataSet Metadata Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Fetches full metadata for a single DataSet, including schema, owner, row/column counts, and update method. ```APIDOC ## `domo.ds_meta(dataset_id)` — Get DataSet metadata Fetches full metadata for a single DataSet, including schema, owner, row/column counts, and update method. ### Parameters - `dataset_id` (str) - Required - The ID of the DataSet. ### Request Example ```python from pydomo import Domo domo = Domo('client-id', 'secret') meta = domo.ds_meta('2f09a073-54a4-4269-8c62-b776e67d59f0') print(meta['name']) print(meta['rows']) print(meta['schema']['columns']) ``` ``` -------------------------------- ### Create Row-Level Security Policy (PDP) with Domo Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Define and create Personalized Data Policies (PDP) to restrict row access for users or groups within a DataSet. Multiple filter conditions can be combined in a single policy. This example shows how to build a filter for a specific region. ```python from pydomo import Domo from pydomo.datasets import Policy, PolicyFilter, FilterOperator, PolicyType domo = Domo('client-id', 'secret') ds_id = '2f09a073-54a4-4269-8c62-b776e67d59f0' # Build a filter: only rows where Region == 'North' f1 = PolicyFilter() f1.column = 'Region' f1.operator = FilterOperator.EQUALS f1.values = ['North'] ``` -------------------------------- ### Instantiate Domo SDK Client Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Initialize the Domo client using direct credentials or a connection file. Optional arguments allow customization of API host, HTTPS usage, logging, and request timeouts. ```python from pydomo import Domo # Option 1: Direct credentials domo = Domo( 'your-client-id', 'your-client-secret', api_host='api.domo.com', # default use_https=True, # default log_level='WARNING', # optional: DEBUG, INFO, WARNING, ERROR request_timeout=30, # optional: seconds scope=['data', 'user'] # optional: limit OAuth scopes ) # Option 2: INI connection file (connection.ini) # [client_auth] # client = your-client-id # secret = your-client-secret # api_host = api.domo.com # use_https = True domo_from_file = Domo(connection_file='connection.ini') # Multiple independent clients (different API credentials) can coexist domo_admin = Domo('admin-client-id', 'admin-secret') domo_readonly = Domo('readonly-client-id', 'readonly-secret') ``` -------------------------------- ### Domo SDK Initialization Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Instantiate the Domo SDK client with credentials. Supports direct credentials or an INI configuration file. Optional arguments allow customization of API host, HTTPS usage, logging, timeout, and scopes. ```APIDOC ## Initialization ### `Domo(client_id, client_secret, ...)` — Instantiate the SDK client Creates a fully authenticated SDK client. Credentials can be supplied directly or via an INI configuration file. Optional arguments control the API host, HTTPS usage, logging level, request timeout, and OAuth scopes. ```python from pydomo import Domo # Option 1: Direct credentials domo = Domo( 'your-client-id', 'your-client-secret', api_host='api.domo.com', # default use_https=True, # default log_level='WARNING', # optional: DEBUG, INFO, WARNING, ERROR request_timeout=30, # optional: seconds scope=['data', 'user'] # optional: limit OAuth scopes ) # Option 2: INI connection file (connection.ini) # [client_auth] # client = your-client-id # secret = your-client-secret # api_host = api.domo.com # use_https = True domo_from_file = Domo(connection_file='connection.ini') # Multiple independent clients (different API credentials) can coexist domo_admin = Domo('admin-client-id', 'admin-secret') domo_readonly = Domo('readonly-client-id', 'readonly-secret') ``` ``` -------------------------------- ### Run All Tests Source: https://github.com/domoinc/domo-python-sdk/blob/master/tests/README.md Execute all unit tests within the project. Ensure you are in the root directory of the project. ```bash python -m unittest discover tests ``` -------------------------------- ### Interact with Domo Groups and Users Source: https://github.com/domoinc/domo-python-sdk/blob/master/README.md Demonstrates listing all groups and users, listing users within a specific group, and adding users to a group. Requires valid group and user IDs. ```python # Interact with groups all_groups = domo.groups_list() # List all groups all_users = domo.users_list() # List all users # List all users in US South Division domo.groups_list_users(328554991) added_users = domo.groups_add_users(328554991,2063934980) domo.groups_list_users(328554991) ``` -------------------------------- ### Create Summary Dataset and Create New Dataset in Domo Source: https://github.com/domoinc/domo-python-sdk/blob/master/README.md Creates a summary dataset by aggregating data and then creates a new dataset in Domo with the summarized information. The return value is the ID of the newly created dataset. ```python # Create a summary data set, taking the mean of dollars by make and model. car_summary = car_data.groupby(['make','model']).agg({'dollars':'mean'}).reset_index() # Create a new data set in Domo with the result, the return value is the data set id of the new data set. car_ds = domo.ds_create(car_summary,'Python | Car Summary Data Set','Python | Generated during demo') ``` -------------------------------- ### Low-Level DataSet Management with Domo Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Utilize the `DataSetClient` for fine-grained control over DataSet schema, data import/export, and PDP management. This includes creating, updating, and deleting DataSets, as well as importing and exporting data. ```python from pydomo import Domo from pydomo.datasets import ( DataSetRequest, Schema, Column, ColumnType, Policy, PolicyFilter, FilterOperator, PolicyType, Sorting, UpdateMethod ) domo = Domo('client-id', 'secret') datasets = domo.datasets # 1. Define schema and create DataSet dsr = DataSetRequest() dsr.name = 'Sales Data' dsr.description = 'Monthly sales by region' dsr.schema = Schema([ Column(ColumnType.STRING, 'Region'), Column(ColumnType.LONG, 'Month'), Column(ColumnType.DOUBLE, 'Revenue'), Column(ColumnType.DATETIME, 'Updated') ]) dataset = datasets.create(dsr) print("Created:", dataset['id']) ``` ```python # 2. Import CSV data csv_data = '"North",1,150000.00,"2024-01-31 00:00:00"\n"South",1,98000.50,"2024-01-31 00:00:00"' datasets.data_import(dataset['id'], csv_data, update_method=UpdateMethod.REPLACE) ``` ```python # 3. Export to string csv_str = datasets.data_export(dataset['id'], include_csv_header=True) print(csv_str) ``` ```python # 4. Export to file (streams to disk) f = datasets.data_export_to_file(dataset['id'], './sales.csv', include_csv_header=True) f.close() ``` ```python # 5. Import from file datasets.data_import_from_file(dataset['id'], './sales.csv', update_method=UpdateMethod.APPEND) ``` ```python # 6. List with sorting ds_list = list(datasets.list(sort=Sorting.UPDATED, per_page=25, limit=100)) ``` ```python # 7. Update metadata update = DataSetRequest() update.name = 'Sales Data v2' update.description = 'Quarterly sales by region' update.schema = Schema([ Column(ColumnType.STRING, 'Region'), Column(ColumnType.LONG, 'Quarter'), Column(ColumnType.DOUBLE, 'Revenue') ]) datasets.update(dataset['id'], update) ``` ```python # 8. Delete datasets.delete(dataset['id']) ``` -------------------------------- ### Manage Domo Accounts (Credentials) with Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt This snippet shows how to create, retrieve, list, update, and delete accounts, which store connector credentials for Domo DataSets. Ensure you have the correct account type and properties. ```python from pydomo import Domo domo = Domo('client-id', 'secret') # Create an account new_account = domo.accounts_create( name = 'Production MySQL', valid = True, type = {'id': 'domo-csv', 'properties': {}} ) account_id = new_account['id'] print(f"Created account: {account_id}") # Get an account by ID account = domo.accounts_get(account_id) print(account) # {'id': '40', 'name': 'Production MySQL', 'valid': True, 'type': {'id': 'domo-csv', ...}} # List all accounts (auto-paginates) all_accounts = domo.accounts_list() for acct in all_accounts: print(acct['id'], acct['name'], acct['valid']) # Update an account name domo.accounts_update(account_id, name='Production MySQL - Updated', valid=True, type={'id': 'domo-csv', 'properties': {}}) # Delete an account domo.accounts_delete(account_id) ``` -------------------------------- ### Create, List, Update, and Delete PDP Policies Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Demonstrates how to create, list, update, and delete Personal Data Protection (PDP) policies for a dataset. Ensure the dataset ID is correctly specified. ```python # Build a second filter: Revenue > 50000 f2 = PolicyFilter() f2.column = 'Revenue' f2.operator = FilterOperator.GREATER_THAN f2.values = ['50000'] # Create policy applying both filters to specific users and groups policy = Policy() policy.name = 'North Region High Revenue' policy.filters = [f1, f2] policy.type = PolicyType.USER policy.users = [1001, 1002] # affected user IDs policy.groups = [200] # affected group IDs created = domo.pdp_create(ds_id, policy) print(f"PDP created: id={created['id']}, name={created['name']}") # List all PDPs (as DataFrame) pdp_df = domo.pdp_list(ds_id) print(pdp_df[['id', 'name', 'type']]) # Update: negate the filter (NOT EQUALS) f1['not'] = True policy.name = 'Exclude North Region' domo.pdp_update(ds_id, created['id'], policy) # Delete domo.pdp_delete(ds_id, created['id']) ``` -------------------------------- ### Manage Domo Pages with Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt This code demonstrates how to create, retrieve, update, list, and delete dashboard pages and their collections. Use for organizing and managing your Domo dashboards. ```python from pydomo import Domo domo = Domo('client-id', 'secret') # Create a top-level page page = domo.page_create( 'Q1 2024 Dashboard', locked=False, cardIds=[54321, 67890], visibility={'userIds': [1001], 'groupIds': [200]} ) page_id = page['id'] print(f"Created page {page_id}: {page['name']}") # Create a sub-page subpage = domo.page_create('Regional Breakdown', parentId=page_id) # Get page details retrieved = domo.page_get(page_id) print(retrieved) # {'id': page_id, 'name': 'Q1 2024 Dashboard', 'locked': False, # 'ownerId': 12345, 'cardIds': [54321, 67890], ...} # Update: lock the page and add a card domo.page_update(page_id, locked=True, cardIds=[54321, 67890, 11111]) # List all pages all_pages = domo.page_list() print(f"Total pages: {len(all_pages)}") # Create a card collection within a page collection = domo.collections_create(page_id, 'Sales Section', description='Q1 sales cards', cardIds=[54321]) collection_id = collection['id'] # Get collections on a page cols = domo.page_get_collections(page_id) # Update a collection domo.collections_update(page_id, collection_id, cardIds=[54321, 67890]) # Delete a collection domo.collections_delete(page_id, collection_id) # Delete the page domo.page_delete(page_id) ``` -------------------------------- ### Upload package to Pypi Source: https://github.com/domoinc/domo-python-sdk/blob/master/UPDATING_PYPI.md Upload the built package to the Pypi repository using twine. You will be prompted for your Pypi API key. ```bash python3 -m twine upload --repository pypi dist/* ``` -------------------------------- ### Run Specific Test File Source: https://github.com/domoinc/domo-python-sdk/blob/master/tests/README.md Execute all tests within a particular file. Replace 'tests.test_utilities_type_conversion' with the desired test file path. ```bash python -m unittest tests.test_utilities_type_conversion -v ``` -------------------------------- ### List DataSets with Domo Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Retrieve a list of all DataSets in your Domo instance. Supports returning results as a DataFrame or a raw list, with options for pagination and filtering by name. ```python from pydomo import Domo domo = Domo('client-id', 'secret') # All DataSets as a DataFrame (default) all_ds = domo.ds_list() print(all_ds[['id', 'name', 'rows', 'columns']].head(10)) ``` ```python # Raw list, first 100 matching a name fragment matching = domo.ds_list(df_output=False, limit=100, name_like='Sales') for ds in matching: print(ds['id'], ds['name']) ``` -------------------------------- ### Manage Domo Groups with Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Use this snippet to create, list, add/remove users from, and delete groups. Groups are essential for controlling data access via PDP policies. ```python import pandas as pd from pydomo import Domo domo = Domo('client-id', 'secret') # Create a group (optionally add users at creation time) group = domo.groups_create('Data Science Team', users=[1001, 1002, 1003]) group_id = group['id'] print(f"Created group {group_id}: {group['name']}") # Get group metadata g = domo.groups_get(group_id) print(g) # List all groups as a DataFrame groups_df = domo.groups_list() print(groups_df[['id', 'name']].head()) # List users in a group (auto-paginates in batches of 500) members = domo.groups_list_users(group_id) print(f"{len(members)} members: {members}") # Add a single user or a list of users domo.groups_add_users(group_id, 1004) domo.groups_add_users(group_id, [1005, 1006]) # Remove a single user or a list domo.groups_remove_users(group_id, 1004) domo.groups_remove_users(group_id, [1005, 1006]) # Delete (removes all members first, then deletes) domo.groups_delete(group_id) ``` -------------------------------- ### Create a New DataSet Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Create a new DataSet in Domo by uploading a pandas DataFrame. The SDK derives the schema from pandas dtypes and supports `REPLACE`, `APPEND`, and `UPSERT` update methods. For `UPSERT`, specify `key_column_names`. ```APIDOC --- ### `domo.ds_create(df, name, description, update_method, key_column_names)` — Create a new DataSet Creates a Stream pipeline and DataSet in Domo, uploads the DataFrame's data, and returns the new DataSet ID. The schema is derived automatically from pandas dtypes. Supports `REPLACE`, `APPEND`, and `UPSERT` update methods. ```python import pandas as pd from pydomo import Domo domo = Domo('client-id', 'secret') df = pd.DataFrame({ 'Name': ['Alan Turing', 'Ada Lovelace', 'Grace Hopper'], 'Country': ['UK', 'UK', 'US'], 'Year': [1912, 1815, 1906] }) # Create with REPLACE (default) ds_id = domo.ds_create(df, 'Pioneer Mathematicians', 'Historical data') print(f"Created DataSet: {ds_id}") # Create with UPSERT (requires a key column) ds_id_upsert = domo.ds_create( df, 'Pioneer Mathematicians - Upsert', 'With upsert support', update_method='UPSERT', key_column_names=['Name'] ) ``` ``` -------------------------------- ### Run SQL Query Against DataSet with Domo Python SDK Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Execute SQL queries against a specified DataSet using the Domo query engine. Results can be returned as a DataFrame or a raw dictionary. The table alias in queries is always 'table'. ```python from pydomo import Domo domo = Domo('client-id', 'secret') ds_id = '2f09a073-54a4-4269-8c62-b776e67d59f0' # SQL query — table alias is always "table" result_df = domo.ds_query(ds_id, 'SELECT Name, Year FROM table WHERE Year > 1850 ORDER BY Year') print(result_df) # Name Year # 0 Ada Lovelace 1815 <- excluded by WHERE # 1 Alan Turing 1912 # 2 Grace Hopper 1906 ``` ```python # Return raw dict (columns + rows arrays) raw = domo.ds_query(ds_id, 'SELECT COUNT(*) AS total FROM table', return_data=False) print(raw) # {'columns': ['total'], 'rows': [[3]], 'numRows': 1, ...} ``` -------------------------------- ### Domo Utilities: Schema Inspection and Type Conversion Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Utilize the UtilitiesClient for inspecting Domo-side schemas, deriving schemas from pandas DataFrames, and performing type conversions between Domo and pandas data types. ```python from pydomo import Domo import pandas as pd domo = Domo('client-id', 'secret') utils = domo.utilities # Inspect Domo-side schema for a DataSet domo_schema = utils.domo_schema('2f09a073-54a4-4269-8c62-b776e67d59f0') # [{'type': 'STRING', 'name': 'Region'}, {'type': 'DOUBLE', 'name': 'Revenue'}, ...] # Derive a Domo schema from a pandas DataFrame df = pd.DataFrame({'Name': ['Alice'], 'Score': [95.5], 'Date': pd.to_datetime(['2024-01-01'])}) data_schema = utils.data_schema(df) # [{'type': 'STRING', 'name': 'Name'}, {'type': 'DOUBLE', 'name': 'Score'}, {'type': 'DATETIME', 'name': 'Date'}] # Type conversion helpers print(utils.type_conversion_text(df['Score'].dtype)) # 'DOUBLE' print(utils.type_conversion_text(df['Date'].dtype)) # 'DATETIME' print(utils.convert_domo_type_to_pandas_type('LONG')) # 'Int64' print(utils.is_date_type('DATETIME')) # True ``` -------------------------------- ### Download a DataSet Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Download a DataSet from Domo as a pandas DataFrame. The SDK automatically fetches the schema to apply correct column types. Optionally, skip schema fetching to let pandas infer types or retrieve data as a list of dictionaries. ```APIDOC ## DataSet API ### `domo.ds_get(dataset_id)` — Download a DataSet as a pandas DataFrame Exports a DataSet from Domo to a pandas DataFrame. The schema is fetched automatically to apply correct column types (LONG → Int64, DOUBLE/DECIMAL → Float64, DATE/DATETIME → datetime64[ns], STRING → string). Set `use_schema=False` to let pandas infer types dynamically. ```python import pandas as pd from pydomo import Domo domo = Domo('client-id', 'secret') # Download with automatic schema/type mapping df = domo.ds_get('2f09a073-54a4-4269-8c62-b776e67d59f0') print(df.dtypes) # Friend string # Attending string # Revenue Float64 # Date datetime64[ns] # Skip schema fetch (faster, pandas infers types) df_raw = domo.ds_get('2f09a073-54a4-4269-8c62-b776e67d59f0', use_schema=False) # Download as a list of dicts instead of DataFrame rows = domo.ds_get_dict('2f09a073-54a4-4269-8c62-b776e67d59f0') # [{'Friend': 'Alan Turing', 'Attending': 'TRUE'}, ...] ``` ``` -------------------------------- ### Run SQL against a DataSet Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Submits a SQL query to the Domo query engine and returns results as a DataFrame (or raw dict). ```APIDOC ## `domo.ds_query(dataset_id, query, return_data)` — Run SQL against a DataSet Submits a SQL query to the Domo query engine and returns results as a DataFrame (or raw dict). ### Parameters - `dataset_id` (str) - Required - The ID of the DataSet. - `query` (str) - Required - The SQL query to execute. The table alias is always "table". - `return_data` (bool) - Optional - If True, returns results as a DataFrame. If False, returns raw dict. Defaults to True. ### Request Example ```python from pydomo import Domo domo = Domo('client-id', 'secret') ds_id = '2f09a073-54a4-4269-8c62-b776e67d59f0' # SQL query — table alias is always "table" result_df = domo.ds_query(ds_id, 'SELECT Name, Year FROM table WHERE Year > 1850 ORDER BY Year') print(result_df) # Return raw dict (columns + rows arrays) raw = domo.ds_query(ds_id, 'SELECT COUNT(*) AS total FROM table', return_data=False) print(raw) ``` ``` -------------------------------- ### Page Management Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Create, inspect, and update Domo pages and their card collections. ```APIDOC ## `domo.page_create` — Create a page ### Description Creates a new Domo page, which can be a top-level page or a sub-page. ### Method `page_create(name, parentId=None, locked=False, cardIds=None, visibility=None)` ### Parameters - **name** (str) - Required - The name of the page. - **parentId** (int, optional) - The ID of the parent page if creating a sub-page. - **locked** (bool, optional) - Whether the page is locked. Defaults to False. - **cardIds** (list[int], optional) - A list of card IDs to include on the page. - **visibility** (dict, optional) - Defines the visibility of the page. Example: `{'userIds': [1001], 'groupIds': [200]}`. ### Request Example ```python # Create a top-level page page = domo.page_create('Q1 2024 Dashboard', locked=False, cardIds=[54321, 67890], visibility={'userIds': [1001], 'groupIds': [200]}) # Create a sub-page subpage = domo.page_create('Regional Breakdown', parentId=page['id']) ``` ### Response #### Success Response (200) - **id** (int) - The ID of the newly created page. - **name** (str) - The name of the page. - Other page details like `locked`, `ownerId`, `cardIds`, etc. ### Response Example ```json { "id": 12345, "name": "Q1 2024 Dashboard", "locked": false, "ownerId": 12345, "cardIds": [54321, 67890] } ``` ``` ```APIDOC ## `domo.page_get` — Get page details ### Description Retrieves detailed information about a specific Domo page. ### Method `page_get(page_id)` ### Parameters - **page_id** (int) - Required - The ID of the page to retrieve. ### Request Example ```python retrieved = domo.page_get(12345) ``` ### Response #### Success Response (200) - A dictionary containing detailed information about the page, including its ID, name, locked status, owner, and associated card IDs. ### Response Example ```json { "id": 12345, "name": "Q1 2024 Dashboard", "locked": false, "ownerId": 12345, "cardIds": [54321, 67890] } ``` ``` ```APIDOC ## `domo.page_update` — Update a page ### Description Updates an existing Domo page's properties, such as its locked status or the cards it contains. ### Method `page_update(page_id, **kwargs)` ### Parameters - **page_id** (int) - Required - The ID of the page to update. - **kwargs** - Optional keyword arguments to update page properties. Common arguments include `locked` (bool) and `cardIds` (list[int]). ### Request Example ```python domo.page_update(12345, locked=True, cardIds=[54321, 67890, 11111]) ``` ### Response #### Success Response (200) - Typically returns the updated page object or a success indicator. ``` ```APIDOC ## `domo.page_list` — List all pages ### Description Retrieves a list of all Domo pages accessible to the user. ### Method `page_list()` ### Parameters None ### Request Example ```python all_pages = domo.page_list() ``` ### Response #### Success Response (200) - A list of dictionaries, where each dictionary represents a Domo page and contains its basic information. ### Response Example ```json [ { "id": 12345, "name": "Q1 2024 Dashboard", "ownerId": 12345 }, { "id": 67890, "name": "Regional Breakdown", "ownerId": 12345 } ] ``` ``` ```APIDOC ## `domo.page_delete` — Delete a page ### Description Deletes a specified Domo page. ### Method `page_delete(page_id)` ### Parameters - **page_id** (int) - Required - The ID of the page to delete. ### Request Example ```python domo.page_delete(12345) ``` ### Response #### Success Response (200) - Typically returns an empty response or a success indicator upon successful deletion. ``` ```APIDOC ## `domo.collections_create` — Create a card collection ### Description Creates a new card collection within a specified page. ### Method `collections_create(page_id, name, description=None, cardIds=None)` ### Parameters - **page_id** (int) - Required - The ID of the page where the collection will be created. - **name** (str) - Required - The name of the card collection. - **description** (str, optional) - A description for the collection. - **cardIds** (list[int], optional) - A list of card IDs to include in the collection. ### Request Example ```python collection = domo.collections_create(12345, 'Sales Section', description='Q1 sales cards', cardIds=[54321]) ``` ### Response #### Success Response (200) - **id** (int) - The ID of the newly created collection. - **name** (str) - The name of the collection. - Other collection details. ``` ```APIDOC ## `domo.page_get_collections` — Get collections on a page ### Description Retrieves all card collections associated with a specific page. ### Method `page_get_collections(page_id)` ### Parameters - **page_id** (int) - Required - The ID of the page whose collections are to be retrieved. ### Request Example ```python cols = domo.page_get_collections(12345) ``` ### Response #### Success Response (200) - A list of dictionaries, where each dictionary represents a card collection on the page. ``` ```APIDOC ## `domo.collections_update` — Update a card collection ### Description Updates an existing card collection on a page, such as modifying its name, description, or associated cards. ### Method `collections_update(page_id, collection_id, **kwargs)` ### Parameters - **page_id** (int) - Required - The ID of the page containing the collection. - **collection_id** (int) - Required - The ID of the collection to update. - **kwargs** - Optional keyword arguments to update collection properties. Common arguments include `name`, `description`, and `cardIds`. ### Request Example ```python domo.collections_update(12345, 111, cardIds=[54321, 67890]) ``` ### Response #### Success Response (200) - Typically returns the updated collection object or a success indicator. ``` ```APIDOC ## `domo.collections_delete` — Delete a card collection ### Description Deletes a specified card collection from a page. ### Method `collections_delete(page_id, collection_id)` ### Parameters - **page_id** (int) - Required - The ID of the page containing the collection. - **collection_id** (int) - Required - The ID of the collection to delete. ### Request Example ```python domo.collections_delete(12345, 111) ``` ### Response #### Success Response (200) - Typically returns an empty response or a success indicator upon successful deletion. ``` -------------------------------- ### List DataSets Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Returns a list or DataFrame of all DataSets in the Domo instance with pagination support. Filtering by name substring is supported. ```APIDOC ## `domo.ds_list(df_output, per_page, offset, limit, name_like)` — List DataSets Returns a list or DataFrame of all DataSets in the Domo instance with pagination support. Filtering by name substring is supported via `name_like`. ### Parameters - `df_output` (bool) - Optional - If True, returns a DataFrame. Defaults to True. - `per_page` (int) - Optional - Number of items per page for pagination. - `offset` (int) - Optional - Offset for pagination. - `limit` (int) - Optional - Maximum number of items to return. - `name_like` (str) - Optional - Filter DataSets by a name substring. ### Request Example ```python from pydomo import Domo domo = Domo('client-id', 'secret') # All DataSets as a DataFrame (default) all_ds = domo.ds_list() print(all_ds[['id', 'name', 'rows', 'columns']].head(10)) # Raw list, first 100 matching a name fragment matching = domo.ds_list(df_output=False, limit=100, name_like='Sales') for ds in matching: print(ds['id'], ds['name']) ``` ``` -------------------------------- ### High-Volume Parallel Uploads with Domo Streams API Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Illustrates creating a stream, uploading data in parallel parts, and committing the execution. This method is suitable for large or rapidly changing DataSets. Ensure the necessary imports are present. ```python from pydomo import Domo from pydomo.datasets import DataSetRequest, Schema, Column, ColumnType from pydomo.streams import CreateStreamRequest, UpdateMethod domo = Domo('client-id', 'secret') streams = domo.streams # 1. Define schema dsr = DataSetRequest() dsr.name = 'Transaction Log' dsr.description = 'High-volume transaction data' dsr.schema = Schema([ Column(ColumnType.LONG, 'TxID'), Column(ColumnType.STRING, 'User'), Column(ColumnType.DOUBLE, 'Amount'), Column(ColumnType.DATETIME, 'Timestamp') ]) # 2. Create Stream (APPEND keeps history; REPLACE overwrites) stream_req = CreateStreamRequest(dsr, UpdateMethod.APPEND) stream = streams.create(stream_req) stream_id = stream['id'] ds_id = stream['dataSet']['id'] print(f"Stream {stream_id} → DataSet {ds_id}") # 3. Search for an existing Stream results = streams.search(f'dataSource.name:{dsr.name}') print(f"Found {len(results)} matching stream(s)") # 4. Begin an Execution (upload session) execution = streams.create_execution(stream_id) execution_id = execution['id'] # 5. Upload parts in parallel (parts can be uploaded concurrently) part1_csv = '1,"alice",99.99,"2024-03-01 10:00:00"\n2,"bob",149.00,"2024-03-01 10:01:00"' part2_csv = '3,"carol",55.50,"2024-03-01 10:02:00"\n4,"dave",200.00,"2024-03-01 10:03:00"' streams.upload_part(stream_id, execution_id, 1, part1_csv) streams.upload_part(stream_id, execution_id, 2, part2_csv) # Upload from a gzip file (memory-efficient for large files) # streams.upload_gzip_part_from_file(stream_id, execution_id, 3, './data.csv', stream_file=True, chunk_size=8192) # 6. Commit the Execution to finalize the upload committed = streams.commit_execution(stream_id, execution_id) print(f"Committed execution {committed['id']}") # 7. Abort a specific execution execution2 = streams.create_execution(stream_id) streams.abort_execution(stream_id, execution2['id']) # 8. Abort whatever execution is currently running streams.create_execution(stream_id) streams.abort_current_execution(stream_id) # 9. List executions for audit/inspection exec_list = streams.list_executions(stream_id, limit=10, offset=0) print(f"Execution history: {len(exec_list)} entries") # 10. Delete Stream (DataSet remains) streams.delete(stream_id) domo.datasets.delete(ds_id) ``` -------------------------------- ### Utilities Client Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Provides utility methods for schema translation and stream upload orchestration, powering dataset creation and updates. ```APIDOC ## `domo.utilities.domo_schema` — Inspect Domo-side schema ### Description Retrieves the schema definition for a given Domo DataSet. ### Method `domo_schema(dataset_id)` ### Parameters - **dataset_id** (str) - Required - The ID of the Domo DataSet. ### Request Example ```python domo_schema = utils.domo_schema('2f09a073-54a4-4269-8c62-b776e67d59f0') ``` ### Response #### Success Response (200) - A list of dictionaries, where each dictionary describes a column in the Domo schema, including its `type` and `name`. ### Response Example ```json [ {"type": "STRING", "name": "Region"}, {"type": "DOUBLE", "name": "Revenue"}, {"type": "DATETIME", "name": "Date"} ] ``` ``` ```APIDOC ## `domo.utilities.data_schema` — Derive Domo schema from pandas DataFrame ### Description Infers a Domo-compatible schema definition from a pandas DataFrame. ### Method `data_schema(dataframe)` ### Parameters - **dataframe** (pd.DataFrame) - Required - The pandas DataFrame from which to derive the schema. ### Request Example ```python df = pd.DataFrame({'Name': ['Alice'], 'Score': [95.5], 'Date': pd.to_datetime(['2024-01-01'])}) data_schema = utils.data_schema(df) ``` ### Response #### Success Response (200) - A list of dictionaries, where each dictionary represents a column's schema, including its `type` and `name`. ### Response Example ```json [ {"type": "STRING", "name": "Name"}, {"type": "DOUBLE", "name": "Score"}, {"type": "DATETIME", "name": "Date"} ] ``` ``` ```APIDOC ## `domo.utilities.type_conversion_text` — Convert pandas dtype to Domo type string ### Description Converts a pandas DataFrame column's data type (dtype) into its corresponding Domo type string representation. ### Method `type_conversion_text(dtype)` ### Parameters - **dtype** - Required - The pandas dtype object (e.g., from `df['column'].dtype`). ### Request Example ```python print(utils.type_conversion_text(df['Score'].dtype)) # Output: 'DOUBLE' ``` ### Response #### Success Response (200) - A string representing the Domo data type (e.g., 'STRING', 'DOUBLE', 'DATETIME'). ``` ```APIDOC ## `domo.utilities.convert_domo_type_to_pandas_type` — Convert Domo type string to pandas dtype ### Description Converts a Domo data type string into its corresponding pandas dtype. ### Method `convert_domo_type_to_pandas_type(domo_type)` ### Parameters - **domo_type** (str) - Required - The Domo data type string (e.g., 'LONG', 'STRING'). ### Request Example ```python print(utils.convert_domo_type_to_pandas_type('LONG')) # Output: 'Int64' ``` ### Response #### Success Response (200) - A string representing the pandas dtype (e.g., 'Int64', 'float64', 'object'). ``` ```APIDOC ## `domo.utilities.is_date_type` — Check if a type is a date type ### Description Determines if a given Domo data type string represents a date or time-related type. ### Method `is_date_type(domo_type)` ### Parameters - **domo_type** (str) - Required - The Domo data type string. ### Request Example ```python print(utils.is_date_type('DATETIME')) # Output: True ``` ### Response #### Success Response (200) - A boolean value: True if the type is a date type, False otherwise. ``` -------------------------------- ### Build Python package Source: https://github.com/domoinc/domo-python-sdk/blob/master/UPDATING_PYPI.md Build the Python package distribution files. This command creates a 'dist' directory containing wheel and tarball archives. ```bash python3 -m build ``` -------------------------------- ### Estimate Optimal Chunk Size for Large Upload Source: https://context7.com/domoinc/domo-python-sdk/llms.txt Use this utility to estimate the optimal number of rows per chunk for large data uploads to Domo, helping to optimize performance. ```python large_df = pd.DataFrame({'x': range(500_000)}) chunk_size = utils.estimate_chunk_rows(large_df, kbytes=10000) print(f"Upload in chunks of ~{chunk_size} rows") ``` -------------------------------- ### Run Specific Test Method Source: https://github.com/domoinc/domo-python-sdk/blob/master/tests/README.md Execute a single test method within a specific test class. Provide the full path to the file, class, and method. ```bash python -m unittest tests.test_utilities_type_conversion.TestUtilitiesTypeConversion.test_datetime_types -v ```