我是API网关的新手,到目前为止我尝试的是一个非常强大的工具.对于我现在正在工作的项目,我们在RDS中使用PostgreSQL实例.我已经看到可以从API网关直接访问DynamoDB表,所以我想知道是否有办法为关系数据库这样做.所以我使用GET方法创建了一个资源并将其配置为连接到我的数据库,但我不确定我是否使用了正确的参数:
所以我不确定每个设置字段中的参数.在AWS子域中,我编写了公共URL,就像我从我的pgAdmin客户端连接我一样(没有端口导致完整的结构未被接受,所以我知道我做的事情很糟糕).在此之前,我尝试使用我的RDS资源的ARN,但出现了此错误:
AWS ARN for integration must contains path or action
Run Code Online (Sandbox Code Playgroud)
对于执行角色,我使用策略创建了一个访问Postgres资源的角色.
阅读RDS文档我发现可以使用HTTP动词GET或POST以及名为Action的Query参数从RDS使用查询API,因此我试图弄清楚如何以这种方式放置查询语句:
但是当我测试方法时,这就是响应主体:
{
"message": "AWS ARN for integration contains invalid action"
}
Run Code Online (Sandbox Code Playgroud)
这就是日志:
Execution log for request test-request
Sat Mar 19 15:27:17 UTC 2016 : Execution failed: AWS ARN for integration contains invalid action
Sat Mar 19 15:27:17 UTC 2016 : Method completed with status: 400
Run Code Online (Sandbox Code Playgroud)
我知道我做了很多错事,所以有人知道这是否真的可行以及怎么做,因为我还没有找到任何详细的教程.
我在Postgres创建的新表格中发生了一些奇怪的事情,我可以向它们添加数据,但我无法使用PgAdmin编辑任何行.
这是我的表列描述:
执行查询以查看所有表行后,这是我可以看到的:
保存按钮被禁用以更新我的表行.但是这只发生在我新创建的表中,正如您所看到的,我还有其他表可以编辑行,例如在这个用户表中:
我已经在Curl中尝试了以下命令来使用Firebase REST Api发送通知,它可以正常工作:
curl -X POST --header "Authorization: key=AIza...iD9wk" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"notification\":{\"title\": \"My title\", \"text\": \"My text\", \"sound\": \"default\"}, \"to\": \"cAhmJfN...bNau9z\"}"
Run Code Online (Sandbox Code Playgroud)
既然我正在尝试在Java中做同样的事情,我找不到一个简单的方法来做同样的事情,我尝试过的任何东西都不会触发我的移动端点中的通知.
这是我最接近的方法:
try {
HttpURLConnection httpcon = (HttpURLConnection) ((new URL("https://fcm.googleapis.com/fcm/send").openConnection()));
httpcon.setDoOutput(true);
httpcon.setRequestProperty("Content-Type", "application/json");
httpcon.setRequestProperty("Authorization: key", "AIza...iD9wk");
httpcon.setRequestMethod("POST");
httpcon.connect();
System.out.println("Connected!");
byte[] outputBytes = "{\"notification\":{\"title\": \"My title\", \"text\": \"My text\", \"sound\": \"default\"}, \"to\": \"cAhmJfN...bNau9z\"}".getBytes("UTF-8");
OutputStream os = httpcon.getOutputStream();
os.write(outputBytes);
os.close();
// Reading response
InputStream input = httpcon.getInputStream();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
for (String line; …Run Code Online (Sandbox Code Playgroud) 我有一个包含列的 FinishedGames 表:类别和分数。我需要知道有多少游戏按类别完成了超过一定的分数,但我不明白 PostgreSQL 中的结构计数。
select category, count(score) as rounds, count(if score > 7) as wins
from "FinishedGames" group by category;
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在 PostgreSQL 中做到这一点?
postgresql ×2
amazon-rds ×1
curl ×1
firebase ×1
http ×1
java ×1
pgadmin ×1
pgadmin-4 ×1
post ×1