### Running the Authentication Webserver Source: https://context7.com/benhoyle/netdocs/llms.txt How to start the built-in Flask webserver for the OAuth flow. ```APIDOC ## Running the Authentication Webserver Start the built-in Flask webserver to initiate the OAuth flow and retrieve access tokens. ```bash # Start the authentication webserver python -m netdocs.webserver # Then navigate to https://localhost:3000/ndsetup in your browser # After authorization, tokens are automatically saved to .netdocs config file ``` ``` -------------------------------- ### Install netdocs package Source: https://github.com/benhoyle/netdocs/blob/master/README.md Install the library using pip. ```bash pip install netdocs ``` -------------------------------- ### Configuration Setup Source: https://context7.com/benhoyle/netdocs/llms.txt Configuration file setup for NetDocs, including client parameters and URLs. ```APIDOC ## Configuration Setup Create a `.netdocs` configuration file in your home directory with your NetDocuments API credentials and endpoint URLs. ```ini [Client Parameters] c_id = your_client_id_here c_secret = your_client_secret_here scope = read access_token = refresh_token = [URLs] auth_url = https://vault.netvoyage.com/neWeb2/OAuth.aspx redirect_uri = https://localhost:3000/gettoken refresh_url = https://api.vault.netvoyage.com/v1/OAuth base_url = https://api.vault.netvoyage.com ``` ``` -------------------------------- ### Run authentication webserver Source: https://github.com/benhoyle/netdocs/blob/master/README.md Start the local webserver to authorize the application and retrieve access tokens. ```bash python -m netdocs.webserver ``` -------------------------------- ### Complete NetDocs Workflow Example Source: https://context7.com/benhoyle/netdocs/llms.txt Demonstrates initializing the client, authenticating, listing cabinets, and retrieving recent uploads with detailed document information. Assumes credentials are set up in ~/.netdocs. ```python from netdocs import NetDocs def main(): # Initialize client (loads credentials from ~/.netdocs) nd = NetDocs() # Get current user info status, user = nd.get_user_data() if status != 200: print(f"Authentication failed: {user}") return print(f"Logged in as: {user['email']}") # List all accessible cabinets status, cabinets = nd.get_cabinets() if status != 200: print(f"Failed to get cabinets: {cabinets}") return print(f"\nAccessible cabinets ({len(cabinets)}):") for cab in cabinets: print(f" - {cab.get('name', 'Unnamed')} (ID: {cab['id']})") # Get recent uploads from last 14 days uploads = nd.get_uploads(withindays=14) if isinstance(uploads, list) and uploads: print(f"\nRecent uploads ({len(uploads)} documents):") for doc in uploads[:3]: print(f" - {doc.get('name')}") # Get detailed info for first document doc_status, doc_info = nd.get_doc_info(doc.get('envId')) if doc_status == 200: print(f" Size: {doc_info.get('size', 0)} bytes") print(f" Modified: {doc_info.get('lastMod')}") if __name__ == "__main__": main() ``` -------------------------------- ### GET /cabinets Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve a list of all document cabinets accessible to the authenticated user. ```APIDOC ## GET /cabinets ### Description Retrieve a list of all document cabinets accessible to the authenticated user. ### Method GET ### Endpoint /cabinets ### Parameters None ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the cabinet. - **name** (string) - The name of the cabinet. #### Response Example ```json [ { "id": "NG-1234567", "name": "Main Cabinet" }, { "id": "NG-7654321", "name": "Archive Cabinet" } ] ``` ``` -------------------------------- ### Configuration File Setup (.ini) Source: https://context7.com/benhoyle/netdocs/llms.txt Create a .netdocs configuration file in your home directory with your NetDocuments API credentials and endpoint URLs. Ensure all sensitive information is kept secure. ```ini [Client Parameters] c_id = your_client_id_here c_secret = your_client_secret_here scope = read access_token = refresh_token = [URLs] auth_url = https://vault.netvoyage.com/neWeb2/OAuth.aspx redirect_uri = https://localhost:3000/gettoken refresh_url = https://api.vault.netvoyage.com/v1/OAuth base_url = https://api.vault.netvoyage.com ``` -------------------------------- ### Run Authentication Webserver (Bash) Source: https://context7.com/benhoyle/netdocs/llms.txt Start the built-in Flask webserver to initiate the OAuth flow. After authorization via your browser, tokens are automatically saved to the .netdocs config file. ```bash # Start the authentication webserver python -m netdocs.webserver # Then navigate to https://localhost:3000/ndsetup in your browser # After authorization, tokens are automatically saved to .netdocs config file ``` -------------------------------- ### GET /make_query Source: https://context7.com/benhoyle/netdocs/llms.txt Executes a custom API query with automatic token refresh on 401 errors. ```APIDOC ## GET /make_query ### Description Execute a custom API query with automatic token refresh on 401 errors. ### Parameters - **url_portion** (string) - Required - The API endpoint path. - **params** (dict) - Optional - Query parameters to include in the request. ``` -------------------------------- ### NetDocs API methods Source: https://github.com/benhoyle/netdocs/blob/master/README.md Example methods for retrieving user data, cabinet information, and document or folder details. ```python # Get information on current user info = nd.get_user_data() # Get information on available cabinets cabinets = nd.get_cabinents() # Get information on a document with id [docid] docinfo = nd.get_doc_info(docid) # Get information on a folder with id [folderid] folderinfo = nd.get_folder_info(folderid) # Get contents of a folder with id [folderid] foldercontents = folder_content(folderid) ``` -------------------------------- ### GET /user Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve information about the currently authenticated user including email and account details. ```APIDOC ## GET /user ### Description Retrieve information about the currently authenticated user including email and account details. ### Method GET ### Endpoint /user ### Parameters None ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **email** (string) - The email address of the authenticated user. - **id** (string) - The unique identifier for the user. #### Response Example ```json { "email": "user@example.com", "id": "US-12345678" } ``` ``` -------------------------------- ### GET /folders/{folderid} Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve metadata and properties of a specific folder by its folder ID. ```APIDOC ## GET /folders/{folderid} ### Description Retrieve metadata and properties of a specific folder by its folder ID. ### Method GET ### Endpoint /folders/{folderid} ### Parameters #### Path Parameters - **folderid** (string) - Required - The unique identifier of the folder. ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **name** (string) - The name of the folder. - **envId** (string) - The environment ID of the folder. - **parent** (string) - The ID of the parent folder. #### Response Example ```json { "name": "Project Documents", "envId": "ABCD-1234-EFGH", "parent": "NG-1234567" } ``` ``` -------------------------------- ### GET /get_savedsearch Source: https://context7.com/benhoyle/netdocs/llms.txt Executes a saved search by its ID and retrieves the results. ```APIDOC ## GET /get_savedsearch ### Description Execute a saved search by its ID and retrieve the results. ### Parameters - **ssid** (string) - Required - The unique ID of the saved search. ``` -------------------------------- ### Get Folder Info by ID (Python) Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve metadata and properties of a specific folder using its folder ID. Displays folder name, environment ID, and parent folder ID. Includes error handling for failed requests. ```python from netdocs import NetDocs nd = NetDocs() folder_id = "ABCD-1234-EFGH" status_code, folder_info = nd.get_folder_info(folder_id) if status_code == 200: print(f"Folder Name: {folder_info.get('name')}") print(f"Folder ID: {folder_info.get('envId')}") print(f"Parent: {folder_info.get('parent')}") else: print(f"Error retrieving folder: {status_code} - {folder_info}") # Expected output: # Folder Name: Project Documents # Folder ID: ABCD-1234-EFGH # Parent: NG-1234567 ``` -------------------------------- ### GET /get_homepage_searches Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieves the IDs of all saved searches configured on the user's homepage. ```APIDOC ## GET /get_homepage_searches ### Description Retrieve the IDs of all saved searches configured on the user's homepage. ``` -------------------------------- ### Get Cabinets List (Python) Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve a list of all document cabinets accessible to the authenticated user. Iterates through the list and prints cabinet IDs and names, handling cases where names might be missing. ```python from netdocs import NetDocs nd = NetDocs() status_code, cabinets = nd.get_cabinets() if status_code == 200: for cabinet in cabinets: print(f"Cabinet ID: {cabinet['id']}") print(f"Cabinet Name: {cabinet.get('name', 'N/A')}") print("---") else: print(f"Error: {status_code} - {cabinets}") # Expected output: # Cabinet ID: NG-1234567 # Cabinet Name: Main Cabinet # --- # Cabinet ID: NG-7654321 # Cabinet Name: Archive Cabinet # --- ``` -------------------------------- ### GET /folders/{folderid}/content Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve the contents of a folder including all documents and subfolders within it. ```APIDOC ## GET /folders/{folderid}/content ### Description Retrieve the contents of a folder including all documents and subfolders within it. ### Method GET ### Endpoint /folders/{folderid}/content ### Parameters #### Path Parameters - **folderid** (string) - Required - The unique identifier of the folder. #### Query Parameters - **attributes** (boolean) - Optional - If true, include detailed attributes for each item. Defaults to true. ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **documents** (array) - A list of documents within the folder. - **id** (string) - Document ID. - **name** (string) - Document name. - **folders** (array) - A list of subfolders within the folder. - **id** (string) - Folder ID. - **name** (string) - Folder name. #### Response Example ```json { "documents": [ { "id": "DOC-1111-2222", "name": "Report.docx" } ], "folders": [ { "id": "SUB-FOLDER-ID", "name": "Subfolder Name" } ] } ``` ``` -------------------------------- ### GET /get_uploads Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieves all documents uploaded within a specified number of days across all accessible cabinets. ```APIDOC ## GET /get_uploads ### Description Retrieve all documents uploaded within a specified number of days. ### Parameters - **withindays** (integer) - Optional - The number of days to look back (default is 30). ``` -------------------------------- ### GET /documents/{docid} Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve detailed information about a specific document by its document ID. ```APIDOC ## GET /documents/{docid} ### Description Retrieve detailed information about a specific document by its document ID. ### Method GET ### Endpoint /documents/{docid} ### Parameters #### Path Parameters - **docid** (string) - Required - The unique identifier of the document. ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **name** (string) - The name of the document. - **extension** (string) - The file extension of the document. - **created** (string) - The creation timestamp of the document (ISO 8601 format). - **lastMod** (string) - The last modification timestamp of the document (ISO 8601 format). - **size** (integer) - The size of the document in bytes. #### Response Example ```json { "name": "Contract_2024.pdf", "extension": "pdf", "created": "2024-01-15T10:30:00Z", "lastMod": "2024-01-20T14:45:00Z", "size": 245678 } ``` ``` -------------------------------- ### Retrieve recent uploads Source: https://context7.com/benhoyle/netdocs/llms.txt Gets documents uploaded within a specified timeframe across all accessible cabinets. ```python from netdocs import NetDocs nd = NetDocs() # Get all uploads from the last 7 days recent_uploads = nd.get_uploads(withindays=7) if isinstance(recent_uploads, list): print(f"Found {len(recent_uploads)} recent uploads:") for doc in recent_uploads[:5]: # Show first 5 print(f" - {doc.get('name')} (Modified: {doc.get('lastMod')})") else: print(f"Error retrieving uploads") ``` -------------------------------- ### Get User Data (Python) Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve information about the currently authenticated user, including email and account details. Handles potential errors by checking the status code. ```python from netdocs import NetDocs nd = NetDocs() status_code, user_info = nd.get_user_data() if status_code == 200: print(f"User Email: {user_info['email']}") print(f"User ID: {user_info.get('id')}") else: print(f"Error: {status_code} - {user_info}") # Expected output: # User Email: user@example.com # User ID: US-12345678 ``` -------------------------------- ### Get Folder Contents (Python) Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve the contents of a folder, including all documents and subfolders within it. The 'attributes' parameter defaults to True, indicating that detailed attributes should be returned. ```python from netdocs import NetDocs nd = NetDocs() folder_id = "ABCD-1234-EFGH" ``` -------------------------------- ### GET /get_folder_id Source: https://context7.com/benhoyle/netdocs/llms.txt Searches for a folder ID based on cabinet, case reference, and folder name. ```APIDOC ## GET /get_folder_id ### Description Search for and retrieve a folder ID based on cabinet, case reference, and folder name. ### Parameters - **cabinet_id** (string) - Required - The ID of the cabinet. - **caseref** (string) - Required - The case reference string. - **foldername** (string) - Required - The name of the folder to search for. ``` -------------------------------- ### GET /folder_content Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieves the contents of a specific folder, including standard attributes for items within the folder. ```APIDOC ## GET /folder_content ### Description Retrieves the contents of a folder identified by its ID. ### Parameters #### Path Parameters - **folder_id** (string) - Required - The unique identifier of the folder. #### Query Parameters - **attributes** (boolean) - Optional - Whether to include standard attributes for the items. ``` -------------------------------- ### Get Document Info by ID (Python) Source: https://context7.com/benhoyle/netdocs/llms.txt Retrieve detailed information about a specific document using its unique document ID. Displays document name, type, creation, modification times, and size. Includes error handling for failed requests. ```python from netdocs import NetDocs nd = NetDocs() doc_id = "1234-5678-9012" status_code, doc_info = nd.get_doc_info(doc_id) if status_code == 200: print(f"Document Name: {doc_info.get('name')}") print(f"Document Type: {doc_info.get('extension')}") print(f"Created: {doc_info.get('created')}") print(f"Modified: {doc_info.get('lastMod')}") print(f"Size: {doc_info.get('size')}") else: print(f"Error retrieving document: {status_code} - {doc_info}") # Expected output: # Document Name: Contract_2024.pdf # Document Type: pdf # Created: 2024-01-15T10:30:00Z # Modified: 2024-01-20T14:45:00Z # Size: 245678 bytes ``` -------------------------------- ### Initialize NetDocs Client (Python) Source: https://context7.com/benhoyle/netdocs/llms.txt Create a NetDocs client instance. It automatically loads configuration from the default ~/.netdocs file or a specified custom path. ```python from netdocs import NetDocs # Initialize with default config from ~/.netdocs nd = NetDocs() # Or specify a custom config file path nd = NetDocs(path_to_config="/path/to/custom/.netdocs") ``` -------------------------------- ### Configure .netdocs file Source: https://github.com/benhoyle/netdocs/blob/master/README.md Create a .netdocs configuration file in your home directory with your client credentials and API URLs. ```ini [Client Parameters] c_id = [Paste your client id here] c_secret = [Paste your client secret here] scope = read [select from 'read', 'edit', 'organize', 'lookup', 'delete_doc', 'delete_container', 'full'] access_token = [Leave blank - will be retrieved] refresh_token = [Leave blank - will be retrieved] [URLs] auth_url = https://vault.netvoyage.com/neWeb2/OAuth.aspx redirect_uri = https://localhost:3000/gettoken [Register this in your App configuration - you can use a different uri if required] refresh_url = https://api.vault.netvoyage.com/v1/OAuth base_url = https://api.vault.netvoyage.com ``` -------------------------------- ### Initialize NetDocs client Source: https://github.com/benhoyle/netdocs/blob/master/README.md Import the NetDocs class and initialize the client instance. ```python from netdocs import NetDocs nd = NetDocs() ``` -------------------------------- ### Initializing the NetDocs Client Source: https://context7.com/benhoyle/netdocs/llms.txt How to initialize the NetDocs client, with options for default or custom configuration paths. ```APIDOC ## Initializing the NetDocs Client Create a NetDocs instance that automatically loads configuration and handles authentication. ```python from netdocs import NetDocs # Initialize with default config from ~/.netdocs nd = NetDocs() # Or specify a custom config file path nd = NetDocs(path_to_config="/path/to/custom/.netdocs") ``` ``` -------------------------------- ### SSL Certificate Generation Source: https://context7.com/benhoyle/netdocs/llms.txt Instructions for generating a self-signed SSL certificate for the OAuth webserver. ```APIDOC ## SSL Certificate Generation Generate a self-signed certificate for the OAuth webserver to handle HTTPS connections required by NetDocuments. ```bash # Generate self-signed certificate and key (valid for 365 days) openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout ~/domain.key -out ~/domain.crt ``` ``` -------------------------------- ### Generate SSL Certificate (Bash) Source: https://context7.com/benhoyle/netdocs/llms.txt Generate a self-signed SSL certificate and key for the OAuth webserver. This is required for HTTPS connections needed by NetDocuments. The certificate is valid for 365 days. ```bash # Generate self-signed certificate and key (valid for 365 days) openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout ~/domain.key -out ~/domain.crt ``` -------------------------------- ### Generate self-signed SSL certificate Source: https://github.com/benhoyle/netdocs/blob/master/README.md Generate a self-signed certificate and key required for the local authentication webserver. ```bash openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout domain.key -out domain.crt ``` -------------------------------- ### Retrieve folder contents Source: https://context7.com/benhoyle/netdocs/llms.txt Fetches items within a specific folder and iterates through the results to identify folders and documents. ```python status_code, contents = nd.folder_content(folder_id, attributes=True) if status_code == 200: print(f"Items in folder: {len(contents.get('list', []))}") for item in contents.get('list', []): item_type = "Folder" if item.get('isContainer') else "Document" print(f" [{item_type}] {item.get('name')} (ID: {item.get('envId')})") else: print(f"Error: {status_code} - {contents}") ``` -------------------------------- ### Execute custom API query Source: https://context7.com/benhoyle/netdocs/llms.txt Performs a custom API request with automatic token refresh handling for 401 errors. ```python from netdocs import NetDocs import urllib nd = NetDocs() # Custom search query cabinet_id = "NG-1234567" url_portion = f"/v1/Search/{cabinet_id}" query = "contract" params = urllib.parse.urlencode({ 'q': query, '$select': 'standardAttributes', '$orderby': 'lastMod desc' }) status_code, response = nd.make_query(url_portion, params) if status_code == 200: print(f"Found {len(response.get('list', []))} documents matching '{query}'") for doc in response.get('standardList', []): print(f" - {doc.get('name')}") else: print(f"Query failed: {status_code} - {response}") ``` -------------------------------- ### Retrieve folder ID Source: https://context7.com/benhoyle/netdocs/llms.txt Searches for a folder ID using cabinet, case reference, and folder name parameters. ```python from netdocs import NetDocs nd = NetDocs() cabinet_id = "NG-1234567" case_reference = "CASE-2024-001" folder_name = "Correspondence" result = nd.get_folder_id(cabinet_id, case_reference, folder_name) if isinstance(result, str): # Single folder found - returns the folder ID print(f"Found folder ID: {result}") else: status_code, response = result print(f"Error or multiple results: {status_code} - {response}") ``` -------------------------------- ### Execute saved search Source: https://context7.com/benhoyle/netdocs/llms.txt Runs a saved search by its ID and processes the returned document list. ```python from netdocs import NetDocs nd = NetDocs() saved_search_id = "SS-12345" status_code, results = nd.get_savedsearch(saved_search_id) if status_code == 200: print(f"Search returned {len(results.get('list', []))} results") for doc in results.get('list', []): print(f" - {doc.get('name')}") else: print(f"Error: {status_code} - {results}") ``` -------------------------------- ### Retrieve homepage searches Source: https://context7.com/benhoyle/netdocs/llms.txt Fetches a list of saved search IDs configured on the user's homepage. ```python from netdocs import NetDocs nd = NetDocs() search_ids = nd.get_homepage_searches() if isinstance(search_ids, list): print(f"Found {len(search_ids)} homepage searches:") for search_id in search_ids: print(f" - {search_id}") else: status_code, error = search_ids print(f"Error: {status_code} - {error}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.