-
-
Save sisimaimai/c71d27e2ab0e41b1452e7af1bb0feab1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main: | |
params: [args] | |
steps: | |
- transferAll: | |
parallel: | |
for: | |
value: device_id | |
in: ${args.device_ids} | |
steps: | |
- transferEach: | |
call: transferThermalInfo | |
args: | |
device_id: ${device_id} | |
transferThermalInfo: | |
params: | |
- device_id | |
steps: | |
# 温度情報の取得 | |
- getThermalInfo: | |
try: | |
steps: | |
- executeRequest: | |
call: http.get | |
args: | |
url: {switchbot_thermal_getterでデプロイしたCloudFunctionのURL} # 要記載 | |
query: | |
device_id: ${device_id} | |
auth: | |
type: OIDC | |
result: thermal_info_response | |
- printResponse: | |
call: sys.log | |
args: | |
data: ${thermal_info_response} | |
severity: INFO | |
retry: | |
predicate: ${http.default_retry_predicate_non_idempotent} | |
max_retries: 5 | |
backoff: | |
initial_delay: 5 | |
max_delay: 10 | |
multiplier: 1.2 | |
- printThermalInfo: | |
call: sys.log | |
args: | |
data: ${thermal_info_response.body} | |
severity: INFO | |
- decodeThermalInfo: | |
assign: | |
- thermal_info: ${json.decode(thermal_info_response.body)} | |
# Pub/Sub経由でBigQueryに送信 | |
- printEncoded: | |
call: sys.log | |
args: | |
text: ${base64.encode(json.encode(thermal_info))} | |
severity: DEBUG | |
- transferToBigquery: | |
try: | |
call: googleapis.pubsub.v1.projects.topics.publish | |
args: | |
topic: {BigQueryサブスクリプションを設定したPubSubトピック} # 要記載 | |
body: | |
messages: | |
- data: ${base64.encode(json.encode(thermal_info))} | |
result: publishResult | |
retry: ${http.default_retry} | |
- printPublishResult: | |
call: sys.log | |
args: | |
data: ${publishResult} | |
severity: INFO | |
- endTransfer: | |
call: sys.log | |
args: | |
text: '${"transfer " + device_id + " finished!"}' | |
severity: INFO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment