{
  "version": 0,
  "execution": {
    "transactionMode": "SAFE_AUTO_COMMIT"
  },
  "requires": [
    {
      "id": "runtime.python"
    }
  ],
  "entry": "b1",
  "blocks": {
    "b1": {
      "type": "setVar",
      "inputs": {
        "name": "pythonPath",
        "value": {
          "type": "resolveCapabilityExecutable",
          "inputs": {
            "id": "runtime.python"
          }
        }
      },
      "next": "b2"
    },
    "b2": {
      "type": "setVar",
      "inputs": {
        "name": "selectedItems",
        "value": {
          "type": "prListProjectItems",
          "inputs": {
            "onlySelected": true,
            "includeSubbins": "BIN_AND_SUBBINS"
          }
        }
      },
      "next": "b3"
    },
    "b3": {
      "type": "setVar",
      "inputs": {
        "name": "selectedItem",
        "value": {
          "type": "listGet",
          "inputs": {
            "list": {
              "var": "selectedItems"
            },
            "where": "FIRST"
          }
        }
      },
      "next": "b4"
    },
    "b4": {
      "type": "setVar",
      "inputs": {
        "name": "cameraMetadata",
        "value": {
          "type": "prGetProjectItemCameraMetadata",
          "inputs": {
            "item": {
              "var": "selectedItem"
            }
          }
        }
      },
      "next": "b5"
    },
    "b5": {
      "type": "setVar",
      "inputs": {
        "name": "cameraMetadataJson",
        "value": {
          "type": "jsonStringify",
          "inputs": {
            "value": {
              "var": "cameraMetadata"
            },
            "pretty": false
          }
        }
      },
      "next": "b6"
    },
    "b6": {
      "type": "createFolder",
      "inputs": {
        "path": "::HOME::/automation-agent-runtime-tests"
      },
      "next": "b7"
    },
    "b7": {
      "type": "setVar",
      "inputs": {
        "name": "runSuffix",
        "value": {
          "type": "mathRandomInt",
          "inputs": {
            "a": 100000,
            "b": 999999
          }
        }
      },
      "next": "b8"
    },
    "b8": {
      "type": "setVar",
      "inputs": {
        "name": "jsonPath",
        "value": {
          "type": "resolveSpecialPath",
          "inputs": {
            "path": {
              "type": "textJoin",
              "inputs": {
                "items": [
                  "::HOME::/automation-agent-runtime-tests/camera-metadata-",
                  {
                    "var": "runSuffix"
                  },
                  ".json"
                ]
              }
            }
          }
        }
      },
      "next": "b9"
    },
    "b9": {
      "type": "writeTextFile",
      "inputs": {
        "path": {
          "var": "jsonPath"
        },
        "text": {
          "var": "cameraMetadataJson"
        },
        "append": false,
        "flushNow": true
      },
      "next": "b10"
    },
    "b10": {
      "type": "esConsoleLog",
      "inputs": {
        "message": {
          "type": "textJoin",
          "inputs": {
            "items": [
              "HANDOFF|path=",
              {
                "type": "jsonStringify",
                "inputs": {
                  "value": {
                    "var": "jsonPath"
                  },
                  "pretty": false
                }
              },
              "|cleanup=best-effort-after-normal-process-completion"
            ]
          }
        }
      },
      "next": "b11"
    },
    "b11": {
      "type": "runExternalProgram",
      "inputs": {
        "program": {
          "var": "pythonPath"
        },
        "args": [
          "-I",
          "-c",
          "import json,sys; data=json.load(open(sys.argv[1],encoding='utf-8')); print(json.dumps({'fieldCount':len(data),'model':data.get('model')},separators=(',',':')))",
          {
            "var": "jsonPath"
          }
        ],
        "timeoutMs": 10000,
        "maxOutputBytes": 4096,
        "storeExitCodeIn": "pythonExitCode",
        "storeStdoutIn": "pythonStdout",
        "storeStderrIn": "pythonStderr"
      },
      "next": "b12"
    },
    "b12": {
      "type": "deleteFile",
      "inputs": {
        "path": {
          "var": "jsonPath"
        },
        "reason": "Remove the per-run randomized camera metadata handoff file after Python has read it.",
        "onError": "CONTINUE"
      },
      "next": "b13"
    },
    "b13": {
      "type": "esConsoleLog",
      "inputs": {
        "message": {
          "type": "textJoin",
          "inputs": {
            "items": [
              "SUMMARY|pythonExitCode=",
              {
                "var": "pythonExitCode"
              },
              "|stdout=\"",
              {
                "var": "pythonStdout"
              },
              "\"|stderr=\"",
              {
                "var": "pythonStderr"
              },
              "\""
            ]
          }
        }
      },
      "next": null
    }
  }
}
