curl で Cloud Firestore のデータを取得
3083 ワード
Cloud Firestore の RestAPI を使ってデータを取得します。
1) project-aaa の cities の t0921 を取得
export GOOGLE_APPLICATION_CREDENTIALS="***.json"
ACCESS_TOKEN=`gcloud auth application-default print-access-token`
#
project_id=`jq .project_id $GOOGLE_APPLICATION_CREDENTIALS | sed "s/\"//g"`
echo $project_id
URL='https://firestore.googleapis.com/v1/projects/'$project_id'/databases/(default)/documents/cities'
#
#
curl -H "Authorization: Bearer $ACCESS_TOKEN" $URL"/t0921"
実行結果
{
"name": "projects/project-jan25-2020/databases/(default)/documents/cities/t0921",
"fields": {
"population": {
"integerValue": "81235"
},
"name": {
"stringValue": "宇都宮"
},
"date_mod": {
"stringValue": "1950-9-24"
}
},
"createTime": "2020-01-25T06:14:38.983529Z",
"updateTime": "2020-01-25T06:23:16.019805Z"
}
2) Collection 内の全てのデータを取得
export GOOGLE_APPLICATION_CREDENTIALS="***.json"
ACCESS_TOKEN=`gcloud auth application-default print-access-token`
#
project_id=`jq .project_id $GOOGLE_APPLICATION_CREDENTIALS | sed "s/\"//g"`
echo $project_id
URL='https://firestore.googleapis.com/v1/projects/'$project_id'/databases/(default)/documents/cities'
#
curl -H "Authorization: Bearer $ACCESS_TOKEN" $URL
Author And Source
この問題について(curl で Cloud Firestore のデータを取得), 我々は、より多くの情報をここで見つけました https://qiita.com/ekzemplaro/items/07232715da9ea4c8c6b7著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .