3scale API python client
Project description
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)
# Get list of APIs/Services or any other resource
services: List[resources.Service] = client.services.list()
# Get service by it's name
test_service: resources.Service = client.services["test_service"] # or use: client.services.read_by_name(system_name)
# Get service by it's id
test_service: resources.Service = client.services[12345] # or use client.services.read(id)
# To get raw JSON response - you can use the fetch method - it takes the service id
raw_json: dict = client.services.fetch(12345)
# To create a new service (or any other resource), parameters are the same as you would provide by the documentation
new_service: resources.Service = client.services.create(system_name='my_testing_service', name="My Testing service")
# In order to update service you can either
client.services[123456].update(param="new_value")
# or
service: resources.Service = client.services[123456]
service['param'] = 'new_value'
service.update()
# To get a proxy config you can use
proxy: resources.Proxy = client.services['test_service'].proxy.read()
# To update the proxy you can either
proxy: resources.Proxy = client.services['test_service'].proxy.update(parameter_to_update='update')
# or
proxy_instance = client.services['test_service'].proxy.read()
proxy_instance['param'] = 'new_value'
proxy_instance.update()
# On the service you can access the:
service: resources.Service = client.services[123456]
service.proxy # The PROXY client
service.mapping_rules # mapping rules client
service.metrics # metrics
service.app_plans # application plans
# The proxy supports:
proxy = service.proxy.read()
proxy.promote(version=1, from_env="sandbox", to_env="production") # The promote operation
proxy.mapping_rules # The mapping rules
proxy.configs # proxy configurations client
proxy.policies # Policies defined for the API
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>'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file 3scale-api-0.35.3.tar.gz
.
File metadata
- Download URL: 3scale-api-0.35.3.tar.gz
- Upload date:
- Size: 42.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
5a68c904c5c0a746b13a276951286910f858c1d6e285c151e54bcac8eb6ffef6
|
|
MD5 |
963392bb17bcff65b004c066a08edbe7
|
|
BLAKE2b-256 |
a3ccdcb316adddc835b4be39b93b28879ca38e4221530e0d38765691dd827d6b
|
Provenance
The following attestation bundles were made for 3scale-api-0.35.3.tar.gz
:
Publisher:
release.yml
on 3scale-qe/3scale-api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
3scale_api-0.35.3.tar.gz
-
Subject digest:
5a68c904c5c0a746b13a276951286910f858c1d6e285c151e54bcac8eb6ffef6
- Sigstore transparency entry: 246420687
- Sigstore integration time:
-
Permalink:
3scale-qe/3scale-api-python@32de76d9eee8fee81ec3ed9876eaea7d4806338d
-
Branch / Tag:
refs/tags/v0.35.3
- Owner: https://github.com/3scale-qe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release.yml@32de76d9eee8fee81ec3ed9876eaea7d4806338d
-
Trigger Event:
push
-
Statement type:
File details
Details for the file 3scale_api-0.35.3-py3-none-any.whl
.
File metadata
- Download URL: 3scale_api-0.35.3-py3-none-any.whl
- Upload date:
- Size: 58.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
68bf4ad135550c5082b37453b0728117b40af1ebeca7a4cb2ce3430aa9f13aa5
|
|
MD5 |
25afcb3a25852a79526d98877fa72d3e
|
|
BLAKE2b-256 |
0928bf8473a3e02ed5f54c543c9fa29d3293386e7e98f41b12ad01db03e4e014
|
Provenance
The following attestation bundles were made for 3scale_api-0.35.3-py3-none-any.whl
:
Publisher:
release.yml
on 3scale-qe/3scale-api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
3scale_api-0.35.3-py3-none-any.whl
-
Subject digest:
68bf4ad135550c5082b37453b0728117b40af1ebeca7a4cb2ce3430aa9f13aa5
- Sigstore transparency entry: 246420707
- Sigstore integration time:
-
Permalink:
3scale-qe/3scale-api-python@32de76d9eee8fee81ec3ed9876eaea7d4806338d
-
Branch / Tag:
refs/tags/v0.35.3
- Owner: https://github.com/3scale-qe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release.yml@32de76d9eee8fee81ec3ed9876eaea7d4806338d
-
Trigger Event:
push
-
Statement type: