Long-Running Operations
This doc details what emitters will generate for long-running operations.
Resource create or replace​
Long-running operation to create or replace a resource.
- TypeSpec
- Python
- CSharp
- Typescript
- Java
alias ResourceOperations = global.Azure.Core.ResourceOperations<NoConditionalRequests &
NoRepeatableRequests &
NoClientRequestId>;
@resource("users")
@doc("Details about a user.")
model User {
@key
@visibility("read")
@doc("The name of user.")
name: string;
@doc("The role of user")
role: string;
}
// Operation for polling the status of the LRO. SDK may exclude this operation from client.
@sharedRoute
op getOperationStatus is ResourceOperations.GetResourceOperationStatus<User, never>;
@pollingOperation(getOperationStatus)
op createOrReplace is ResourceOperations.LongRunningResourceCreateOrReplace<User>;
def begin_create_or_replace(
self, name: str, resource: Union[User, JSON, IO[bytes]], **kwargs: Any
) -> LROPoller[User]
public SyncPoller<PollOperationDetails, User> beginCreateOrReplace(String name, User resource);
Resource delete​
Long-running operation to delete a resource.
- TypeSpec
- Python
- CSharp
- Typescript
- Java
@pollingOperation(getOperationStatus)
op delete is ResourceOperations.LongRunningResourceDelete<User>;
def begin_delete(self, name: str, **kwargs: Any) -> LROPoller[None]
public SyncPoller<PollOperationDetails, Void> beginDelete(String name);
Resource action​
Long-running operation to invoke an action on a resource.
- TypeSpec
- Python
- CSharp
- Typescript
- Java
@resource("users")
@doc("Details about a user.")
model User {
@key
@visibility("read")
@doc("The name of user.")
name: string;
@doc("The role of user")
role: string;
}
@doc("The parameters for exporting a user.")
model UserExportParams {
@query
@doc("The format of the data.")
format: string;
}
@doc("The exported user data.")
model ExportedUser {
@doc("The name of user.")
name: string;
@doc("The exported URI.")
resourceUri: string;
}
// Operation for polling the status of the LRO. SDK may exclude this operation from client.
@sharedRoute
op getExportOperationStatus is ResourceOperations.GetResourceOperationStatus<User, ExportedUser>;
@pollingOperation(getExportOperationStatus)
op export is ResourceOperations.LongRunningResourceAction<User, UserExportParams, ExportedUser>;
def begin_export(self, name: str, *, format: str, **kwargs: Any) -> LROPoller[ExportedUser]
public SyncPoller<PollOperationDetails, ExportedUser> beginExport(String name, String format);