@@ -33,6 +33,12 @@ type HTTPClientOptions struct {
33
33
// A [FailureConverter] to convert a [Failure] instance to and from an [error]. Defaults to
34
34
// [DefaultFailureConverter].
35
35
FailureConverter FailureConverter
36
+ // UseOperationID instructs the client to use an older format of the protocol where operation ID is sent
37
+ // as part of the URL path.
38
+ // This flag will be removed in a future release.
39
+ //
40
+ // NOTE: Experimental
41
+ UseOperationID bool
36
42
}
37
43
38
44
// User-Agent header set on HTTP requests.
@@ -42,7 +48,7 @@ const headerUserAgent = "User-Agent"
42
48
43
49
var errEmptyOperationName = errors .New ("empty operation name" )
44
50
45
- var errEmptyOperationID = errors .New ("empty operation ID " )
51
+ var errEmptyOperationToken = errors .New ("empty operation token " )
46
52
47
53
var errOperationWaitTimeout = errors .New ("operation wait timeout" )
48
54
@@ -268,13 +274,16 @@ func (c *HTTPClient) StartOperation(
268
274
if info .State != OperationStateRunning {
269
275
return nil , newUnexpectedResponseError (fmt .Sprintf ("invalid operation state in response info: %q" , info .State ), response , body )
270
276
}
277
+ if info .Token == "" && info .ID != "" {
278
+ info .Token = info .ID
279
+ }
280
+ handle , err := c .NewHandle (operation , info .Token )
281
+ if err != nil {
282
+ return nil , newUnexpectedResponseError ("empty operation token in response" , response , body )
283
+ }
271
284
return & ClientStartOperationResult [* LazyValue ]{
272
- Pending : & OperationHandle [* LazyValue ]{
273
- Operation : operation ,
274
- ID : info .ID ,
275
- client : c ,
276
- },
277
- Links : links ,
285
+ Pending : handle ,
286
+ Links : links ,
278
287
}, nil
279
288
case statusOperationFailed :
280
289
state , err := getUnsuccessfulStateFromHeader (response , body )
@@ -366,24 +375,25 @@ func (c *HTTPClient) ExecuteOperation(ctx context.Context, operation string, inp
366
375
return handle .GetResult (ctx , gro )
367
376
}
368
377
369
- // NewHandle gets a handle to an asynchronous operation by name and ID .
378
+ // NewHandle gets a handle to an asynchronous operation by name and token .
370
379
// Does not incur a trip to the server.
371
- // Fails if provided an empty operation or ID .
372
- func (c * HTTPClient ) NewHandle (operation string , operationID string ) (* OperationHandle [* LazyValue ], error ) {
380
+ // Fails if provided an empty operation or token .
381
+ func (c * HTTPClient ) NewHandle (operation string , token string ) (* OperationHandle [* LazyValue ], error ) {
373
382
var es []error
374
383
if operation == "" {
375
384
es = append (es , errEmptyOperationName )
376
385
}
377
- if operationID == "" {
378
- es = append (es , errEmptyOperationID )
386
+ if token == "" {
387
+ es = append (es , errEmptyOperationToken )
379
388
}
380
389
if len (es ) > 0 {
381
390
return nil , errors .Join (es ... )
382
391
}
383
392
return & OperationHandle [* LazyValue ]{
384
393
client : c ,
385
394
Operation : operation ,
386
- ID : operationID ,
395
+ ID : token , // Duplicate token as ID for the deprecation period.
396
+ Token : token ,
387
397
}, nil
388
398
}
389
399
0 commit comments