ApiGateway Service (AGS)¶
API Gateway (APIG) is a high-performance, high-availability, and high-security API hosting service that helps you build, manage, and deploy APIs at any scale. With just a few clicks, you can integrate internal systems, and selectively expose capabilities with minimal costs and risks.
Gateway¶
A Gateway is a service that acts as an intermediary between clients and backend services, providing a centralized point of control for processing API requests. It enables management of access, security, routing, scalability, and monitoring of APIs.
Create Gateway¶
This example demonstrates how to create a new gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'instance_name': 'name',
'spec_id': 'BASIC',
'vpc_id': 'vpc.id',
'subnet_id': 'subnet.id',
'security_group_id': 'security_group.id',
'available_zone_ids': ['available_zone_ids'],
}
gateway = conn.apig.create_gateway(**attrs)
Delete Gateway¶
This example demonstrates how to delete an existing gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_gateway('gateway_id')
List Gateways¶
This example demonstrates how to list all gateways.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'limit': 2
}
for gw in conn.apig.gateways(**attrs):
print(gw.name)
Get Gateway Details¶
This example demonstrates how to retrieve details of a specific gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.get_gateway("id")
Update Gateway¶
This example demonstrates how to update an existing gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"description": "some description",
}
conn.apig.update_gateway("gateway_id", **attrs)
Bind EIP¶
This example demonstrates how to bind an Elastic IP (EIP) to a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"eip_id": "eip_id"
}
conn.apig.bind_eip('gateway_id', **attrs)
Unbind EIP¶
This example demonstrates how to unbind an Elastic IP (EIP) from a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.unbind_eip('gateway_id')
Update Public Inbound Access¶
This example demonstrates how to update public inbound access for a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"bandwidth_size": "7",
"bandwidth_charging_mode": "bandwidth"
}
conn.apig.update_ingress('gateway_id', **attrs)
Enable Public Inbound Access¶
This example demonstrates how to enable public inbound access for a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"bandwidth_size": "5",
"bandwidth_charging_mode": "bandwidth"
}
conn.apig.enable_ingress('gateway_id', **attrs)
Disable Public Inbound Access¶
This example demonstrates how to disable public inbound access for a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.disable_ingress('gateway_id')
Enable Public Access¶
This example demonstrates how to enable public access for a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"bandwidth_size": "5",
"bandwidth_charging_mode": "bandwidth"
}
conn.apig.enable_public_access("gateway.id", **attrs)
Update Public Access¶
This example demonstrates how to update public access settings for a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"bandwidth_size": "7",
"bandwidth_charging_mode": "bandwidth"
}
conn.apig.update_public_access("gateway_id", **attrs)
Disable Public Access¶
This example demonstrates how to disable public access for a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.disable_public_access('gateway_id')
Get Gateway Constraints¶
This example demonstrates how to retrieve the constraints and limitations of a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.get_constraints("gateway.id")
Get Gateway Creation Progress¶
This example demonstrates how to check the progress of a gateway creation process.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.get_gateway_progress('gateway_id')
Modify Gateway Specifications¶
This example demonstrates how to modify the specifications of an existing gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"spec_id": "PROFESSIONAL"
}
conn.apig.modify_gateway_spec("gateway_id", **attrs)
AZs¶
List Azs¶
This example demonstrates how to list the availability zones (AZs) supported by API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"eip_id": "eip_id"
}
for az in conn.apig.azs():
print(az)
Environment¶
Create Environment¶
This example demonstrates how to create a new environment within a specific API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "DEV",
"remark": "Development environment"
}
environment = conn.apig.create_environment(gateway="gateway_id",
**attrs)
Update Environment¶
This example demonstrates how to update an existing environment within a specific API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "DEV",
"remark": "Development environment"
}
environment = conn.apig.update_environment(environment="env_id",
gateway="gateway_id",
**attrs)
Delete Environment¶
This example demonstrates how to delete an existing environment from a specific API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_environment(gateway="gateway_id",
environment="env_id",)
List Environments¶
This example demonstrates how to list all environments associated with a specific API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
environments = list(conn.apig.environments(gateway="gateway_id"))
Api Group¶
Create Api Group¶
This example demonstrates how to create a new API group in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "api_group_001",
"remark": "API group 1"
}
created = conn.apig.create_api_group(gateway="gateway_id",
**attrs)
Update Api Group¶
This example demonstrates how to update an existing API group in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'name': 'name',
'remark': 'new_remark'
}
updated = conn.apig.update_api_group(
gateway='gateway_id',
api_group='api_group_id',
**attrs)
Delete Api Group¶
This example demonstrates how to delete an existing API group from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_api_group(gateway='gateway_id',
api_group='api_group_id')
List Api Groups¶
This example demonstrates how to list all API groups associated with a specific API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
groups = list(conn.apig.api_groups(gateway="gateway_id"))
Get Api Group¶
This example demonstrates how to retrieve details of a specific API group from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = conn.apig.get_api_group(gateway='gateway_id',
api_group='api_group_id')
Verify Api Group Name¶
This example demonstrates how to verify whether a given API group name is available in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"group_name": "api_group_002"
}
conn.apig.verify_api_group_name(gateway="gateway_id", **attrs)
Creating a Variable¶
This example demonstrates how to define environment variables.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"variable_name": "address",
"variable_value": "192.168.1.5",
"env_id": "environment_id",
"group_id": "group_id"
}
variable = conn.apig.create_environment_variable(
gateway="gateway_id",
**attrs
)
Deleting a Variable¶
This example demonstrates how to delete environment variable.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_environment_variable(
gateway="gateway_id",
var="var_id"
)
Querying Variable Details¶
This example demonstrates how to query the details of an environment variable.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.get_environment_variable(
gateway="gateway_id",
var="variable_id"
)
Querying Environment Variables¶
This example demonstrates how to query all environment variables under an API group.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
environments = list(conn.apig.environment_variables(
gateway="gateway_id",
group_id="group_id"
))
Modifying a Variable¶
This example demonstrates how to modify an environment variable.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"variable_value": "192.168.1.6",
}
var = conn.apig.update_environment_variable(
gateway="gateway_id",
var="variable_id",
**attrs
)
Creating a Request Throttling Policy¶
This example demonstrates how to create throttling policy.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"api_call_limits": 100,
"app_call_limits": 60,
"enable_adaptive_control": "FALSE",
"ip_call_limits": 60,
"name": "throttle_demo",
"remark": "Total: 800 calls/second;"
" user: 500 calls/second;"
" app: 300 calls/second;"
" IP address: 600 calls/second",
"time_interval": 1,
"time_unit": "SECOND",
"type": 1,
"user_call_limits": 60
}
policy = conn.apig.create_throttling_policy(
gateway="gateway_id",
**attrs
)
Modifying a Request Throttling Policy¶
This example demonstrates how to update throttling policy.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"time_unit": "SECOND",
"name": "throttle_demo",
"api_call_limits": 100,
"time_interval": 1,
"remark": "Total: 800 calls/second;"
" user: 500 calls/second;"
" app: 300 calls/second;"
" IP address: 600 calls/second",
}
environment = conn.apig.update_throttling_policy(
gateway="gateway_id",
policy="policy_id",
**attrs
)
Deleting a Request Throttling Policy¶
This example demonstrates how to delete throttling policy.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_throttling_policy(
gateway="gateway_id",
policy="policy_id"
)
Querying Request Throttling Policies¶
This example demonstrates how to query all throttling policies.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
environments = list(conn.apig.throttling_policies(
gateway="gateway_id"))
Querying Details of a Request Throttling Policy¶
This example demonstrates how to get throttling policy.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.get_throttling_policy(
gateway="gateway_id",
policy="policy_id"
)
Creating an API¶
This example demonstrates how to create an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"group_id": "group_id",
"name": "test_api_001",
"auth_type": "IAM",
"backend_type": "HTTP",
"req_protocol": "HTTP",
"req_uri": "/test/http",
"remark": "Mock backend API",
"type": 2,
"req_method": "GET",
"result_normal_sample": "Example success response",
"result_failure_sample": "Example failure response",
"tags": ["httpApi"],
"backend_api": {
"req_protocol": "HTTP",
"req_method": "GET",
"req_uri": "/test/benchmark",
"timeout": 5000,
"retry_count": "-1",
"url_domain": "192.168.189.156:12346"
},
}
created = conn.apig.create_apicreate_api(
gateway="gateway_id",
**attrs
)
Modifying an API¶
This example demonstrates how to update an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"group_id": "group_id",
"name": "test_api_001",
"auth_type": "IAM",
"backend_type": "HTTP",
"req_protocol": "HTTP",
"req_uri": "/test/http",
"remark": "Mock backend API",
"type": 2,
"req_method": "GET",
"result_normal_sample": "Example success response",
"result_failure_sample": "Example failure response",
"tags": ["httpApi"],
"backend_api": {
"req_protocol": "HTTP",
"req_method": "GET",
"req_uri": "/test/benchmark",
"timeout": 5000,
"retry_count": "-1",
"url_domain": "192.168.189.156:12346"
},
}
environment = conn.apig.update_api(
api="env_id",
gateway="gateway_id",
**attrs
)
Deleting an API¶
This example demonstrates how to delete an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_api(
gateway="gateway_id",
api="env_id"
)
Querying API Details¶
This example demonstrates how to get an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.get_api(
gateway="gateway_id",
api="api_id"
)
Querying APIs¶
This example demonstrates how to list an APIs.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
environments = list(conn.apig.apis(gateway="gateway_id"))
Publishing an API¶
This example demonstrates how to publish an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
publish = conn.apig.publish_api(
gateway="gateway_id",
api="api_id",
env="environment_id",
remark="publish"
)
Take API offline¶
This example demonstrates how to take API offline.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
unpublish = conn.apig.offline_api(
gateway="gateway_id",
api="api_id",
env="environment_id",
remark="publish"
)
Verifying the API Definition¶
This example demonstrates how to verify the API definition.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"type": "name",
"name": "api_name"
}
check = conn.apig.check_api(
gateway="gateway_id",
**attrs
)
Debugging an API¶
This example demonstrates how to debug an API in a specified environment.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"mode": "DEVELOPER",
"scheme": "HTTP",
"method": "GET",
"path": "/test/http"
}
debug = conn.apig.debug_api(
gateway="gateway_id",
api="api_id",
**attrs
)
Publishing APIs¶
This example demonstrates how to publish multiple APIs in an environment.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
unpublish = conn.apig.offline_apis(
gateway="gateway_id",
apis=["api_id_1", "api_id_2"],
env="environment_id",
remark="publish"
)
Taking APIs Offline¶
This example demonstrates how to remove multiple APIs from the environment.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
unpublish = conn.apig.offline_api(
gateway="gateway_id",
apis=["api_id_1", "api_id_2"],
env="environment_id",
remark="offline"
)
Querying Historical Versions of an API¶
This example demonstrates how to query the historical versions of an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
groups = list(conn.apig.api_versions(
gateway="gateway_id",
api="api_id")
)
Switching the Version of an API¶
This example demonstrates how to switch the version of an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
switch = conn.apig.switch_version(
gateway="gateway_id",
api="api_id",
version_id="version_id"
)
Querying the Runtime Definition of an API¶
This example demonstrates how to query the runtime definition of an API in a specified environment.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
definitions = list(conn.apig.api_runtime_definitions(
gateway="gateway_id",
api="api_id",
env_id="environment_id"
))
Querying API Version Details¶
This example demonstrates how to query the details of a specified API version.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
details = list(conn.apig.api_version_details(
gateway="gateway_id",
version_id="version_id"
))
Taking an API Version Offline¶
This example demonstrates how to remove an effective version of an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
unpublish = conn.apig.take_api_version_offline(
gateway="gateway_id",
version_id="version_id"
)
Creating a Signature Key¶
This example demonstrates how to create a signature key.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "otce_signature_1",
"sign_type": "aes",
"sign_algorithm": "aes-256-cfb",
}
created = conn.apig.create_signature(
gateway="gateway_id",
**attrs
)
Modifying a Signature Key¶
This example demonstrates how to update a signature key.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "otce_signature_1",
"sign_type": "aes",
"sign_algorithm": "aes-128-cfb",
}
sign = conn.apig.update_signature(
sign="sign_id",
gateway="gateway_id",
**attrs
)
Deleting a Signature Key¶
This example demonstrates how to delete a signature key.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_signature(
gateway="gateway_id",
sign="signature_id"
)
Querying Signature Keys¶
This example demonstrates how to fetch all signature keys.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
environments = list(conn.apig.signatures(gateway="gateway_id"))
Binding a Signature Key¶
This example demonstrates how to bind a signature key.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"sign_id": "sign_id",
"publish_ids": ["publish_id"]
}
bind = conn.apig.bind_signature(
gateway="gateway_id",
**attrs
)
Unbinding a Signature Key¶
This example demonstrates how to unbind a signature key.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.unbind_signature(
gateway="gateway_id",
bind="binding_id"
)
Querying Signature Keys Bound to an API¶
This example demonstrates how to list the signature keys that have been bound to a specified API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
signs = list(conn.apig.bound_signatures(
gateway="gateway_id",
api_id="api_id"
))
Querying APIs Not Bound with a Signature Key¶
This example demonstrates how to list the APIs to which a signature key has not been bound.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
apis = list(conn.apig.not_bound_apis(
gateway="gateway_id",
sign_id="sign_id"
))
Querying APIs Bound with a Signature Key¶
This example demonstrates how to list the APIs to which a signature key has been bound.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
apis = list(conn.apig.bound_apis(
gateway="gateway_id",
sign_id="sign_id"
))
Binding a Request Throttling Policy¶
This example demonstrates how to bind request throttling policy to an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"throttle_id": "throttle_id",
"publish_ids": ["publish_id"]
}
bind = conn.apig.bind_throttling_policy(
gateway="gateway_id",
**attrs
)
Unbinding a Request Throttling Policy¶
This example demonstrates how to unbind request throttling policy from an API.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.unbind_throttling_policy(
gateway="gateway_id",
bind="throttle_binding_id"
)
Querying APIs Bound with a Request Throttling Policy¶
This example demonstrates how to query the APIs to which a specified request throttling policy has been bound.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
apis = list(conn.apig.bound_throttling_policy_apis(
gateway="gateway_id",
throttle_id="throttle_id"
))
Querying APIs Not Bound with a Request Throttling Policy¶
This example demonstrates how to query the self-developed APIs to which a request throttling policy has not been bound. Only published APIs will be displayed.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
apis = list(conn.apig.not_bound_throttling_policy_apis(
gateway="gateway_id",
throttle_id="throttle_id"
))
Querying Request Throttling Policies Bound to an API¶
This example demonstrates how to query the request throttling policies that have been bound to an API. Only one request throttling policy can be bound to an API in an environment
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
apis = list(conn.apig.bound_throttling_policies(
gateway="gateway_id",
api_id="api_id"
))
Querying Request Throttling Policies Bound to an API¶
This example demonstrates how to unbind request throttling policies from APIs.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.unbind_throttling_policies(
gateway="gateway_id",
throttle_bindings=[
"throttle_binding_id_1",
"throttle_binding_id_2"
]
)
Creating an Excluded Request Throttling Configuration¶
This example demonstrates how to create an excluded request throttling configuration.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"api_call_limits": 100,
"app_call_limits": 60,
"enable_adaptive_control": "FALSE",
"ip_call_limits": 60,
"name": "throttle_demo",
"remark": "Total: 800 calls/second;"
" user: 500 calls/second;"
" app: 300 calls/second;"
" IP address: 600 calls/second",
"time_interval": 1,
"time_unit": "SECOND",
"type": 1,
"user_call_limits": 60
}
policy = conn.apig.create_throttling_policy(
gateway="gateway_id",
**attrs
)
ex_attrs = {
"call_limits": 50,
"object_id": "user_id",
"object_type": "USER"
}
excluded = conn.apig.create_throttling_excluded_policy(
gateway="gateway_id",
policy=policy,
**ex_attrs
)
Modifying an Excluded Request Throttling Configuration¶
This example demonstrates how to update an excluded request throttling configuration.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"call_limits": 30
}
updated = conn.apig.update_throttling_excluded_policy(
gateway="gateway_id",
policy="policy_id",
exclude="excluded_id",
**attrs
)
Deleting an Excluded Request Throttling Configuration¶
This example demonstrates how to delete an excluded request throttling configuration.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_throttling_excluded_policy(
gateway="gateway_id",
policy="policy_id",
exclude="excluded_id"
)
Querying Excluded Request Throttling Configurations¶
This example demonstrates how to query an excluded request throttling configurations.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
exc = list(conn.apig.throttling_excluded_policies(
policy="policy_id",
gateway="gateway_id"
))
Querying the Supported Features of a Gateway¶
This example demonstrates how to query the supported features of a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
features = list(conn.apig.supported_gateway_features(gateway="gateway_id"))
Querying Gateway Features¶
This example demonstrates how to query the features of a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
features = list(conn.apig.gateway_features(gateway="gateway_id"))
Querying Gateway Features¶
This example demonstrates how to configure a feature for a gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "route",
"enable": True,
"config": "{\"user_routes\":[\"172.16.128.0/20\",\"172.16.0.0/20\"]}",
}
feat = conn.apig.configure_gateway_feature(
gateway="gateway_id",
**attrs
)
Querying API Quantities¶
This example demonstrates how to get the number of APIs that have been published in the RELEASE environment and the number of APIs that have not been published in this environment.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
api_q = conn.apig.get_api_quantities(
gateway="gateway_id")
Querying API Group Quantities¶
This example demonstrates how to get the number of API groups.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
api_q = conn.apig.get_api_group_quantities(
gateway="gateway_id")
Querying App Quantities¶
This example demonstrates how to get the number of apps that have been authorized to access APIs and the number of apps that have not been authorized to access any APIs.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
api_q = conn.apig.get_app_quantities(
gateway="gateway_id")
Binding a Domain Name¶
This example demonstrates how to bind domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"url_domain": "example.com"
}
bind = conn.apig.bind_domain_name(
gateway="gateway_id",
group="group_id",
**attrs
)
Adding a Certificate to a Domain Name¶
This example demonstrates how to add certificate to a domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "cert",
"private_key": "key",
"cert_content": "content"
}
created = conn.apig.create_certificate_for_domain_name(
gateway="gateway_id",
group="group_id",
domain="domain_id",
**attrs
)
Modifying a Domain Name¶
This example demonstrates how to modify the configuration of a domain name bound to an API group.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"min_ssl_version": "TLSv1.2"
}
updated = conn.apig.update_domain_name_bound(
gateway="gateway_id",
group="group_id",
domain="domain_id",
**attrs
)
Unbinding a Domain Name¶
This example demonstrates how to unbind a custom domain name from an API group.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.conn.apig.unbind_domain_name(
gateway="gateway_id",
group="group_id",
domain="domain_id",
)
Unbinding a Domain Name¶
This example demonstrates how to to disable or enable the debugging domain name bound to an API group.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
updated = conn.apig.enable_debug_domain_name(
gateway="gateway_id",
group="group_id",
domain="domain_id",
enable=False,
)
Deleting the Certificate Bound to a Domain Name¶
This example demonstrates how to delete a certificate that is no longer needed or has expired.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
unbind = conn.apig.unbind_certificate_from_domain_name(
gateway="gateway_id",
group="group_id",
domain="domain_id",
certificate="certificate_id",
)
Deleting the Certificate Bound to a Domain Name¶
This example demonstrates how to query the details of the certificate bound to a domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = conn.apig.get_bound_certificate(
gateway="gateway_id",
group="group_id",
domain="domain_id",
certificate="ssl_id",
)
Deleting an SSL Certificate¶
This example demonstrates how to query the details of the certificate bound to a domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_certificate(
certificate="ssl_id",
)
Credentials¶
Create an App¶
This example demonstrates how to create a new app in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "app_demo",
"remark": "Demo app"
}
created = conn.apig.create_app(gateway='gateway_id',
**attrs)
Modify an App¶
This example demonstrates how to modify an existing app in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
app = conn.apig.update_app(gateway='gateway_id',
app='app_id',)
Delete an App¶
This example demonstrates how to delete an existing app from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_app(gateway='gateway_id',
app='app_id',)
Reset the AppSecret of an App¶
This example demonstrates how to reset the AppSecret of a specific app in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = conn.apig.reset_app_secret(gateway='gateway_id',
app='app_id',)
Verify an App¶
This example demonstrates how to verify a specific app in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
app = conn.apig.verify_app(gateway='gateway_id',
app='app_id',)
Query App Details¶
This example demonstrates how to retrieve details of a specific app from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
app = conn.apig.get_app(gateway='gateway_id',
app='app_id',)
Query Apps¶
This example demonstrates how to list all apps associated with a specific API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'limit': 5
}
apps = conn.apig.apps(gateway='gateway_id', **attrs)
Create an AppCode¶
This example demonstrates how to create a new AppCode for an app in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"app_code": "GjOD3g80AABuuFeEJpVQADBlAjBh3UzC7W+gr4V"
"JBB5BtJ4fdVOQoSvoji3gFxUDb5pWBz9wUcw9+8"
"/bFZ1B/4pq29wCMQC0pQWX6zTndljDEl99As1pw+"
"WntAU9xcq+ffagoH6zDpKUvdxV6Ezj8LcCcPZN6BU="
}
created = conn.apig.create_app_code(gateway='gateway_id',
app='app_id',
**attrs)
Generate an AppCode¶
This example demonstrates how to generate a new AppCode for an app in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
code = conn.apig.generate_app_code(gateway='gateway_id',
app='app_id',)
Delete an AppCode¶
This example demonstrates how to delete an existing AppCode from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_app_code(gateway='gateway_id',
app='app_id',
Query AppCode Details¶
This example demonstrates how to retrieve details of a specific AppCode in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = conn.apig.get_app_code(gateway='gateway_id',
app='app_id',
app_code='app_code_id',)
Query AppCodes of an App¶
This example demonstrates how to list all AppCodes associated with a specific app in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = list(conn.apig.app_codes(gateway='gateway_id',
app='app_id',))
Query Quotas Associated with a Credential¶
This example demonstrates how to query quotas associated with a specific credential in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
info = conn.apig.quotas()