diff --git a/.changeset/popular-tables-yawn.md b/.changeset/popular-tables-yawn.md new file mode 100644 index 000000000..b8b871ac1 --- /dev/null +++ b/.changeset/popular-tables-yawn.md @@ -0,0 +1,5 @@ +--- +"@azure-tools/cadl-ranch-specs": patch +--- + +Use pollingOperation to customize non-standard LRO diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 80f5db849..379ac4365 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -315,7 +315,9 @@ Expected response body: ### Azure_Core_Lro_Rpc_Legacy_CreateResourcePollViaOperationLocation -- Endpoint: `post /azure/core/lro/rpc/legacy/create-resource-poll-via-operation-location/jobs` +- Endpoints: + - `get /azure/core/lro/rpc/legacy/create-resource-poll-via-operation-location` + - `get /azure/core/lro/rpc/legacy/create-resource-poll-via-operation-location/jobs` POST to create resource. Poll URL via operation-location header in response. diff --git a/packages/cadl-ranch-specs/http/azure/core/lro/rpc-legacy/main.tsp b/packages/cadl-ranch-specs/http/azure/core/lro/rpc-legacy/main.tsp index 3eb71b297..35ab7e84f 100644 --- a/packages/cadl-ranch-specs/http/azure/core/lro/rpc-legacy/main.tsp +++ b/packages/cadl-ranch-specs/http/azure/core/lro/rpc-legacy/main.tsp @@ -2,7 +2,6 @@ import "@azure-tools/typespec-azure-core"; import "@azure-tools/cadl-ranch-expect"; import "@typespec/rest"; import "@typespec/versioning"; -import "./util.tsp"; using TypeSpec.Rest; using TypeSpec.Http; @@ -138,10 +137,11 @@ Expected response body: """) @route("/create-resource-poll-via-operation-location") interface CreateResourcePollViaOperationLocation { - #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Legacy LRO uses local template" - #suppress "@azure-tools/typespec-azure-core/long-running-polling-operation-required" "Operation link pollingOperation is not required for getLroMetadata" + @doc("Poll a Job") + getJob is ResourceOperations.ResourceRead; + + @pollingOperation(CreateResourcePollViaOperationLocation.getJob) @doc("Creates a Job") @route("/jobs") - @post - createJob is Local.LongRunningLegacyOperation; + createJob is LongRunningRpcOperation; } diff --git a/packages/cadl-ranch-specs/http/azure/core/lro/rpc-legacy/util.tsp b/packages/cadl-ranch-specs/http/azure/core/lro/rpc-legacy/util.tsp deleted file mode 100644 index bd88efe6b..000000000 --- a/packages/cadl-ranch-specs/http/azure/core/lro/rpc-legacy/util.tsp +++ /dev/null @@ -1,26 +0,0 @@ -import "@azure-tools/typespec-azure-core"; - -using TypeSpec.Versioning; -using Azure.Core; - -@useDependency(global.Azure.Core.Versions.v1_0_Preview_2) -namespace Local { - // Ref https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/HealthInsights/healthinsights.common/primitives.tsp - // Ref https://github.com/Azure/typespec-azure/issues/3108 - #suppress "@azure-tools/typespec-azure-core/long-running-polling-operation-required" "This is a template" - @Foundations.Private.needsRoute - @doc("Long running legacy operation template") - op LongRunningLegacyOperation< - TParams extends TypeSpec.Reflection.Model, - TResponse, - TPollResponse extends TypeSpec.Reflection.Model = Foundations.OperationStatus - > is Azure.Core.Foundations.Operation< - TParams, - Foundations.AcceptedResponse<{ - @pollingLocation - @doc("The location for monitoring the operation state.") - @TypeSpec.Http.header("Operation-Location") - operationLocation: TypeSpec.Rest.ResourceLocation; - } & Foundations.RetryAfterHeader> | TResponse - >; -}