@@ -346,8 +346,11 @@ The request includes the following top-level keys:
346346 **MUST ** conform to the `packaging version
347347 <https://packaging.python.org/en/latest/specifications/version-specifiers/> `_ specification.
348348
349- Upon successful session creation, the server returns a ``201 Created `` response. If an error
350- occurs, the appropriate ``4xx `` code will be returned, as described in the :ref: `session-errors `
349+ Upon successful session creation, the server returns a ``201 Created `` response. The response **MUST ** also
350+ include a ``Location `` header containing the same URL as the :ref: `links.session <publishing-session-links >`
351+ key in the :ref: `response body <publishing-session-response >`.
352+
353+ If an error occurs, the appropriate ``4xx `` code will be returned, as described in the :ref: `session-errors `
351354section.
352355
353356If a session is created for a project which has no previous release,
@@ -362,7 +365,6 @@ The session is owned by the user that created it,
362365and all subsequent requests **MUST ** be performed with the same credentials,
363366otherwise a ``403 Forbidden `` will be returned on those subsequent requests.
364367
365-
366368.. _publishing-session-response :
367369
368370Response Body
@@ -416,12 +418,12 @@ the following keys:
416418 including any uploaded files and the URL links related to the session. The session **SHOULD **
417419 remain active until at least this time unless the client itself has canceled or published the
418420 session. Servers **MAY ** choose to extend this expiration time, but should never move it
419- earlier. Clients can query the :ref: `session status <session-status >` to get the current
421+ earlier. Clients can query the :ref: `session status <publishing- session-status >` to get the current
420422 expiration time of the session.
421423
422424``status ``
423425 A string that contains one of ``pending ``, ``published ``, ``error ``, or ``canceled ``,
424- representing the overall :ref: `status of the session <session-status >`.
426+ representing the overall :ref: `status of the session <publishing- session-status >`.
425427
426428``files ``
427429 A mapping containing the filenames that have been uploaded to this session, to a mapping
@@ -432,6 +434,19 @@ the following keys:
432434 wishes to communicate to the end user. These notices are specific to the overall session, not
433435 to any particular file in the session.
434436
437+ .. _publishing-session-multiple :
438+
439+ Multiple Session Creation Requests
440+ ++++++++++++++++++++++++++++++++++
441+
442+ If a second session is created for the same name-version pair while a session for that pair is in the
443+ ``pending ``, ``processing ``, or ``complete `` state, then the server **MUST ** respond with a ``409 Conflict ``
444+ and **MUST ** include a ``Location `` header that points to the :ref: `session status URL
445+ <publishing-session-status>`.
446+
447+ For sessions in the ``error `` or ``canceled `` state, a new session is created with same ``201 Created ``
448+ response and payload, except that the :ref: `publishing session status URL <publishing-session-status >`,
449+ ``session-token ``, and ``links.stage `` values **MUST ** be different.
435450
436451.. _publishing-session-links :
437452
@@ -440,6 +455,14 @@ Publishing Session Links
440455
441456For the ``links `` key in the success JSON, the following sub-keys are valid:
442457
458+ ``session ``
459+ The endpoint where actions for this session can be performed,
460+ including :ref: `publishing this session <publishing-session-completion >`,
461+ :ref: `canceling and discarding the session <publishing-session-cancellation >`,
462+ :ref: `querying the current session status <publishing-session-status >`,
463+ and :ref: `requesting an extension of the session lifetime <publishing-session-extension >`
464+ (*if * the server supports it).
465+
443466``upload ``
444467 The endpoint session clients will use to initiate a :ref: `File Upload Session <file-upload-session >`
445468 for each file to be included in this session.
@@ -451,14 +474,6 @@ For the ``links`` key in the success JSON, the following sub-keys are valid:
451474 ``stage `` URL should be easily calculated using the ``session-token ``, but the exact format of that URL is
452475 index specific. If the index does not support previewing staged releases, this key **MUST ** be omitted.
453476
454- ``session ``
455- The endpoint where actions for this session can be performed,
456- including :ref: `publishing this session <publishing-session-completion >`,
457- :ref: `canceling and discarding the session <publishing-session-cancellation >`,
458- :ref: `querying the current session status <session-status >`,
459- and :ref: `requesting an extension of the session lifetime <session-extension >`
460- (*if * the server supports it).
461-
462477
463478.. _publishing-session-files :
464479
@@ -489,10 +504,6 @@ sub-mapping with the following keys:
489504 An optional key with similar format and semantics as the ``notices `` session key, except that
490505 these notices are specific to the referenced file.
491506
492- If a second session is created for the same name-version pair while a session for that pair is in
493- the ``pending `` state, then the server **MUST ** return the JSON status response for the already
494- existing session, along with the ``200 OK `` status code rather than creating a new, empty session.
495-
496507
497508.. _publishing-session-completion :
498509
@@ -521,16 +532,17 @@ If the server is able to immediately complete the Publishing Session, it may do
521532request), then it may return a ``202 Accepted `` response.
522533
523534The server **MUST ** include a ``Location `` header in the response pointing back to the :ref: `Publishing
524- Session status <session-status>` URL, which can be used to query the current session status. If the server
535+ Session status <publishing- session-status>` URL, which can be used to query the current session status. If the server
525536returned a ``202 Accepted ``, polling that URL can be used to watch for session status changes.
526537
527538If an error occurs, the appropriate ``4xx `` code should be returned, as described in the
528539:ref: `session-errors ` section.
529540
541+
530542.. _publishing-session-cancellation :
531543
532- Cancellation
533- ~~~~~~~~~~~~
544+ Publishing Session Cancellation
545+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
534546
535547To cancel a Publishing Session, a client issues a ``DELETE `` request to
536548the ``session `` :ref: `link <publishing-session-links >`
@@ -543,7 +555,53 @@ Future attempts to access that session URL or any of the Publishing Session URLs
543555To prevent dangling sessions, servers may also choose to cancel timed-out sessions on their own
544556accord. It is recommended that servers expunge their sessions after no less than a week, but each
545557server may choose their own schedule. Servers **MAY ** support client-directed :ref: `session
546- extensions <session-extension>`.
558+ extensions <publishing-session-extension>`.
559+
560+
561+ .. _publishing-session-status :
562+
563+ Publishing Session Status
564+ ~~~~~~~~~~~~~~~~~~~~~~~~~
565+
566+ At any time, a client can query the status of a session by issuing a ``GET `` request to the URL given in the
567+ :ref: `links.session <publishing-session-links >` URL (also provided in the :ref: `session creation response's
568+ <publishing-session-response>` ``Location `` header).
569+
570+ The server will respond to this ``GET `` request with the same :ref: `publishing session creation response
571+ <publishing-session-response>`, that they got when they initially created the publishing session, except with
572+ any changes to ``status ``, ``expires-at ``, or ``files `` reflected.
573+
574+
575+ .. _publishing-session-extension :
576+
577+ Publishing Session Extension
578+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
579+
580+ Servers **MAY ** allow clients to extend sessions, but the overall lifetime and number of extensions
581+ allowed is left to the server. To extend a session, a client issues a ``POST `` request to the
582+ :ref: `links.session <publishing-session-links >` URL (same as above, also the ``Location `` header).
583+
584+ The request looks like:
585+
586+ .. code-block :: json
587+
588+ {
589+ "meta" : {
590+ "api-version" : " 2.0"
591+ },
592+ "action" : " extend" ,
593+ "extend-for" : 3600
594+ }
595+
596+ The number of seconds specified is just a suggestion to the server for the number of additional seconds to
597+ extend the current session. For example, if the client wants to extend the current session for another hour,
598+ ``extend-for `` would be ``3600 ``. Upon successful extension, the server will respond with the same
599+ :ref: `publishing session creation response body <publishing-session-response >` that they got when they
600+ initially created the publishing session, except with any changes to ``status ``, ``expires-at ``, or ``files ``
601+ reflected.
602+
603+ If the server refuses to extend the session for the requested number of seconds, it **MUST ** still return a
604+ success response, and the ``expires-at `` key will simply reflect the current expiration time of the session.
547605
548606
549607.. _publishing-session-token :
@@ -646,7 +704,7 @@ the file to be uploaded. These checks may include, but are not limited to:
646704- checking if the contents of the ``metadata ``, if provided, are valid.
647705
648706If the server determines that upload should proceed, it will return a ``202 Accepted `` response, with the
649- response body below. The :ref: `status <session-status >` of the session will also include the filename in the
707+ response body below. The :ref: `status <publishing- session-status >` of the session will also include the filename in the
650708``files `` mapping. If the server cannot proceed with an upload because the ``mechanism `` supplied by the
651709client is not supported it **MUST ** return a ``422 Unprocessable Content ``. The server **MAY ** allow parallel
652710uploads of files, but is not required to. If the server determines the upload cannot proceed, it **MUST **
@@ -666,7 +724,6 @@ The successful response includes the following:
666724 "api-version" : " 2.0"
667725 },
668726 "links" : {
669- "publishing-session" : " ..." ,
670727 "file-upload-session" : " ..."
671728 },
672729 "status" : " pending" ,
@@ -712,14 +769,13 @@ File Upload Session Links
712769
713770For the ``links `` key in the success JSON, the following sub-keys are valid:
714771
715- ``publishing-session ``
716- The endpoint where actions for the parent Publishing Session can be performed.
772+ **FIXME **: file-upload-session, rename and add status.
717773
718774``file-upload-session ``
719775 The endpoint where actions for this file-upload-session can be performed.
720776 including :ref: `canceling and discarding the File Upload Session <file-upload-session-cancelation >`,
721- :ref: `querying the current File Upload Session status <session-status >`,
722- and :ref: `requesting an extension of the File Upload Session lifetime <session-extension >`
777+ :ref: `querying the current File Upload Session status <publishing- session-status >`,
778+ and :ref: `requesting an extension of the File Upload Session lifetime <publishing- session-extension >`
723779 (*if * the server supports it).
724780
725781.. _file-upload-session-completion :
@@ -795,63 +851,6 @@ This means providing the metadata request again to retrieve a new upload resourc
795851Clients **MUST NOT ** assume that the previous upload resource URL can be reused after deletion.
796852
797853
798- .. _session-status :
799-
800- Session Status
801- --------------
802-
803- At any time, a client can query the status of a session by issuing a ``GET `` request to the
804- ``publishing-session `` :ref: `link <publishing-session-links >`
805- or ``file-upload-session `` :ref: `link <file-upload-session-links >`
806- given in the :ref: `session creation response body <publishing-session-response >`
807- or :ref: `File Upload Session creation response body <file-upload-session-response >`,
808- respectively.
809-
810- The server will respond to this ``GET `` request with the same
811- :ref: `Publishing Session creation response body <publishing-session-response >`
812- or :ref: `File Upload Session creation response body <file-upload-session-response >`,
813- that they got when they initially created the Publishing Session or File Upload Session,
814- except with any changes to ``status ``, ``expires-at ``, or ``files `` reflected.
815-
816-
817- .. _session-extension :
818-
819- Session Extension
820- -----------------
821-
822- Servers **MAY ** allow clients to extend sessions, but the overall lifetime and number of extensions
823- allowed is left to the server. To extend a session, a client issues a ``POST `` request to the
824- ``publishing-session `` :ref: `link <publishing-session-links >`
825- or ``file-upload-session `` :ref: `link <file-upload-session-links >`
826- given in the :ref: `Publishing Session creation response body <publishing-session-response >`
827- or :ref: `File Upload Session creation response body <file-upload-session-response >`,
828- respectively.
829-
830- The request looks like:
831-
832- .. code-block :: json
833-
834- {
835- "meta" : {
836- "api-version" : " 2.0"
837- },
838- "action" : " extend" ,
839- "extend-for" : 3600
840- }
841-
842- The number of seconds specified is just a suggestion to the server for the number of additional
843- seconds to extend the current session. For example, if the client wants to extend the current
844- session for another hour, ``extend-for `` would be ``3600 ``. Upon successful extension, the server
845- will respond with the same
846- :ref: `Publishing Session creation response body <publishing-session-response >`
847- or :ref: `File Upload Session creation response body <file-upload-session-response >`,
848- that they got when they initially created the Publishing Session or File Upload Session,
849- except with any changes to ``status ``, ``expires-at ``, or ``files `` reflected.
850-
851- If the server refuses to extend the session for the requested number of seconds, it still returns a
852- success response, and the ``expires-at `` key will simply reflect the current expiration time of
853- the session.
854-
855854.. _staged-preview :
856855
857856Stage Previews
0 commit comments