sha*_*nuo 6 boto amazon-web-services jq aws-api-gateway
我使用网关部署了几个 API。如何以表格格式列出所有这些内容以及集成类型(如 lambda)和方法响应(如 200)等详细信息?
更新:正如答案中所建议的,我可以使用“get-rest-apis”方法来获取所有 API ID 的列表。json 数据可以像这样转换为 pandas dataframe...
# aws apigateway get-rest-apis --region=us-east-1 > /tmp/to_file.json
import pandas as pd
import json
from pandas.io.json import json_normalize
with open("to_file.json") as f:
data = json.load(f)
df = json_normalize(data, "items")
df["createdDate"] = pd.to_datetime(df["createdDate"], unit="s").dt.date
df = df.sort_values(["createdDate"])
df["endpointConfiguration.types"] = df["endpointConfiguration.types"].str[0]
Run Code Online (Sandbox Code Playgroud)
但是如何查询才能获取每个ID的详细信息呢?
为了全面了解给定 API,我需要查询多种方法,例如 get-integration、get-method-response、get-resource。其中每一项都有不同数量的所需参数,这使得自动化过程非常困难。
尽管它可能无法满足您的所有要求(或者可能正是您所需要的),但实现您想要的最简单且最标准化的方法是将 REST API 导出为 OpenAPI 格式(以前的“ Swagger”格式)。API Gateway最近添加了对 3.0 版本的支持。您可以使用所需的附加信息来扩充/扩展输出 JSON。
官方文档:https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-export-api.html
| 归档时间: |
|
| 查看次数: |
3459 次 |
| 最近记录: |