You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Swan Python SDK provides an intuitive interface for interacting with the Swan network, enabling developers to manage cloud resources, tasks, and payments with ease. This SDK abstracts the complexities of the underlying API, allowing you to focus on building your applications.
Swan Python SDK Documentation
Overview
The Swan Python SDK provides an intuitive interface for interacting with the Swan network, enabling developers to manage cloud resources, tasks, and payments with ease. This SDK abstracts the complexities of the underlying API, allowing you to focus on building your applications.
Table of Contents
Installation
Install the Swan Python SDK via pip:
Alternatively, you can clone the repository and install it directly:
Getting Started
To start using the SDK, import the necessary modules and initialize the client:
Initialization and Configuration
Initialization
You can initialize the SDK with various configuration options:
Configuration from Environment Variables
The SDK can be configured using environment variables:
Then, in your code:
Configuration from a File
Load configuration from a JSON or YAML file:
Task Management
Creating a Task
To create a task on the Swan network:
Terminating a Task
To terminate an existing task:
Listing Tasks
To list all tasks:
Hardware Management
Fetching Hardware Configurations
Retrieve available hardware configurations:
Checking Hardware Availability
Verify if a specific hardware configuration is available in a region:
Payment Management
Estimating Payment
Estimate the cost for a task:
Submitting Payment
Submit a payment for a task:
Validating Payment
Validate a payment on the Swan backend:
Asynchronous Operations
The SDK supports asynchronous operations for non-blocking calls:
Error Handling
The SDK provides robust error handling with custom exceptions:
Custom Exceptions
SwanAPIException
: General API errors.SwanAuthenticationException
: Authentication-related errors.SwanTaskException
: Errors related to task management.SwanPaymentException
: Errors related to payments.Logging and Monitoring
Configurable Logging
Enable logging for better insight into SDK operations:
Integrating with Cloud Logging
You can integrate the SDK's logging with cloud services like AWS CloudWatch or Google Cloud Logging for centralized monitoring.
Advanced Usage
Using Profiles
Use profiles for managing different environments:
Context Managers for Resource Handling
Automatically manage resources using context managers:
Command-Line Interface (CLI)
The SDK provides a CLI for quick operations:
CLI Usage Examples
Create a Task:
List Tasks:
Terminate a Task:
Contributing
We welcome contributions to improve the Swan Python SDK. Please follow the guidelines in our CONTRIBUTING.md file.
License
The Swan Python SDK is open-source software licensed under the MIT License. See the LICENSE file for more details.
The text was updated successfully, but these errors were encountered: