LoginSignup
0
0

More than 3 years have passed since last update.

Python3 の Rest で Cloud Firestore のデータを削除 (Delete)

Posted at
firestore_delete_rest.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#   firestore_delete_rest.py
#
#                   Jan/29/2020
#
# ------------------------------------------------------------------
import  sys
import  json
import  requests
#
from get_token import get_token_proc
# ------------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")
#
key_in = sys.argv[1]
print("%s" % key_in)
#
token = get_token_proc()
#
project = 'project-jan25-2020'
#
url="https://firestore.googleapis.com/v1/projects/" + project + "/databases/(default)/documents/cities/" + key_in
#
try:
    rr=requests.delete(url,headers={"Authorization": "Bearer " + token})
    print(rr.text)
#
except Exception as ee:
    sys.stderr.write("*** error *** in requests.delete ***\n")
    sys.stderr.write(str(ee) + "\n")
#
sys.stderr.write("*** 終了 ***\n")
# ------------------------------------------------------------------

get_token.py はこちら
Python3 の Rest で Cloud Firestore のデータを作成 (Create)

実行コマンド

export GOOGLE_APPLICATION_CREDENTIALS="***.json"
./firestore_delete_rest.py t0924
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0