Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix arm provider async doesn't return 202 #1673

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Fix `ArmProviderActionAsync` to correctly return 202 responses.
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ op Azure.ResourceManager.ArmListBySubscription(apiVersion: string, subscriptionI
### `ArmProviderActionAsync` {#Azure.ResourceManager.ArmProviderActionAsync}

```typespec
op Azure.ResourceManager.ArmProviderActionAsync(apiVersion: string, subscriptionId: Azure.Core.uuid, location: string, resourceGroupName: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", body: Request): Response | Azure.ResourceManager.CommonTypes.ErrorResponse
op Azure.ResourceManager.ArmProviderActionAsync(apiVersion: string, subscriptionId: Azure.Core.uuid, location: string, resourceGroupName: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", body: Request): Azure.ResourceManager.ArmAcceptedLroResponse<Description, LroHeaders> | Response | Azure.ResourceManager.CommonTypes.ErrorResponse
```

#### Template Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,50 @@ model LogAnalyticsCollection is Page<LogAnalyticsOperationResult>;
interface ProviderOperations {
/** Operation to get virtual machines for subscription (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/getVmSizes) */
@get
getVmSizes is ArmProviderActionAsync<
Response = VmSizeCollection,
Scope = SubscriptionActionScope
>;
getVmSizes is ArmProviderActionSync<Response = VmSizeCollection, Scope = SubscriptionActionScope>;
/** Operation to get virtual machines for tenant (/providers/Microsoft.ContosoProviderHub/getVmSizesTenant) */
@get
getVmSizesTenant is ArmProviderActionAsync<
Response = VmSizeCollection,
Scope = TenantActionScope
>;
getVmSizesTenant is ArmProviderActionSync<Response = VmSizeCollection, Scope = TenantActionScope>;
/** Operation to get virtual machines for subscription for specific location (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/locations/{location}/getVmSizesLocation) */
@get
getVmSizesLocation is ArmProviderActionAsync<
getVmSizesLocation is ArmProviderActionSync<
Response = VmSizeCollection,
Scope = SubscriptionActionScope,
Parameters = LocationParameter
>;
/** Operation to get throttled requests sharing action (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/logAnalytics/apiAccess/getThrottledRequests) */
@get
@action("logAnalytics/apiAccess/getThrottledRequests")
getThrottledRequestsSubscription is ArmProviderActionAsync<
getThrottledRequestsSubscription is ArmProviderActionSync<
Response = LogAnalyticsCollection,
Scope = SubscriptionActionScope
>;
/** Operation to get throttled requests sharing action for tenant (/providers/Microsoft.ContosoProviderHub/logAnalytics/apiAccess/getThrottledRequests) */
@get
@action("logAnalytics/apiAccess/getThrottledRequests")
getThrottledRequestsTenant is ArmProviderActionAsync<
getThrottledRequestsTenant is ArmProviderActionSync<
Response = LogAnalyticsCollection,
Scope = TenantActionScope
>;
/** Operation to post virtual machines for subscription (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/postVmSizes) */
postVmSizes is ArmProviderActionAsync<
Response = LogAnalyticsCollection,
Scope = SubscriptionActionScope
>;
/** Operation to post virtual machines for subscription for specific location (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/locations/{location}/postVmSizesLocation) */
postVmSizesLocation is ArmProviderActionAsync<
Response = LogAnalyticsCollection,
Scope = SubscriptionActionScope,
Parameters = LocationParameter
>;
/** Operation to post virtual machines for subscription with retry after header (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/postVmSizesRetry) */
postVmSizesRetry is ArmProviderActionAsync<
Response = Azure.Core.Foundations.RetryAfterHeader,
Scope = SubscriptionActionScope
>;
/** Operation to post virtual machines for subscription with ARM combined header (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/postVmSizesArmCombined) */
postVmSizesArmCombined is ArmProviderActionAsync<
Response = ArmCombinedLroHeaders,
Scope = SubscriptionActionScope
>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,61 @@
}
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.OperationStatusSample/locations/{location}/postVmSizesLocation": {
"post": {
"operationId": "ProviderOperations_PostVmSizesLocation",
"tags": [
"ProviderOperations"
],
"description": "Operation to post virtual machines for subscription for specific location (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/locations/{location}/postVmSizesLocation)",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/LocationParameter"
}
],
"responses": {
"200": {
"description": "The request has succeeded.",
"schema": {
"$ref": "#/definitions/LogAnalyticsCollection"
}
},
"202": {
"description": "Resource operation accepted.",
"headers": {
"Location": {
"type": "string",
"description": "The Location header contains the URL where the status of the long running operation can be checked."
},
"Retry-After": {
"type": "integer",
"format": "int32",
"description": "The Retry-After header can indicate how long the client should wait before polling the operation status."
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse"
}
}
},
"x-ms-long-running-operation-options": {
"final-state-via": "location"
},
"x-ms-long-running-operation": true,
"x-ms-pageable": {
"nextLinkName": "nextLink"
}
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.OperationStatusSample/logAnalytics/apiAccess/getThrottledRequests": {
"get": {
"operationId": "ProviderOperations_GetThrottledRequestsSubscription",
Expand Down Expand Up @@ -243,9 +298,179 @@
"nextLinkName": "nextLink"
}
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.OperationStatusSample/postVmSizes": {
"post": {
"operationId": "ProviderOperations_PostVmSizes",
"tags": [
"ProviderOperations"
],
"description": "Operation to post virtual machines for subscription (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/postVmSizes)",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter"
}
],
"responses": {
"200": {
"description": "The request has succeeded.",
"schema": {
"$ref": "#/definitions/LogAnalyticsCollection"
}
},
"202": {
"description": "Resource operation accepted.",
"headers": {
"Location": {
"type": "string",
"description": "The Location header contains the URL where the status of the long running operation can be checked."
},
"Retry-After": {
"type": "integer",
"format": "int32",
"description": "The Retry-After header can indicate how long the client should wait before polling the operation status."
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse"
}
}
},
"x-ms-long-running-operation-options": {
"final-state-via": "location"
},
"x-ms-long-running-operation": true,
"x-ms-pageable": {
"nextLinkName": "nextLink"
}
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.OperationStatusSample/postVmSizesArmCombined": {
"post": {
"operationId": "ProviderOperations_PostVmSizesArmCombined",
"tags": [
"ProviderOperations"
],
"description": "Operation to post virtual machines for subscription with ARM combined header (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/postVmSizesArmCombined)",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter"
}
],
"responses": {
"200": {
"description": "The request has succeeded.",
"headers": {
"Azure-AsyncOperation": {
"type": "string",
"format": "uri",
"description": "A link to the status monitor"
},
"Location": {
"type": "string",
"description": "The Location header contains the URL where the status of the long running operation can be checked."
}
}
},
"202": {
"description": "Resource operation accepted.",
"headers": {
"Location": {
"type": "string",
"description": "The Location header contains the URL where the status of the long running operation can be checked."
},
"Retry-After": {
"type": "integer",
"format": "int32",
"description": "The Retry-After header can indicate how long the client should wait before polling the operation status."
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse"
}
}
},
"x-ms-long-running-operation-options": {
"final-state-via": "location"
},
"x-ms-long-running-operation": true
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.OperationStatusSample/postVmSizesRetry": {
"post": {
"operationId": "ProviderOperations_PostVmSizesRetry",
"tags": [
"ProviderOperations"
],
"description": "Operation to post virtual machines for subscription with retry after header (/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/postVmSizesRetry)",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter"
}
],
"responses": {
"200": {
"description": "The request has succeeded.",
"headers": {
"Retry-After": {
"type": "integer",
"format": "int32",
"description": "The Retry-After header can indicate how long the client should wait before polling the operation status."
}
}
},
"202": {
"description": "Resource operation accepted.",
"headers": {
"Location": {
"type": "string",
"description": "The Location header contains the URL where the status of the long running operation can be checked."
},
"Retry-After": {
"type": "integer",
"format": "int32",
"description": "The Retry-After header can indicate how long the client should wait before polling the operation status."
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse"
}
}
},
"x-ms-long-running-operation-options": {
"final-state-via": "location"
},
"x-ms-long-running-operation": true
}
}
},
"definitions": {
"Azure.Core.Foundations.RetryAfterHeader": {
"type": "object",
"description": "The retry-after envelope."
},
"Azure.ResourceManager.ArmCombinedLroHeaders<Azure.ResourceManager.ArmOperationStatus<never, Azure.ResourceManager.ResourceProvisioningState>, void, TypeSpec.Rest.ResourceLocation, string>": {
"type": "object",
"description": "Provide Both Azure-AsyncOperation and Location headers"
},
"LogAnalyticsCollection": {
"type": "object",
"description": "LogAnalytics collection of operation status response",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,4 +752,4 @@ op ArmProviderActionAsync<

/** The request body */
@bodyRoot body: Request,
): Response | ErrorResponse;
): ArmAcceptedLroResponse<"Resource operation accepted.", LroHeaders> | Response | ErrorResponse;
Loading