简体   繁体   中英

Api Blueprint and long running jobs

I would like to properly design my json API with long running jobs with Blueprint . I need to process files, return a 202 Accepted with a location header and then design the temporary location who will receive 303 See Other and then the final object 201 Created .

Is there a way to properly design this sequence ?

The blueprint could look like this:

# Stars [/stars]

Collection of stars.

## Create [POST]
+ Request (application/json)

    Create a star

    + Body

            {"name": "Death Star"}

+ Response 202

    Request has been accepted into the queue. Poll the queue item to check the result. 

    + Headers

            Location: /queue/12345


# Queue Item [/queue/{id}]

One item in a job queue.

+ Parameters
    + id: 12345 (number) - Id of the queue

## Query Status [GET]
+ Response 200 (aplication/xml)

    The job is still in progress.

    + Body

            <response>
                <status>PENDING</status>
                <eta>2 mins.</eta>
                <link rel="cancel" method="delete" href="/queue/12345" />
            </response>

+ Response 303

    The job has finished. See the created resource.

    + Headers

            Location: /stars/97865

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM