# Google Dataflow API . projects . jobs . workItems

## Instance Methods

Leases a dataflow WorkItem to run.

Reports the status of dataflow WorkItems leased by a worker.

### Method Details

`lease(projectId, jobId, body)`

    Leases a dataflow WorkItem to run.

    Args:
      projectId: string, A parameter (required)
      jobId: string, A parameter (required)
      body: object, The request body. (required)
        The object takes the form of:

    {
        "requestedLeaseDuration": "A String",
        "workItemTypes": [
          "A String",
        ],
        "workerCapabilities": [
          "A String",
        ],
        "currentWorkerTime": "A String",
        "workerId": "A String",
      }

    Returns:
      An object of the form:

        {
        "workItems": [
          {
            "packages": [
              {
                "location": "A String",
                "name": "A String",
              },
            ],
            "leaseExpireTime": "A String",
            "seqMapTask": {
              "inputs": [
                {
                  "sources": [
                    {
                      "codec": {
                        "a_key": "",
                      },
                      "baseSpecs": [
                        {
                          "a_key": "",
                        },
                      ],
                      "spec": {
                        "a_key": "",
                      },
                      "doesNotNeedSplitting": True or False,
                      "metadata": {
                        "infinite": True or False,
                        "estimatedSizeBytes": "A String",
                        "producesSortedKeys": True or False,
                      },
                    },
                  ],
                  "kind": {
                    "a_key": "",
                  },
                  "tag": "A String",
                },
              ],
              "name": "A String",
              "stageName": "A String",
              "systemName": "A String",
              "userFn": {
                "a_key": "",
              },
              "outputInfos": [
                {
                  "tag": "A String",
                  "sink": {
                    "codec": {
                      "a_key": "",
                    },
                    "spec": {
                      "a_key": "",
                    },
                  },
                },
              ],
            },
            "projectId": "A String",
            "sourceOperationTask": {
              "getMetadata": {
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
              },
              "split": {
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
                "options": {
                  "desiredShardSizeBytes": "A String",
                  "desiredBundleSizeBytes": "A String",
                },
              },
            },
            "initialReportIndex": "A String",
            "mapTask": {
              "systemName": "A String",
              "stageName": "A String",
              "instructions": [
                {
                  "name": "A String",
                  "read": {
                    "source": {
                      "codec": {
                        "a_key": "",
                      },
                      "baseSpecs": [
                        {
                          "a_key": "",
                        },
                      ],
                      "spec": {
                        "a_key": "",
                      },
                      "doesNotNeedSplitting": True or False,
                      "metadata": {
                        "infinite": True or False,
                        "estimatedSizeBytes": "A String",
                        "producesSortedKeys": True or False,
                      },
                    },
                  },
                  "outputs": [
                    {
                      "codec": {
                        "a_key": "",
                      },
                      "name": "A String",
                    },
                  ],
                  "partialGroupByKey": {
                    "input": {
                      "outputNum": 42,
                      "producerInstructionIndex": 42,
                    },
                    "valueCombiningFn": {
                      "a_key": "",
                    },
                    "inputElementCodec": {
                      "a_key": "",
                    },
                  },
                  "write": {
                    "input": {
                      "outputNum": 42,
                      "producerInstructionIndex": 42,
                    },
                    "sink": {
                      "codec": {
                        "a_key": "",
                      },
                      "spec": {
                        "a_key": "",
                      },
                    },
                  },
                  "systemName": "A String",
                  "flatten": {
                    "inputs": [
                      {
                        "outputNum": 42,
                        "producerInstructionIndex": 42,
                      },
                    ],
                  },
                  "parDo": {
                    "sideInputs": [
                      {
                        "sources": [
                          {
                            "codec": {
                              "a_key": "",
                            },
                            "baseSpecs": [
                              {
                                "a_key": "",
                              },
                            ],
                            "spec": {
                              "a_key": "",
                            },
                            "doesNotNeedSplitting": True or False,
                            "metadata": {
                              "infinite": True or False,
                              "estimatedSizeBytes": "A String",
                              "producesSortedKeys": True or False,
                            },
                          },
                        ],
                        "kind": {
                          "a_key": "",
                        },
                        "tag": "A String",
                      },
                    ],
                    "input": {
                      "outputNum": 42,
                      "producerInstructionIndex": 42,
                    },
                    "multiOutputInfos": [
                      {
                        "tag": "A String",
                      },
                    ],
                    "numOutputs": 42,
                    "userFn": {
                      "a_key": "",
                    },
                  },
                },
              ],
            },
            "jobId": "A String",
            "streamingComputationTask": {
              "taskType": "A String",
              "computationRanges": [
                {
                  "rangeAssignments": [
                    {
                      "start": "A String",
                      "end": "A String",
                      "dataDisk": "A String",
                    },
                  ],
                  "computationId": "A String",
                },
              ],
              "dataDisks": [
                {
                  "dataDisk": "A String",
                },
              ],
            },
            "reportStatusInterval": "A String",
            "streamingSetupTask": {
              "workerHarnessPort": 42,
              "streamingComputationTopology": {
                "computations": [
                  {
                    "inputs": [
                      {
                        "streamingStageLocation": {
                          "streamId": "A String",
                        },
                        "pubsubLocation": {
                          "idLabel": "A String",
                          "timestampLabel": "A String",
                          "dropLateData": True or False,
                          "topic": "A String",
                          "trackingSubscription": "A String",
                          "subscription": "A String",
                        },
                        "sideInputLocation": {
                          "tag": "A String",
                        },
                      },
                    ],
                    "computationId": "A String",
                    "keyRanges": [
                      {
                        "start": "A String",
                        "deliveryEndpoint": "A String",
                        "end": "A String",
                        "persistentDirectory": "A String",
                        "dataDisk": "A String",
                      },
                    ],
                    "outputs": [
                      {
                        "streamingStageLocation": {
                          "streamId": "A String",
                        },
                        "pubsubLocation": {
                          "idLabel": "A String",
                          "timestampLabel": "A String",
                          "dropLateData": True or False,
                          "topic": "A String",
                          "trackingSubscription": "A String",
                          "subscription": "A String",
                        },
                        "sideInputLocation": {
                          "tag": "A String",
                        },
                      },
                    ],
                  },
                ],
                "dataDiskAssignments": [
                  {
                    "vmInstance": "A String",
                    "dataDisks": [
                      "A String",
                    ],
                  },
                ],
              },
              "receiveWorkPort": 42,
            },
            "configuration": "A String",
            "shellTask": {
              "command": "A String",
              "exitCode": 42,
            },
            "id": "A String",
          },
        ],
      }

