3scale REST API client in Python
3Scale REST API client in a wrapper over the 3scale API.

Installing
Install and update using pip:
pip install 3scale-api
Or as a dependency using the pipenv
pipenv install 3scale-api
Usage
Client supports basic CRUD operations and it using the official 3scale API.
The API can be found at <https://yourdomain-admin.3scale.net>/p/admin/api_docs
Basic usage of the client:
from threescale_api import ThreeScaleClient, resources
from typing import List
client = ThreeScaleClient(url="myaccount.3scale.net", token="secret_token", ssl_verify=True)
services: List[resources.Service] = client.services.list()
test_service: resources.Service = client.services["test_service"]
test_service: resources.Service = client.services[12345]
raw_json: dict = client.services.fetch(12345)
new_service: resources.Service = client.services.create(system_name='my_testing_service', name="My Testing service")
client.services[123456].update(param="new_value")
service: resources.Service = client.services[123456]
service['param'] = 'new_value'
service.update()
proxy: resources.Proxy = client.services['test_service'].proxy.read()
proxy: resources.Proxy = client.services['test_service'].proxy.update(parameter_to_update='update')
proxy_instance = client.services['test_service'].proxy.read()
proxy_instance['param'] = 'new_value'
proxy_instance.update()
service: resources.Service = client.services[123456]
service.proxy
service.mapping_rules
service.metrics
service.app_plans
proxy = service.proxy.read()
proxy.promote(version=1, from_env="sandbox", to_env="production")
proxy.mapping_rules
proxy.configs
proxy.policies
Run the Tests
To run the tests you need to have installed development dependencies:
pipenv install --dev
and then run the pytest:
pipenv run pytest -v
Integration tests configuration
To run the integration tests you need to set these env variables:
THREESCALE_PROVIDER_URL='https://example-admin.3scale.net'
THREESCALE_PROVIDER_TOKEN='<test-token>'
# OPTIONAL:
THREESCALE_MASTER_URL='https://master.3scale.net'
THREESCALE_MASTER_TOKEN='<test-master-token>'