Alibaba Cloud Gateway SPI SDK Library

raw JSON →
0.0.3 verified Sat Apr 25 auth: no python

The `alibabacloud-gateway-spi` library provides Service Provider Interface (SPI) definitions for building and extending Alibaba Cloud Gateway functionalities in Python. It's a foundational component within the Alibaba Cloud SDK ecosystem, defining abstract clients and models that other SDKs or custom gateway implementations can utilize. The current version is 0.0.3, with releases appearing to follow an irregular cadence as part of the broader Alibaba Cloud SDK development.

pip install alibabacloud-gateway-spi
error ModuleNotFoundError: No module named 'alibabacloud_gateway_spi'
cause The 'alibabacloud_gateway_spi' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install alibabacloud-gateway-spi'.
error ImportError: cannot import name 'GatewayClient' from 'alibabacloud_gateway_spi'
cause The 'GatewayClient' class does not exist in the 'alibabacloud_gateway_spi' module.
fix
Verify the correct class name and import statement; refer to the module's documentation for available classes.
error AttributeError: 'CredentialModel' object has no attribute 'provider_name'
cause An outdated 'alibabacloud_credentials' package version is incompatible with the code accessing the 'provider_name' attribute.
fix
Upgrade the 'alibabacloud_credentials' package to the latest version using pip: 'pip install --upgrade alibabacloud_credentials'.
error ModuleNotFoundError: No module named 'Tea'
cause The `alibabacloud-gateway-spi` library, or another Alibaba Cloud SDK component it depends on, requires the `Tea` framework, which is not installed or the pip version is outdated leading to incomplete dependencies.
fix
Update pip and install the missing Tea module: pip install --upgrade pip followed by pip install alibabacloud-tea.
error AttributeError: 'NoneType' object has no attribute 'get_access_key_id'
cause This error typically occurs when the Alibaba Cloud access key ID and secret are not properly configured or passed, resulting in a `None` credentials object when the SDK attempts to retrieve the access key ID.
fix
Ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are set, or explicitly configure your AccessKey ID and AccessKey secret when initializing the client.
gotcha This library (`alibabacloud-gateway-spi`) serves as a Service Provider Interface (SPI) and provides abstract classes and models. It is not designed for direct end-user interaction to make API calls to Alibaba Cloud services. Instead, it defines interfaces that other Alibaba Cloud SDKs or custom gateway implementations build upon or implement.
fix Do not attempt to instantiate `Client` directly for making API calls. Refer to specific Alibaba Cloud service SDKs for client-side API usage. Use this library when building custom gateway logic or extending the Alibaba Cloud SDK's gateway capabilities.
gotcha As of version 0.0.3, this library is in a very early development stage (implied by the low version number). While no explicit 'beta' status is listed for this specific package, a related package (`alibabacloud-gateway-pds`) that depends on `alibabacloud-gateway-spi` is marked as 'Development Status :: 4 - Beta'. This suggests that API stability might not be fully guaranteed, and breaking changes could occur in future minor versions.
fix Monitor GitHub releases and PyPI for updates. Pin the exact version in your `requirements.txt` to ensure stability in production environments. Be prepared for potential API changes when upgrading to new minor or patch versions.
runtime status import time mem disk
3.10-alpine 1.16s 18.6MB 33.0M
3.10-slim 0.82s 18.6MB 35M
3.11-alpine 1.49s 20.6MB 36.7M
3.11-slim 1.15s 20.6MB 39M
3.12-alpine 1.54s 20.7MB 26.6M
3.12-slim 1.65s 20.7MB 29M
3.13-alpine 1.47s 21.6MB 25.8M
3.13-slim 1.66s 21.6MB 28M
3.9-alpine 1.25s 18.4MB 32.9M
3.9-slim 0.98s 18.4MB 36M

This quickstart demonstrates how to import core components of `alibabacloud-gateway-spi`, which primarily defines abstract classes and models. It highlights that this library is intended for extending or implementing custom gateway logic rather than direct end-user API invocation. It includes a simple placeholder for a custom gateway client extending the provided abstract `Client` class.

from alibabacloud_gateway_spi.client import Client
from alibabacloud_gateway_spi.models import InterceptorContext

# alibabacloud-gateway-spi provides abstract classes and interfaces.
# It is not typically used directly by end-users for making API calls,
# but rather extended or implemented by other Alibaba Cloud SDK components
# or custom gateway logic.

print(f"Successfully imported Client class: {Client.__name__}")
print(f"Successfully imported InterceptorContext model: {InterceptorContext.__name__}")

# Example of defining a placeholder for a custom gateway client:
class MyCustomGatewayClient(Client):
    def _do_request(self, request, runtime): # type: (...), (...) -> (...)
        # Implement custom request logic here
        print("MyCustomGatewayClient is processing a request.")
        # In a real scenario, this would involve making an actual HTTP request
        # and handling the response.
        return {'statusCode': 200, 'headers': {}, 'body': {}}

# This quickstart demonstrates importing and understanding the library's purpose.
# For actual usage, you would build upon or integrate with other Alibaba Cloud SDKs.