Open
Description
Context / Requirement
LRO in mgmt follows a certain pattern, which is quite different from data-plane.
- The response of PUT or PATCH is the resource, with
provisioningState
indicate the LRO state. - The response of PUT or PATCH could be 200, with
provisioningState=Succeeded
(e.g. when the resource exists in backend and there is no difference). In this case, no polling is needed (not GET need to be sent). - The
id
in response of PUT or PATCH is important for customer. They can use it to query the resource. In some case, it can be used to query info related to this resource (e.g. in ARM templatedeployment
, theid
is used to query the details of this deployment).
Therefore, mgmt would like
- Poller can return the response of the PUT or PATCH (the response of the activation/initial operation).
- API/Poller gives consistence exception (particularly,
ManagementException
onpoller.getFinalResult
) when failed to create resource.
Current (v1)
mgmt implemented this design for some LRO APIs
// API, throws com.azure.core.management.exception.ManagementException If fails to create/update resource.
Deployment createOrUpdate(...);
Accepted<Deployment> beginCreateOrUpdate(...);
// interface
public interface Accepted<U> {
/**
* Gets the activation response of LRO.
*
* @return the activation response
*/
ActivationResponse<U> getActivationResponse();
/**
* Gets the {@link SyncPoller} of LRO.
*
* @return the sync poller.
*/
SyncPoller<Void, U> getSyncPoller();
/**
* Gets the final result of LRO.
*
* @return the final result.
* @throws com.azure.core.management.exception.ManagementException If polling fails.
*/
U getFinalResult();
}
for the LRO PUT/POST/DELETE.
(for DELETE, T=Void
)
The getFinalResult()
is just a wrapper of getSyncPoller().getFinalResult()
.
The SyncPoller
would throw a ManagementException
if LRO is not Succeeded
. Otherwise, it be same as typical SyncPoller
.
related classes
- Accepted
- ActivationResponse (it is just
SimpleResponse
+ LRO state + retryAfter) - AcceptedImpl
v2
We'd like to explore
- Whether we should have such pattern built-in to mgmt codegen
- Whether we should build the pattern into the subclass of Poller, e.g.
public final class ManagementPoller implements Poller<T, U> {
public ActivationResponse<U> getActivationResponse();
...
}
- What do we do to POST (resource action)