Be consistent about 'payload'
This commit is contained in:
parent
518648b238
commit
692327e276
3 changed files with 7 additions and 6 deletions
|
@ -39,11 +39,11 @@ $ curl -X POST $JOBQ/api/v0/job --data '{"query": [["IS", "json_extract(state, '
|
||||||
```
|
```
|
||||||
|
|
||||||
### POST /api/v0/job/create
|
### POST /api/v0/job/create
|
||||||
Given a JSON document as the POST body, create a new job in the given state.
|
Given a JSON document as the POST body, create a new job with a payload in the given state.
|
||||||
If state is not provided, the state `null` is used.
|
If state is not provided, the state `null` is used.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ curl -X POST $JOBQ/api/v0/job/create --data '{"state": ["CREATED"], "job": {"msg": "Hello, world!"}}' | jq .
|
$ curl -X POST $JOBQ/api/v0/job/create --data '{"state": ["CREATED"], "payload": {"msg": "Hello, world!"}}' | jq .
|
||||||
{
|
{
|
||||||
"id": 1
|
"id": 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,11 +222,11 @@ def create_job():
|
||||||
"""Create a job."""
|
"""Create a job."""
|
||||||
|
|
||||||
blob = request.get_json(force=True)
|
blob = request.get_json(force=True)
|
||||||
job = blob["job"]
|
payload = blob["payload"]
|
||||||
state = blob.get("state", None)
|
state = blob.get("state", None)
|
||||||
id, state = current_app.queries.job_create(
|
id, state = current_app.queries.job_create(
|
||||||
request.db,
|
request.db,
|
||||||
payload=json.dumps(job),
|
payload=json.dumps(payload),
|
||||||
state=json.dumps(state),
|
state=json.dumps(state),
|
||||||
)
|
)
|
||||||
return jsonify({"id": id, "state": state}), 200
|
return jsonify({"id": id, "state": state}), 200
|
||||||
|
|
|
@ -53,11 +53,12 @@ class JobqClient(object):
|
||||||
json={"query": query,
|
json={"query": query,
|
||||||
"state": state}).json())
|
"state": state}).json())
|
||||||
|
|
||||||
def create(self, payload: object) -> DehydratedJob:
|
def create(self, payload: object, state=None) -> DehydratedJob:
|
||||||
"""Create a new job in the system."""
|
"""Create a new job in the system."""
|
||||||
|
|
||||||
job_frag = self._session.post(self._url + "/api/v0/job/create",
|
job_frag = self._session.post(self._url + "/api/v0/job/create",
|
||||||
json=payload)\
|
json={"payload": payload,
|
||||||
|
"state": state})\
|
||||||
.json()
|
.json()
|
||||||
return self._job(job_frag)
|
return self._job(job_frag)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue