Skip to content

Commit 7f86303

Browse files
authored
Rename operation ID to token (#16)
Rename operation ID to token to clarify that it is meant to be opaque. Tokens may be encrypted, signed, and used as OTPs. Also remove the operation ID from the request paths and accept the token as either a query param or a header.
1 parent 3934057 commit 7f86303

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

Diff for: SPEC.md

+44-12
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ An operation is addressed using the following components:
1717
- The containing endpoint, a URL prefix (e.g. `http://api.mycompany.com/services/`)
1818
- Service Name - A grouping of operations (e.g. `payments.v1`)
1919
- Operation Name - A unique name for the given (e.g. `charge`)
20-
- Operation ID - A unique ID assigned by the handler as a response to a [StartOperation](#start-operation) request.
20+
- Operation Token - A unique token assigned by the handler as a response to a [StartOperation](#start-operation)
21+
request.
2122

22-
The service name, operation name, and operation ID MUST not be empty and may contain any arbitrary character sequence as
23-
long as they're encoded into the URL.
23+
The service name and operation name MUST not be empty and may contain any arbitrary character sequence as long as
24+
they're encoded into the URL.
25+
26+
An operation token MUST not be empty and contain only characters that are valid HTTP header values. When passing a token
27+
as part of a URL path make sure any special characters are encoded.
2428

2529
## Schema Definitions
2630

@@ -57,10 +61,10 @@ The `OperationInfo` object MUST adhere to the given schema:
5761
```yaml
5862
type: object
5963
properties:
60-
id:
64+
token:
6165
type: string
6266
description: |
63-
An identifier for referencing this operation.
67+
A token for referencing this operation.
6468
6569
state:
6670
enum:
@@ -150,17 +154,27 @@ The body may contain arbitrary data. Headers should specify content type and enc
150154
Request to cancel an operation. The operation may later complete as canceled or any other outcome. Handlers should
151155
ignore multiple cancelations of the same operation and return successfully if cancelation was already requested.
152156

153-
**Path**: `/{service}/{operation}/{operation_id}/cancel`
157+
**Path**: `/{service}/{operation}/cancel`
154158

155159
**Method**: `POST`
156160

161+
#### Request Headers
162+
163+
The operation token received as a response to the Start Operation method. Must be delivered either via the `token` query
164+
param or the `Nexus-Operation-Token` header field.
165+
166+
#### Query Parameters
167+
168+
- `token`: The operation token received as a response to the Start Operation method. Must be delivered either via the
169+
`token` query param or the `Nexus-Operation-Token` header field.
170+
157171
#### Response Codes
158172

159173
- `202 Accepted`: Cancelation request accepted.
160174

161175
**Body**: Empty.
162176

163-
- `404 Not Found`: Operation ID not recognized or references deleted.
177+
- `404 Not Found`: Operation token not recognized or references deleted.
164178

165179
**Headers**:
166180

@@ -172,12 +186,20 @@ ignore multiple cancelations of the same operation and return successfully if ca
172186

173187
Retrieve operation result.
174188

175-
**Path**: `/{service}/{operation}/{operation_id}/result`
189+
**Path**: `/{service}/{operation}/result`
176190

177191
**Method**: `GET`
178192

193+
#### Request Headers
194+
195+
The operation token received as a response to the Start Operation method. Must be delivered either via the `token` query
196+
param or the `Nexus-Operation-Token` header field.
197+
179198
#### Query Parameters
180199

200+
- `token`: The operation token received as a response to the Start Operation method. Must be delivered either via the
201+
`token` query param or the `Nexus-Operation-Token` header field.
202+
181203
- `wait`: Optional. Duration indicating the waiting period for a result, defaulting to no wait. If by the end of the
182204
wait period the operation is still running, the request should resolve with a 412 status code (see below).
183205

@@ -217,7 +239,7 @@ Retrieve operation result.
217239

218240
**Body**: A JSON serialized [`Failure`](#failure) object.
219241

220-
- `404 Not Found`: Operation ID not recognized or references deleted.
242+
- `404 Not Found`: Operation token not recognized or references deleted.
221243

222244
**Headers**:
223245

@@ -229,10 +251,20 @@ Retrieve operation result.
229251

230252
Retrieve operation details.
231253

232-
**Path**: `/{service}/{operation}/{operation_id}`
254+
**Path**: `/{service}/{operation}`
233255

234256
**Method**: `GET`
235257

258+
#### Request Headers
259+
260+
The operation token received as a response to the Start Operation method. Must be delivered either via the `token` query
261+
param or the `Nexus-Operation-Token` header field.
262+
263+
#### Query Parameters
264+
265+
- `token`: The operation token received as a response to the Start Operation method. Must be delivered either via the
266+
`token` query param or the `Nexus-Operation-Token` header field.
267+
236268
#### Response Codes
237269

238270
- `200 OK`: Successfully retrieved info.
@@ -245,7 +277,7 @@ Retrieve operation details.
245277

246278
A JSON serialized [`OperationInfo`](#operationinfo) object.
247279

248-
- `404 Not Found`: Operation ID not recognized or references deleted.
280+
- `404 Not Found`: Operation token not recognized or references deleted.
249281

250282
**Headers**:
251283

@@ -312,7 +344,7 @@ For invoking a callback URL:
312344
- Issue a POST request to the caller-provided URL.
313345
- Include any callback headers supplied in the originating StartOperation request, stripping away the `Nexus-Callback-`
314346
prefix.
315-
- Include the `Nexus-Operation-Id` header, `Nexus-Operation-Start-Time` and any `Nexus-Link` headers for resources
347+
- Include the `Nexus-Operation-Token` header, `Nexus-Operation-Start-Time` and any `Nexus-Link` headers for resources
316348
associated with this operation to support completing asynchronous operations before the response to StartOperation is
317349
received. `Nexus-Operation-Start-Time` should be in a valid HTTP format described
318350
[here](https://www.rfc-editor.org/rfc/rfc5322.html#section-3.3). If is omitted, the time the completion is received

0 commit comments

Comments
 (0)