Skip to content

Commit

Permalink
fix(doc): problematic polling operation for lro delete (#1442)
Browse files Browse the repository at this point in the history
Currently in the offical guide, the same polling operation is shared by
all lro operations, which could cause problems for some emitters since
the lro metadata contains value which doesn't fit for lro delete. See
Azure/autorest.csharp#4827

This commit will create a separate polling operation which fits lro
delete. The same definition is already available in
https://github.com/Azure/typespec-azure/blob/955fc9534c2f7153d45c9fbe5743baa0c104d803/packages/samples/specs/data-plane/trait-versioning/main.tsp#L72-L77

---------

Co-authored-by: Mark Cowlishaw <[email protected]>
  • Loading branch information
archerzz and markcowl authored Oct 23, 2024
1 parent 7b8d751 commit 0ec0106
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/getstarted/azure-core/step06.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ alias ServiceTraits = SupportsRepeatableRequests &
alias Operations = Azure.Core.ResourceOperations<ServiceTraits>;
interface Widgets {
@doc("Gets status of a Widget operation.")
getWidgetOperationStatus is Operations.GetResourceOperationStatus<Widget>;
@doc("Get status of a Widget operation. This operation return status in status code. No response body is returned.")
getWidgetOperationStatus is Operations.GetResourceOperationStatus<Widget, never>;
@doc("Fetch a Widget by name.")
getWidget is Operations.ResourceRead<Widget>;
@doc("Creates or updates a Widget asynchronously.")
@doc("Create or replace a Widget asynchronously.")
@pollingOperation(Widgets.getWidgetOperationStatus)
createOrUpdateWidget is Operations.LongRunningResourceCreateOrUpdate<Widget>;
createOrUpdateWidget is Operations.LongRunningResourceCreateOrReplace<Widget>;
@doc("Delete a Widget asynchronously.")
@pollingOperation(Widgets.getWidgetOperationStatus)
Expand All @@ -36,7 +36,7 @@ interface Widgets {
}
```

1. We change `createOrUpdateWidget` to use `LongRunningResourceCreateOrUpdate<Widget>` and `deleteWidget` to use `LongRunningResourceDelete`.
1. We change `createOrUpdateWidget` to use `LongRunningResourceCreateOrReplace<Widget>` and `deleteWidget` to use `LongRunningResourceDelete`.
2. We define the `getWidgetOperationStatus` operation based on the `GetResourceOperationStatus` signature. This defines the operation status monitor as a child resource of the `Widget` type so that it shows up under that resource in the route hierarchy.
3. We **must** add the `pollingOperation` decorator to both of the long-running operations and reference the `Widgets.getWidgetOperationStatus` operation. This connects the long-running operations to their associated status monitor operation to make it easier for service clients to be generated.

Expand Down

0 comments on commit 0ec0106

Please sign in to comment.