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_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()
Access Control Policy¶
Creating an Access Control Policy¶
This example demonstrates how to create an ACL policy in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"acl_name": "acl_demo",
"acl_type": "PERMIT",
"acl_value": "192.168.1.5,192.168.10.1",
"entity_type": "IP"
}
created = conn.apig.create_acl_policy(gateway='gateway_id',
**attrs)
Updating an Access Control Policy¶
This example demonstrates how to update an existing ACL policy in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"acl_name": "acl_demo",
"acl_type": "DENY",
"acl_value": "192.168.1.5,192.168.10.1",
"entity_type": "IP"
}
created = conn.apig.update_acl_policy(gateway='gateway_id',
acl_policy='acl_id',
**attrs)
Deleting an Access Control Policy¶
This example demonstrates how to delete a specific ACL policy in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_acl_policy(gateway='gateway_id',
acl_policy='acl_id')
Deleting Multiple Access Control Policies¶
This example demonstrates how to delete multiple ACL policies in a single request in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'acls': ['acl_id1', 'acl_id2']
}
conn.apig.delete_acl_policies(gateway='gateway_id',
**attrs)
Querying Access Control Policy¶
This example demonstrates how to list all ACL policies configured in a specific API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'offset': 1
}
found = list(conn.apig.acl_policies(gateway='gateway_id',
**attrs))
Get Access Control Policy¶
This example demonstrates how to retrieve details of a specific ACL policy in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
acl = conn.apig.get_acl_policy(gateway='gateway_id',
acl_policy='acl_id')
Access Control Policy Binding¶
Binding an Access Control Policy to an API¶
This example demonstrates how to bind an access control policy to a specific API in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"acl_id": "d5645ed3c454492f8d6aa68ab034c6d3",
"publish_ids": ["293fe0a8e3f04a1ab151bd0d913900a9"]
}
result = list(conn.apig.bind_acl_to_api(gateway='gateway_id', **attrs))
Unbinding an Access Control Policy¶
This example demonstrates how to unbind a specific access control policy from an API in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'api_id': '12259302184a4972ac64277537a6aa20'
}
found = list(conn.apig.list_acl_for_api(gateway='gateway_id', **attrs))
Unbinding Access Control Policies¶
This example demonstrates how to unbind multiple access control policies from APIs in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"acl_bindings": ["332c5db1458a477b89b2ea741fec94a3"]
}
result = list(conn.apig.unbind_acls(gateway='gateway_id', **attrs))
Query APIs Bound with an Access Control Policy¶
This example demonstrates how to query APIs that are bound to a specific access control policy in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'acl_id': '1142260d5e654b9590a1d329926bea52'
}
found = list(conn.apig.list_apis_for_acl(
gateway='gateway_id', **attrs))
Query APIs Not Bound with an Access Control Policy¶
This example demonstrates how to query APIs that are not bound to a specific access control policy in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'acl_id': '1142260d5e654b9590a1d329926bea52'
}
found = list(conn.apig.list_api_not_bound_to_acl(
gateway='gateway_id', **attrs))
Query Access Control Policies Bound to an API¶
This example demonstrates how to query access control policies bound to a specific API in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'api_id': '64182cc7e77245ebbae8cf3b8522a540'
}
found = list(conn.apig.list_acl_for_api(
gateway='gateway_id', **attrs))
API Import and Export¶
Exporting APIs¶
This example demonstrates how to export an existing API from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"env_id": "DEFAULT_ENVIRONMENT_RELEASE_ID",
"group_id": "ce973ff83ce54ef192c80bde884aa0ac",
"define": "all"
}
conn.apig.export_api(
gateway='gateway_id',
full_path='/mnt/c/Users/sand1/api',
**attrs)
Importing APIs¶
This example demonstrates how to import an API definition into API Gateway.
import openstack
import json
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
with open('/mnt/c/Users/sand1/PycharmProjects/python-otcextensions/'
'otcextensions/tests/functional/sdk/apig/v2/test.json', 'r') as f:
openapi_content = json.load(f)
attrs = {
"is_create_group": False,
"group_id": "ce973ff83ce54ef192c80bde884aa0ac",
"file_name": "test.json",
"swagger": openapi_content
}
conn.apig.client.import_api(
gateway='gateway_id',
**attrs)
VPC Channel¶
Creating a VPC Channel¶
This example demonstrates how to create a VPC channel in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"balance_strategy": 1,
"member_type": "ip",
"name": "VPC_demo",
"port": 22,
}
vpc = conn.apig.create_vpc_channel(gateway="gateway_id",
**attrs)
Updating a VPC Channel¶
This example demonstrates how to update configuration of an existing VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"balance_strategy": 1,
"member_type": "ip",
"name": "VPC_demo",
"port": 222,
}
updated = conn.apig.update_vpc_channel(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
**attrs)
Deleting a VPC Channel¶
This example demonstrates how to delete a VPC channel from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_vpc_channel(
gateway="gateway_id",
vpc_channel="vpc_channel_id")
Get VPC Channel Details¶
This example demonstrates how to retrieve details of a specific VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = conn.apig.get_vpc_channel(
gateway="gateway_id",
vpc_channel="vpc_channel_id"
)
List VPC Channels¶
This example demonstrates how to list all VPC channels configured in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = list(conn.apig.vpc_channels(gateway="gateway_id"))
Adding or Updating Backend Instances¶
This example demonstrates how to add or update backend instances for a VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"members": [{
"host": "192.168.2.25",
"weight": 1,
"member_group_name": "vpc_member_group"
}]
}
result = conn.apig.add_or_update_backend_servers(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
**attrs
)
Querying Backend Servers of a VPC Channel¶
This example demonstrates how to list all backend servers of a given VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = list(conn.apig.list_backend_servers(
gateway="gateway_id",
vpc_channel="vpc_channel",
))
Updating Backend Instances¶
This example demonstrates how to update configuration of existing backend instances.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"member_group_name": "vpc_member_group",
"members": [{
"host": "192.168.2.25",
"weight": 2,
"is_backup": True,
"member_group_name": "vpc_member_group"
}]
}
updated = conn.apig.update_backend_server(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
**attrs
)
Removing a Backend Server¶
This example demonstrates how to remove a backend server from a VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.remove_backend_server(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
backend_server="backend_server_id"
)
Enabling Backend Servers¶
This example demonstrates how to enable one or more backend servers for a VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"member_ids": ["id"]
}
conn.apig.enable_backend_server(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
backend_server="backend_server_id",
**attrs
)
Disabling Backend Servers¶
This example demonstrates how to disable one or more backend servers for a VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"member_ids": ["id"]
}
conn.apig.disable_backend_server(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
backend_server="backend_server_id",
**attrs
)
Modifying VPC Channel Health Check¶
This example demonstrates how to modify the health check settings of a VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"http_code": "200",
"path": "/vpc/demo",
"port": 22,
"method": "GET",
"protocol": "http",
"threshold_abnormal": 5,
"threshold_normal": 2,
"time_interval": 10,
"timeout": 5,
"enable_client_ssl": False
}
updated = conn.apig.modify_vpc_channel_healthcheck(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
**attrs
)
Adding or Updating a Backend Server Group of a VPC Channel¶
This example demonstrates how to add or update a backend server group for a VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"member_groups": [{
"member_group_name": "vpc_member_group",
"member_group_weight": 10
}]
}
result = conn.apig.add_or_update_backend_server_group(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
**attrs
)
Querying Backend Server Groups of a VPC Channel¶
This example demonstrates how to list all backend server groups of a given VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = list(conn.apig.backend_server_groups(
gateway="gateway_id",
vpc_channel="vpc_channel_id"))
Querying a Backend Server Group of a VPC Channel¶
This example demonstrates how to retrieve details of a specific backend server group.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = conn.apig.get_backend_server_group(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
backend_group="backend_group_id")
Deleting a Backend Server Group of a VPC Channel¶
This example demonstrates how to delete a backend server group from a VPC channel.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_backend_server_group(
gateway="gateway_id",
vpc_channel="vpc_channel_id",
backend_group="backend_group_id"
)
Updating a Backend Server Group of a VPC Channel¶
This example demonstrates how to update configuration of an existing backend server group.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"member_group_name": "vpc_member_group",
"member_group_weight": 50
}
VPC Channel¶
Querying API Calls Within a Period¶
This example demonstrates how to retrieve statistics of API calls within a specified time period.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'api_id': '64182cc7e77245ebbae8cf3b8522a540',
'duration': '1h',
}
found = conn.apig.list_api_calls_for_period(gateway='gateway_id_here',
**attrs)
Querying Monitoring Data¶
This example demonstrates how to query monitoring metrics for your APIs.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'dim': 'inbound_eip',
'metric_name': 'upstream_bandwidth',
'from': '1740787200000',
'to': '1740873600000',
'period': 3600,
'filter': 'average',
}
found = conn.apig.list_metric_data(gateway='gateway_id_here', **attrs)
Querying API Calls Under an API Group in the Last One Hour¶
This example demonstrates how to retrieve API call data for a specific API group over the past hour.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'group_id': 'ce973ff83ce54ef192c80bde884aa0ac',
}
found = conn.apig.list_api_calls_for_group(gateway='gateway_id_here',
**attrs)
Group Response¶
Creating a Group Response¶
This example demonstrates how to create a group response in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "test_group_response",
"responses": {
"NOT_FOUND": {
"status": 404,
"body": "Bad Request",
"headers": [{
"key": "Content-Type",
"value": "application/json",
}]
}
}
}
group_response = conn.apig.create_group_response(
gateway="gateway_id",
group="group_id",
**attrs
)
Querying Group Response Details¶
This example demonstrates how to retrieve details of a specific group response.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
response = conn.apig.get_group_response(
gateway="gateway_id",
group="group_id",
response="response_id"
)
Modifying a Group Response¶
This example demonstrates how to update configuration of an existing group response.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "new_response_name",
}
updated = conn.apig.client.update_group_response(
gateway="gateway_id",
group="group_id",
response="response_id",
**attrs
)
Deleting a Group Response¶
This example demonstrates how to delete a group response from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_group_response(
gateway="gateway_id",
group="group_id",
response="response_id"
)
Querying the Response of an Error Type¶
This example demonstrates how to retrieve the response configuration for a specific error type.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
error_response = conn.apig.get_error_response(
gateway="gateway_id",
group="group_id",
response="response_id",
response_type='NOT_FOUND'
)
Modifying the Response of an Error Type¶
This example demonstrates how to update the response settings for a given error type.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"status": 403,
"body": "{\"error_code\": \"$context.error.code\", "
"\"error_msg\": \"$context.error.message\"}"
}
updated = conn.apig.update_error_response(
gateway="gateway_id",
group="group_id",
response="response_id",
response_type='NOT_FOUND',
**attrs
Deleting the Response of an Error Type¶
This example demonstrates how to delete the response configuration for a specific error type.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
response = conn.apig.delete_error_response(
gateway="gateway_id",
group="group_id",
response="response_id",
response_type='NOT_FOUND'
)
Querying Group Responses¶
This example demonstrates how to list all group responses configured in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
response_list = list(conn.apig.client.group_responses(
gateway="gateway_id",
group="group_id"))
Tag¶
Querying SSL Certificates¶
This example demonstrates how to list SSL certificates configured in the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"limit": 10,
"offset": 0,
"type": "instance",
"instance_id": "gateway"
}
found = list(conn.apig.ssl_certificates(**attrs))
Creating an SSL Certificate¶
This example demonstrates how to create a new SSL certificate.
import openstack
from pathlib import Path
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "cert_demo",
"cert_content": Path("/mnt/c/Users/sand1/fullchain.pem")
.read_text().replace('\r\n', '\n'),
"private_key": Path("/mnt/c/Users/sand1/privkey.pem")
.read_text().replace('\r\n', '\n'),
"type": "instance",
"instance_id": "gateway_id"
}
cert = conn.apig.create_ssl_certificate(**attrs)
Binding a Domain Name with SSL Certificates¶
This example demonstrates how to bind one or more SSL certificates to a domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"url_domain": "test-domain-ssl-cert.com"
}
domain = conn.apig.bind_domain_name(
gateway="gateway_id",
group="group_id",
**attrs
)
attrs = {
"certificate_ids": ["cert_id"]
}
conn.apig.bind_domain_to_certificate(
gateway="gateway_id",
group="group_id",
domain=domain.id,
**attrs
)
Unbinding a Domain Name’s SSL Certificates¶
This example demonstrates how to unbind SSL certificates from a domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"certificate_ids": ["cert_id"]
}
conn.apig.unbind_domain_from_certificate(
gateway="gateway_id",
group="group_id",
domain="domain_id",
**attrs
)
Querying Certificate Details¶
This example demonstrates how to retrieve details of a specific SSL certificate.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
cert = conn.apig.self.get_ssl_certificate(ssl_certificate="cert_id")
Deleting an SSL Certificate¶
This example demonstrates how to delete an SSL certificate from the API Gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.self.delete_ssl_certificate(ssl_certificate="cert_id")
Modifying an SSL Certificate¶
This example demonstrates how to update an existing SSL certificate’s metadata or contents.
import openstack
from pathlib import Path
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "cert_demo",
"cert_content": Path("/mnt/c/Users/sand1/fullchain.pem")
.read_text().replace('\r\n', '\n'),
"private_key": Path("/mnt/c/Users/sand1/privkey.pem")
.read_text().replace('\r\n', '\n'),
}
result = conn.apig.update_ssl_certificate(
ssl_certificate="cert_id",
**attrs
)
Binding an SSL Certificate to a Domain Name¶
This example demonstrates how to bind a specific SSL certificate to a domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"domains": [{
"domain": "test-domain-ssl-cert.com",
"instance_ids": ["gateway_id"]
}]
}
conn.apig.bind_ssl_certificates_for_domain(
ssl_certificate="cert_id",
**attrs
)
Unbinding an SSL Certificate from a Domain Name¶
This example demonstrates how to unbind a specific SSL certificate from a domain name.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"domains": [{
"domain": "test-domain-ssl-cert.com",
"instance_ids": ["gateway_id"]
}]
}
conn.apig.unbind_ssl_certificates_for_domain(
ssl_certificate="cert_id",
**attrs
)
Querying Domain Names of an SSL Certificate¶
This example demonstrates how to list all domain names associated with a given SSL certificate.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
result = list(conn.apig.domains_for_certificate(
ssl_certificate="cert_id"
))
Config¶
Querying Configurations¶
This example demonstrates how to query configurations.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
configs = list(conn.apig.configs())
Querying Configurations for Gateway¶
This example demonstrates how to query configurations of a specific gateway.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
configs = list(conn.apig.configs_for_gateway(
gateway_id="gateway_id"))