### GET - List and Query Resources Source: https://context7.com/vast-data/vastpy/llms.txt Explains how to use the GET method to retrieve resources, including filtering by keyword arguments and selecting specific fields. ```APIDOC ## GET - List and Query Resources The GET method retrieves resources from the VMS API. It supports filtering by passing keyword arguments and can select specific fields to return. ```python from vastpy import VASTClient client = VASTClient(address='vast-vms-hostname', token='your-token') # List all views views = client.views.get() for view in views: print(f"View: {view['path']}") # Filter views by name filtered_views = client.views.get(name='production') # List snapshots with specific fields only snapshots = client.snapshots.get(fields=['id', 'path']) for snapshot in snapshots: print(f"ID: {snapshot['id']}, Path: {snapshot['path']}") # Get view policies filtered by name policies = client.viewpolicies.get(name='default') default_policy = policies[0] print(f"Policy ID: {default_policy['id']}") # Query protocol metrics with monitoring endpoint metrics = client.monitors.ad_hoc_query.get( object_type='cluster', time_frame='5m', prop_list=[ 'ProtoMetrics,proto_name=ProtoCommon,iops', # Aggregated IOPS 'ProtoMetrics,proto_name=ProtoCommon,bw', # Aggregated bandwidth 'ProtoMetrics,proto_name=NFS,iops', # NFS-specific IOPS 'ProtoMetrics,proto_name=SMB,bw', # SMB-specific bandwidth 'ProtoMetrics,proto_name=S3,latency' # S3 protocol latency ] ) ``` ``` -------------------------------- ### Install VASTPY Source: https://github.com/vast-data/vastpy/blob/main/README.md Install the package via pip. ```bash pip install vastpy ``` -------------------------------- ### Create Snapshot and API Token Source: https://context7.com/vast-data/vastpy/llms.txt Examples of creating a new snapshot and generating an API token using the VASTpy client. ```APIDOC ## POST /api/snapshots ### Description Creates a new snapshot for a specified path. ### Method POST ### Endpoint /api/snapshots ### Parameters #### Query Parameters - **path** (string) - Required - The path for which to create the snapshot. - **name** (string) - Required - The name of the snapshot. ### Request Example ```python snapshot = client.snapshots.post( path='/prod/pgsql', name='db_backup' ) print(f"Created snapshot: {snapshot['name']} at {snapshot['path']}") ``` ## POST /api/apitokens ### Description Generates a new API token for a specified owner. ### Method POST ### Endpoint /api/apitokens ### Parameters #### Query Parameters - **owner** (string) - Required - The owner of the API token. ### Request Example ```python token_response = client.apitokens.post(owner='automation-user') print(f"Token: {token_response['token']}") ``` ``` -------------------------------- ### CLI - Basic Operations Source: https://context7.com/vast-data/vastpy/llms.txt Guide to performing basic operations using the vastpy-cli command-line tool. ```APIDOC ## vastpy-cli - Basic Operations ### Description The `vastpy-cli` tool allows command-line interaction with the VMS API. Credentials can be configured via environment variables or command-line arguments. ### Configuration Set credentials via environment variables: ```bash export VMS_USER=admin export VMS_PASSWORD=your_password export VMS_ADDRESS=vast-vms-hostname export VMS_TOKEN=your-api-token # Alternative to user/password (VAST 5.3+) export VMS_TENANT_NAME=tenant-name # Optional: for multi-tenant export VMS_API_VERSION=latest # Optional: API version ``` ### Usage Examples - **List all snapshots:** ```bash vastpy-cli get snapshots ``` - **List snapshots with specific fields:** ```bash vastpy-cli get snapshots fields=id,path # Output: # [ # {"path": "/dbs", "id": 12}, # {"path": "/datasets", "id": 43} # ] ``` - **Create a new view:** ```bash vastpy-cli post views path=/prod/pgsql create_dir=true policy_id=1 # Output: # { # "id": 109, # "guid": "551b5fc0-42a2-4b77-b385-d5bf6a6c1538", # "name": "view-109", # "title": "/prod/pgsql" # } ``` - **Create a snapshot:** ```bash vastpy-cli post snapshots path=/prod/pgsql name=db ``` - **Delete a view by ID:** ```bash vastpy-cli delete views/109 ``` - **Using command-line arguments for credentials:** ```bash vastpy-cli --user=admin --password=secret --address=vms.example.com get views ``` ``` -------------------------------- ### List and Query Resources with GET Source: https://context7.com/vast-data/vastpy/llms.txt Retrieves resources using filtering and field selection. Supports complex ad-hoc queries for metrics. ```python from vastpy import VASTClient client = VASTClient(address='vast-vms-hostname', token='your-token') # List all views views = client.views.get() for view in views: print(f"View: {view['path']}") # Filter views by name filtered_views = client.views.get(name='production') # List snapshots with specific fields only snapshots = client.snapshots.get(fields=['id', 'path']) for snapshot in snapshots: print(f"ID: {snapshot['id']}, Path: {snapshot['path']}") # Get view policies filtered by name policies = client.viewpolicies.get(name='default') default_policy = policies[0] print(f"Policy ID: {default_policy['id']}") # Query protocol metrics with monitoring endpoint metrics = client.monitors.ad_hoc_query.get( object_type='cluster', time_frame='5m', prop_list=[ 'ProtoMetrics,proto_name=ProtoCommon,iops', # Aggregated IOPS 'ProtoMetrics,proto_name=ProtoCommon,bw', # Aggregated bandwidth 'ProtoMetrics,proto_name=NFS,iops', # NFS-specific IOPS 'ProtoMetrics,proto_name=SMB,bw', # SMB-specific bandwidth 'ProtoMetrics,proto_name=S3,latency' # S3 protocol latency ] ) ``` -------------------------------- ### Remove Resources (DELETE) Source: https://context7.com/vast-data/vastpy/llms.txt Examples of deleting resources such as views and snapshots using the DELETE method. ```APIDOC ## DELETE /api/views/{id} ### Description Deletes a specific view by its ID. ### Method DELETE ### Endpoint /api/views/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the view to delete. ### Request Example ```python # Get the view to delete views = client.views.get(path='/prod/pgsql') view = views[0] # Delete the view by ID client.views[view['id']].delete() print(f"Deleted view: {view['id']}") ``` ## DELETE /api/snapshots/{id} ### Description Deletes a specific snapshot by its ID. ### Method DELETE ### Endpoint /api/snapshots/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the snapshot to delete. ### Request Example ```python # Delete a snapshot snapshots = client.snapshots.get(name='old_backup') if snapshots: client.snapshots[snapshots[0]['id']].delete() ``` ``` -------------------------------- ### GET /monitors/ad_hoc_query Source: https://github.com/vast-data/vastpy/blob/main/README.md Queries protocol and cluster metrics for monitoring purposes. ```APIDOC ## GET /monitors/ad_hoc_query ### Description Performs an ad-hoc query for cluster or protocol metrics. ### Method GET ### Endpoint /monitors/ad_hoc_query ### Parameters #### Query Parameters - **object_type** (string) - Required - The type of object to query (e.g., 'cluster'). - **time_frame** (string) - Required - The time range for the metrics (e.g., '5m'). - **prop_list** (array) - Required - List of properties/metrics to retrieve. ``` -------------------------------- ### Create Snapshots and API Tokens Source: https://context7.com/vast-data/vastpy/llms.txt Demonstrates creating a snapshot and generating an API token using the VASTClient. ```python # Create a new snapshot snapshot = client.snapshots.post( path='/prod/pgsql', name='db_backup' ) print(f"Created snapshot: {snapshot['name']} at {snapshot['path']}") # Generate API token for a user token_response = client.apitokens.post(owner='automation-user') print(f"Token: {token_response['token']}") ``` -------------------------------- ### Initialize VASTClient with Username/Password Source: https://context7.com/vast-data/vastpy/llms.txt Compatible with all VAST versions. Supports custom SSL certificate configuration. ```python from vastpy import VASTClient # Initialize with username and password (all VAST versions) client = VASTClient( user='admin', password='your_password', address='vast-vms-hostname', tenant='tenant-name', # Optional: for multi-tenant environments version='api-version' # Optional: defaults to oldest API when using password auth ) # Initialize with custom SSL certificate client = VASTClient( user='admin', password='your_password', address='vast-vms-hostname', cert_file='/path/to/custom-cert.pem', cert_server_name='cert-authority-hostname' ) ``` -------------------------------- ### Initialize VASTClient with API Token Source: https://context7.com/vast-data/vastpy/llms.txt Recommended authentication method for VAST 5.3 or later. Supports optional tenant and API version parameters. ```python from vastpy import VASTClient # Initialize with API token (VAST 5.3+) client = VASTClient( address='vast-vms-hostname', token='your-api-token', tenant='tenant-name', # Optional: for multi-tenant environments version='latest' # Optional: API version, defaults to 'latest' ) # Access any endpoint using attribute or item syntax print(client.views) # VASTClient(address="vast-vms-hostname", url="api/latest/views") print(client['snapshots']) # VASTClient(address="vast-vms-hostname", url="api/latest/snapshots") ``` -------------------------------- ### POST - Create New Resources Source: https://context7.com/vast-data/vastpy/llms.txt Details how to use the POST method to create new resources in the VMS, with parameters passed as keyword arguments in the JSON request body. ```APIDOC ## POST - Create New Resources The POST method creates new resources in the VMS. All parameters are passed as keyword arguments and sent as JSON in the request body. ```python from vastpy import VASTClient client = VASTClient(address='vast-vms-hostname', token='your-token') # Create a new view with default policy policies = client.viewpolicies.get(name='default') default_policy = policies[0] view = client.views.post( path='/prod/pgsql', policy_id=default_policy['id'], create_dir=True ) print(f"Created view with ID: {view['id']}") ``` ``` -------------------------------- ### Initialize VASTClient Source: https://github.com/vast-data/vastpy/blob/main/README.md Initialize the client using either an API token or username and password credentials. ```python from vastpy import VASTClient # Initialize with a token client = VASTClient( address='vast-vms-hostname', token='api-token', tenant='tenant-name', # An optional field, supported for VAST versions 5.3 and later version='api-version' # An optional field, defaults to latest API ) ``` ```python from vastpy import VASTClient # Initialize with a username + password client = VASTClient( user='your_username', password='your_password', address='vast-vms-hostname', tenant='tenant-name', # An optional field, supported for VAST versions 5.3 and later version='api-version' # An optional field, defaults to oldest API ) ``` -------------------------------- ### Create View Configuration via CLI Source: https://context7.com/vast-data/vastpy/llms.txt Defines a view configuration in a JSON file and applies it using the CLI. ```bash cat > view-config.json << 'EOF' { "path": "/prod/database", "policy_id": 1, "create_dir": true, "protocols": ["NFS", "SMB"], "nfs_no_squash": ["10.0.0.0/8"] } EOF vastpy-cli post views --file-input view-config.json ``` -------------------------------- ### VASTClient Initialization with API Token Source: https://context7.com/vast-data/vastpy/llms.txt Initializes the VASTClient using an API token. This method is recommended for VAST 5.3+. ```APIDOC ## VASTClient - Initialize Client with API Token The VASTClient class is the main entry point for interacting with the VMS REST API. Token authentication is supported in VAST 5.3 or later and is the recommended authentication method. ```python from vastpy import VASTClient # Initialize with API token (VAST 5.3+) client = VASTClient( address='vast-vms-hostname', token='your-api-token', tenant='tenant-name', # Optional: for multi-tenant environments version='latest' # Optional: API version, defaults to 'latest' ) # Access any endpoint using attribute or item syntax print(client.views) # VASTClient(address="vast-vms-hostname", url="api/latest/views") print(client['snapshots']) # VASTClient(address="vast-vms-hostname", url="api/latest/snapshots") ``` ``` -------------------------------- ### VASTClient Initialization with Username/Password Source: https://context7.com/vast-data/vastpy/llms.txt Initializes the VASTClient using username and password. This method works with all VAST versions and can also be used to generate API tokens. ```APIDOC ## VASTClient - Initialize Client with Username/Password Username and password authentication works with all VAST versions. This method can also be used to generate API tokens for subsequent requests. ```python from vastpy import VASTClient # Initialize with username and password (all VAST versions) client = VASTClient( user='admin', password='your_password', address='vast-vms-hostname', tenant='tenant-name', # Optional: for multi-tenant environments version='api-version' # Optional: defaults to oldest API when using password auth ) # Initialize with custom SSL certificate client = VASTClient( user='admin', password='your_password', address='vast-vms-hostname', cert_file='/path/to/custom-cert.pem', cert_server_name='cert-authority-hostname' ) ``` ``` -------------------------------- ### Manage Snapshots Source: https://github.com/vast-data/vastpy/blob/main/README.md List and create snapshots using the VASTClient. ```python # List snapshots with specific fields snapshots = client.snapshots.get(fields=['id', 'path']) for snapshot in snapshots: print(f"ID: {snapshot['id']}, Path: {snapshot['path']}") # Create a new snapshot snapshot = client.snapshots.post(path='/prod/pgsql', name='db') ``` -------------------------------- ### CLI - JSON File Input Source: https://context7.com/vast-data/vastpy/llms.txt How to use JSON files for complex configurations with the vastpy-cli. ```APIDOC ## vastpy-cli - JSON File Input ### Description The `vastpy-cli` supports using JSON files for complex operations with nested parameters via the `--file-input` flag. ### Usage Example 1. **Create a JSON configuration file (e.g., `audit-config.json`):** ```json { "read_access_users": ["vastadmin"], "read_access_users_groups": ["vastadmin"], "protocols_audit": { "log_full_path": true, "modify_data_md": true, "create_delete_files_dirs_objects": true }, "enable_vast_db_audit": true } ``` 2. **Apply the configuration using JSON file input:** ```bash vastpy-cli patch clusters/1/auditing --file-input audit-config.json ``` ``` -------------------------------- ### Create Resources with POST Source: https://context7.com/vast-data/vastpy/llms.txt Creates new resources by passing parameters as keyword arguments, which are sent as JSON. ```python from vastpy import VASTClient client = VASTClient(address='vast-vms-hostname', token='your-token') # Create a new view with default policy policies = client.viewpolicies.get(name='default') default_policy = policies[0] view = client.views.post( path='/prod/pgsql', policy_id=default_policy['id'], create_dir=True ) print(f"Created view with ID: {view['id']}") ``` -------------------------------- ### Apply CLI Configuration via JSON File Source: https://context7.com/vast-data/vastpy/llms.txt Uses the --file-input flag to pass complex JSON configurations to the CLI. ```bash # Create a JSON configuration file cat > audit-config.json << 'EOF' { "read_access_users": ["vastadmin"], "read_access_users_groups": ["vastadmin"], "protocols_audit": { "log_full_path": true, "modify_data_md": true, "create_delete_files_dirs_objects": true }, "enable_vast_db_audit": true } EOF # Apply the configuration using JSON file input vastpy-cli patch clusters/1/auditing --file-input audit-config.json ``` -------------------------------- ### Retrieve Views as JSON via CLI Source: https://context7.com/vast-data/vastpy/llms.txt Fetches existing views and outputs the result in JSON format. ```bash vastpy-cli --json get views ``` -------------------------------- ### Generate API Token Source: https://context7.com/vast-data/vastpy/llms.txt Demonstrates how to generate an API token using username/password authentication, which can then be used for subsequent client connections. ```APIDOC ## Generate API Token API tokens can be generated using username/password authentication for use in subsequent requests. This is useful for creating long-lived tokens for automation. ```python from vastpy import VASTClient # First authenticate with username/password client = VASTClient( user='admin', password='your_password', address='vast-vms-hostname' ) # Generate an API token for a specific user token_response = client.apitokens.post(owner='admin') api_token = token_response['token'] print(f"Generated token: {api_token}") # Use the token for future connections token_client = VASTClient( address='vast-vms-hostname', token=api_token ) ``` ``` -------------------------------- ### Configure CLI Authentication Source: https://github.com/vast-data/vastpy/blob/main/README.md Set up authentication for the CLI using environment variables or command-line arguments. ```bash # Using environment variables export VMS_USER=admin export VMS_PASSWORD=your_password export VMS_ADDRESS=vast-vms-hostname export VMS_TOKEN=token # For VAST 5.3 and later, you can use a token instead of VMS_USER / VMS_PASSWORD export VMS_TENANT_NAME=tenant-name # An optional field, supported for VAST versions 5.3 and later export VMS_API_VERSION=api-version # An optional field, defaults to oldest API # Or using command-line arguments vastpy-cli --user=admin --password=your_password --address=vast-vms-hostname ``` -------------------------------- ### Execute CLI Operations Source: https://context7.com/vast-data/vastpy/llms.txt Performs basic VMS operations via the command line using environment variables or arguments. ```bash # Set credentials via environment variables export VMS_USER=admin export VMS_PASSWORD=your_password export VMS_ADDRESS=vast-vms-hostname export VMS_TOKEN=your-api-token # Alternative to user/password (VAST 5.3+) export VMS_TENANT_NAME=tenant-name # Optional: for multi-tenant export VMS_API_VERSION=latest # Optional: API version # List all snapshots vastpy-cli get snapshots # List snapshots with specific fields vastpy-cli get snapshots fields=id,path # Output: # [ # {"path": "/dbs", "id": 12}, # {"path": "/datasets", "id": 43} # ] # Create a new view vastpy-cli post views path=/prod/pgsql create_dir=true policy_id=1 # Output: # { # "id": 109, # "guid": "551b5fc0-42a2-4b77-b385-d5bf6a6c1538", # "name": "view-109", # "title": "/prod/pgsql" # } # Create a snapshot vastpy-cli post snapshots path=/prod/pgsql name=db # Delete a view by ID vastpy-cli delete views/109 # Using command-line arguments instead of environment variables vastpy-cli --user=admin --password=secret --address=vms.example.com get views ``` -------------------------------- ### Update Existing Resources (PATCH) Source: https://context7.com/vast-data/vastpy/llms.txt Demonstrates how to update existing resources like views and cluster auditing configurations using the PATCH method. ```APIDOC ## PATCH /api/views/{id} ### Description Updates an existing view with specified protocols. ### Method PATCH ### Endpoint /api/views/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the view to update. #### Request Body - **protocols** (array of strings) - Required - The new list of protocols for the view. ### Request Example ```python # Get a view to update views = client.views.get(path='/prod/pgsql') view_to_update = views[0] # Update the view's protocols updated_view = client.views[view_to_update['id']].patch( protocols=['NFS', 'SMB'] ) print(f"Updated view protocols: {updated_view['protocols']}") ``` ## PATCH /api/clusters/{id}/auditing ### Description Updates the auditing configuration for a specific cluster. ### Method PATCH ### Endpoint /api/clusters/{id}/auditing ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the cluster to update. #### Request Body - **read_access_users** (array of strings) - Optional - List of users with read access. - **read_access_users_groups** (array of strings) - Optional - List of user groups with read access. - **protocols_audit** (object) - Optional - Auditing configuration for protocols. - **log_full_path** (boolean) - Optional - Whether to log the full path. - **modify_data_md** (boolean) - Optional - Whether to log data metadata modifications. - **create_delete_files_dirs_objects** (boolean) - Optional - Whether to log file/directory/object creation/deletion. - **enable_vast_db_audit** (boolean) - Optional - Whether to enable VAST DB auditing. ### Request Example ```python client.clusters[cluster_id].auditing.patch( read_access_users=['vastadmin'], read_access_users_groups=['vastadmin'], protocols_audit={ 'log_full_path': True, 'modify_data_md': True, 'create_delete_files_dirs_objects': True }, enable_vast_db_audit=True ) ``` ``` -------------------------------- ### Translate Python SDK Calls to REST API Source: https://context7.com/vast-data/vastpy/llms.txt Demonstrates how Python SDK methods map directly to VAST REST API endpoints. ```python from vastpy import VASTClient client = VASTClient(address='vast-vms-hostname', token='your-token') # Python SDK calls map directly to REST API endpoints: # GET collection → GET /api/latest/collection/ client.views.get() # GET /api/latest/views/ client.snapshots.get(fields=['id']) # GET /api/latest/snapshots/?fields=id # GET specific object → GET /api/latest/collection/object/ client.views[109].get() # GET /api/latest/views/109/ # POST to collection → POST /api/latest/collection/ client.views.post(path='/data') # POST /api/latest/views/ # PATCH specific object → PATCH /api/latest/collection/object/ client.views[109].patch(name='new') # PATCH /api/latest/views/109/ # DELETE specific object → DELETE /api/latest/collection/object/ client.views[109].delete() # DELETE /api/latest/views/109/ # Nested endpoints work the same way client.monitors.ad_hoc_query.get() # GET /api/latest/monitors/ad_hoc_query/ client.clusters[1].auditing.patch() # PATCH /api/latest/clusters/1/auditing/ ``` -------------------------------- ### Manage Views Source: https://github.com/vast-data/vastpy/blob/main/README.md Perform CRUD operations on views using the VASTClient. ```python # List all views for view in client.views.get(): print(view) # Create a new view with the default policy policies = client.viewpolicies.get(name='default') default_policy = policies[0] # Get the first (and should be only) matching policy # Create a new view using the default policy view = client.views.post( path='/prod/pgsql', policy_id=default_policy['id'], # Use the policy's unique identifier create_dir=True ) # Update a view's protocols view_to_update = client.views.get(path='/prod/pgsql')[0] # Get the first matching view updated_view = client.views[view_to_update['id']].patch(protocols=['NFS', 'SMB']) # Delete a view client.views[view['id']].delete() ``` -------------------------------- ### Monitor Metrics Source: https://github.com/vast-data/vastpy/blob/main/README.md Query cluster and protocol metrics. ```python # Query protocol metrics metrics = client.monitors.ad_hoc_query.get( object_type='cluster', time_frame='5m', prop_list=[ 'ProtoMetrics,proto_name=ProtoCommon,iops', # Aggregated IOPS across protocols 'ProtoMetrics,proto_name=ProtoCommon,bw', # Aggregated bandwidth 'ProtoMetrics,proto_name=NFS,iops', # NFS-specific IOPS 'ProtoMetrics,proto_name=SMB,bw', # SMB-specific bandwidth 'ProtoMetrics,proto_name=S3,latency' # S3 protocol latency ] ) ``` -------------------------------- ### Update Resources with PATCH Source: https://context7.com/vast-data/vastpy/llms.txt Updates existing views and cluster auditing configurations using the PATCH method. ```python from vastpy import VASTClient client = VASTClient(address='vast-vms-hostname', token='your-token') # Get a view to update views = client.views.get(path='/prod/pgsql') view_to_update = views[0] # Update the view's protocols updated_view = client.views[view_to_update['id']].patch( protocols=['NFS', 'SMB'] ) print(f"Updated view protocols: {updated_view['protocols']}") # Update cluster auditing configuration cluster_id = 1 client.clusters[cluster_id].auditing.patch( read_access_users=['vastadmin'], read_access_users_groups=['vastadmin'], protocols_audit={ 'log_full_path': True, 'modify_data_md': True, 'create_delete_files_dirs_objects': True }, enable_vast_db_audit=True ) ``` -------------------------------- ### Snapshot Management Endpoints Source: https://github.com/vast-data/vastpy/blob/main/README.md Endpoints for listing and creating snapshots of paths. ```APIDOC ## GET /snapshots ### Description Lists snapshots, optionally filtering by specific fields. ### Method GET ### Endpoint /snapshots ### Parameters #### Query Parameters - **fields** (array) - Optional - List of fields to return in the response. ## POST /snapshots ### Description Creates a new snapshot for a given path. ### Method POST ### Endpoint /snapshots ### Parameters #### Request Body - **path** (string) - Required - The path to snapshot. - **name** (string) - Required - The name of the snapshot. ``` -------------------------------- ### Perform CLI Operations Source: https://github.com/vast-data/vastpy/blob/main/README.md Execute REST operations via the CLI tool. ```bash # List snapshots $ vastpy-cli get snapshots fields=id,path [ { "path": "/dbs", "id": 12 }, { "path": "/datasets", "id": 43 }, ... ] # Create a new view $ vastpy-cli post views path=/prod/pgsql create_dir=true policy_id=1 { "id": 109, "guid": "551b5fc0-42a2-4b77-b385-d5bf6a6c1538", "name": "view-109", "title": "/prod/pgsql", ... # Create a new snapshot $ vastpy-cli post snapshots path=/prod/pgsql name=db { "id": 4707792, "name": "db_snapshot", "path": "/prod/pgsql" ... ``` -------------------------------- ### Apply Complex Cluster Auditing Configuration with vastpy-cli Source: https://github.com/vast-data/vastpy/blob/main/README.md For complex operations, use JSON input files to patch cluster auditing configurations. Ensure the config.json file is correctly formatted with desired settings. ```bash # Create a file with your configuration $ cat > config.json << EOF { "read_access_users": ["vastadmin"], "read_access_users_groups": ["vastadmin"], "protocols_audit": { "log_full_path": true, "modify_data_md": true, "create_delete_files_dirs_objects": true }, "enable_vast_db_audit": true } EOF # Apply the configuration vastpy-cli patch clusters//auditing --file-input config.json ``` -------------------------------- ### View Management Endpoints Source: https://github.com/vast-data/vastpy/blob/main/README.md Endpoints for listing, creating, updating, and deleting views within the VAST storage system. ```APIDOC ## GET /views ### Description Lists all views configured in the system. ### Method GET ### Endpoint /views ## POST /views ### Description Creates a new view. ### Method POST ### Endpoint /views ### Parameters #### Request Body - **path** (string) - Required - The path for the new view. - **policy_id** (integer) - Required - The unique identifier of the view policy. - **create_dir** (boolean) - Optional - Whether to create the directory. ## PATCH /views/{id} ### Description Updates the properties of an existing view. ### Method PATCH ### Endpoint /views/{id} ### Parameters #### Request Body - **protocols** (array) - Optional - List of protocols to enable (e.g., NFS, SMB). ## DELETE /views/{id} ### Description Deletes a specific view by its ID. ### Method DELETE ### Endpoint /views/{id} ``` -------------------------------- ### Generate API Token Source: https://github.com/vast-data/vastpy/blob/main/README.md Generate an API token using existing credentials for use in future sessions. ```python # Authenticate with user + password client = VASTClient( user='your_username', password='your_password', address='vast-vms-hostname' ) # Generate an API token for a specific user token_response = client.apitokens.post(owner='username') token = token_response['token'] ``` -------------------------------- ### POST /apitokens Source: https://github.com/vast-data/vastpy/blob/main/README.md Generates an API token for a specific user, which can be used for subsequent authentication in VAST 5.3 and later. ```APIDOC ## POST /apitokens ### Description Generates an API token for a specific user. ### Method POST ### Endpoint /apitokens ### Parameters #### Request Body - **owner** (string) - Required - The username for which to generate the token. ### Response #### Success Response (200) - **token** (string) - The generated API token. ``` -------------------------------- ### VMS API Endpoint Mapping Source: https://github.com/vast-data/vastpy/blob/main/README.md This SDK translates Python object methods directly to REST API endpoints. Refer to the VMS API documentation on your VAST system for detailed endpoint information. ```python client.collection[object].get() → GET /api/collection/object ``` ```python client.collection.post() → POST /api/collection ``` ```python client.collection[object].patch() → PATCH /api/collection/object ``` ```python client.collection[object].delete() → DELETE /api/collection/object ``` -------------------------------- ### Remove Resources with DELETE Source: https://context7.com/vast-data/vastpy/llms.txt Deletes views and snapshots by their respective IDs. ```python from vastpy import VASTClient client = VASTClient(address='vast-vms-hostname', token='your-token') # Get the view to delete views = client.views.get(path='/prod/pgsql') view = views[0] # Delete the view by ID client.views[view['id']].delete() print(f"Deleted view: {view['id']}") # Delete a snapshot snapshots = client.snapshots.get(name='old_backup') if snapshots: client.snapshots[snapshots[0]['id']].delete() ``` -------------------------------- ### RESTFailure - Exception Handling Source: https://context7.com/vast-data/vastpy/llms.txt Details on handling API request failures using the RESTFailure exception. ```APIDOC ## RESTFailure Exception ### Description The `RESTFailure` exception is raised when API requests fail. It provides details about the error, including the method, URL, parameters, status code, and response data. ### Usage ```python from vastpy import VASTClient, RESTFailure client = VASTClient(address='vast-vms-hostname', token='your-token') try: # Attempt to create a view with invalid parameters view = client.views.post(path='/invalid/path') except RESTFailure as e: print(f"Request failed!") print(f"Method: {e.method}") print(f"URL: {e.url}") print(f"Parameters: {e.fields}") print(f"Status code: {e.status}") print(f"Error message: {e.data.decode('utf-8')}") # Full error handling example try: snapshots = client.snapshots.get() for snapshot in snapshots: print(snapshot) except RESTFailure as e: if e.status == 401: print("Authentication failed - check your credentials") elif e.status == 403: print("Access denied - insufficient permissions") elif e.status == 404: print("Resource not found") else: print(f"API error {e.status}: {e.data.decode('utf-8')}") ``` ``` -------------------------------- ### Delete a View using vastpy-cli Source: https://github.com/vast-data/vastpy/blob/main/README.md Use this command to delete a specific view identified by its ID. ```bash $ vastpy-cli delete views/109 ``` -------------------------------- ### Handle API Errors with RESTFailure Source: https://context7.com/vast-data/vastpy/llms.txt Catches and inspects RESTFailure exceptions to handle API request failures and status codes. ```python from vastpy import VASTClient, RESTFailure client = VASTClient(address='vast-vms-hostname', token='your-token') try: # Attempt to create a view with invalid parameters view = client.views.post(path='/invalid/path') except RESTFailure as e: print(f"Request failed!") print(f"Method: {e.method}") print(f"URL: {e.url}") print(f"Parameters: {e.fields}") print(f"Status code: {e.status}") print(f"Error message: {e.data.decode('utf-8')}") # Full error handling example try: snapshots = client.snapshots.get() for snapshot in snapshots: print(snapshot) except RESTFailure as e: if e.status == 401: print("Authentication failed - check your credentials") elif e.status == 403: print("Access denied - insufficient permissions") elif e.status == 404: print("Resource not found") else: print(f"API error {e.status}: {e.data.decode('utf-8')}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.