`reportStatus(projectId, jobId, body)`

    Reports the status of dataflow WorkItems leased by a worker.

    Args:
      projectId: string, A parameter (required)
      jobId: string, A parameter (required)
      body: object, The request body. (required)
        The object takes the form of:

    {
        "workerId": "A String",
        "currentWorkerTime": "A String",
        "workItemStatuses": [
          {
            "reportIndex": "A String",
            "errors": [
              {
                "message": "A String",
                "code": 42,
                "details": [
                  {
                    "a_key": "",
                  },
                ],
              },
            ],
            "sourceOperationResponse": {
              "getMetadata": {
                "metadata": {
                  "infinite": True or False,
                  "estimatedSizeBytes": "A String",
                  "producesSortedKeys": True or False,
                },
              },
              "split": {
                "outcome": "A String",
                "bundles": [
                  {
                    "derivationMode": "A String",
                    "source": {
                      "codec": {
                        "a_key": "",
                      },
                      "baseSpecs": [
                        {
                          "a_key": "",
                        },
                      ],
                      "spec": {
                        "a_key": "",
                      },
                      "doesNotNeedSplitting": True or False,
                      "metadata": {
                        "infinite": True or False,
                        "estimatedSizeBytes": "A String",
                        "producesSortedKeys": True or False,
                      },
                    },
                  },
                ],
                "shards": [
                  {
                    "derivationMode": "A String",
                    "source": {
                      "codec": {
                        "a_key": "",
                      },
                      "baseSpecs": [
                        {
                          "a_key": "",
                        },
                      ],
                      "spec": {
                        "a_key": "",
                      },
                      "doesNotNeedSplitting": True or False,
                      "metadata": {
                        "infinite": True or False,
                        "estimatedSizeBytes": "A String",
                        "producesSortedKeys": True or False,
                      },
                    },
                  },
                ],
              },
            },
            "stopPosition": {
              "recordIndex": "A String",
              "end": True or False,
              "byteOffset": "A String",
              "key": "A String",
              "shufflePosition": "A String",
            },
            "sourceFork": {
              "residualSource": {
                "derivationMode": "A String",
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
              },
              "primarySource": {
                "derivationMode": "A String",
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
              },
              "primary": {
                "derivationMode": "A String",
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
              },
              "residual": {
                "derivationMode": "A String",
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
              },
            },
            "requestedLeaseDuration": "A String",
            "completed": True or False,
            "workItemId": "A String",
            "dynamicSourceSplit": {
              "primary": {
                "derivationMode": "A String",
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
              },
              "residual": {
                "derivationMode": "A String",
                "source": {
                  "codec": {
                    "a_key": "",
                  },
                  "baseSpecs": [
                    {
                      "a_key": "",
                    },
                  ],
                  "spec": {
                    "a_key": "",
                  },
                  "doesNotNeedSplitting": True or False,
                  "metadata": {
                    "infinite": True or False,
                    "estimatedSizeBytes": "A String",
                    "producesSortedKeys": True or False,
                  },
                },
              },
            },
            "progress": {
              "position": {
                "recordIndex": "A String",
                "end": True or False,
                "byteOffset": "A String",
                "key": "A String",
                "shufflePosition": "A String",
              },
              "remainingTime": "A String",
              "percentComplete": 3.14,
            },
            "metricUpdates": [
              {
                "meanCount": "",
                "kind": "A String",
                "set": "",
                "name": {
                  "origin": "A String",
                  "name": "A String",
                  "context": {
                    "a_key": "A String",
                  },
                },
                "meanSum": "",
                "cumulative": True or False,
                "updateTime": "A String",
                "scalar": "",
                "internal": "",
              },
            ],
          },
        ],
      }

    Returns:
      An object of the form:

        {
        "workItemServiceStates": [
          {
            "reportStatusInterval": "A String",
            "suggestedStopPosition": {
              "recordIndex": "A String",
              "end": True or False,
              "byteOffset": "A String",
              "key": "A String",
              "shufflePosition": "A String",
            },
            "leaseExpireTime": "A String",
            "nextReportIndex": "A String",
            "harnessData": {
              "a_key": "",
            },
            "suggestedStopPoint": {
              "position": {
                "recordIndex": "A String",
                "end": True or False,
                "byteOffset": "A String",
                "key": "A String",
                "shufflePosition": "A String",
              },
              "remainingTime": "A String",
              "percentComplete": 3.14,
            },
          },
        ],
      }