Scaleway Python SDK documentation
Installation
This library is made to work with Python 3.8 but should work on the latest versions too.
The SDK is available in two flavors, a synchronous and an asynchronous one.
Install from PyPI:
pip install scaleway
Install from PyPI (async):
pip install scaleway-async
Initialization
You’ll need a pair of access and secret keys to connect to Scaleway API. Please check the documentation on how to retrieve them.
scaleway
APIs must be initialized with a scaleway.Client
.
A minimal setup would look like this:
from scaleway import Client
from scaleway.registry.v1 import RegistryV1API
client = Client(
access_key="SCWXXXXXXXXXXXXXXXXX",
secret_key="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
default_project_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
default_region="fr-par",
default_zone="fr-par-1",
)
registry_api = RegistryV1API(client)
For a simpler setup, you could retrieve the profile from either the configuration file or the environment variables:
from scaleway import Client
client = Client.from_config_file_and_env()
Pagination
We included some pagination helpers for the methods supporting the feature. Let’s take scaleway.registry.v1.RegistryV1API.list_namespaces()
as an example:
Retrieve the first page:
result = api.list_namespaces(
# page=1,
)
Retrieve all the pages:
namespaces = api.list_namespaces_all()
Types
The project is coded with Python, so don’t hesitate to take advantage of it.
All types of a product are stored in the scaleway.product.version namespace. For instance,
scaleway.registry.v1.Image
.
Logging
We are using the standard Python logging library. You can configure it as you wish:
import logging
logger = logging.getLogger("scaleway")
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)