diff --git a/.chronus/changes/normalize-ops-2025-7-18-16-29-51.md b/.chronus/changes/normalize-ops-2025-7-18-16-29-51.md new file mode 100644 index 0000000000..af40dc30f0 --- /dev/null +++ b/.chronus/changes/normalize-ops-2025-7-18-16-29-51.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Add single page list and legacy put and patch operations \ No newline at end of file diff --git a/packages/samples/specs/resource-manager/legacy/non-standard-properties/main.tsp b/packages/samples/specs/resource-manager/legacy/non-standard-properties/main.tsp index ca09ab76b3..a7af114791 100644 --- a/packages/samples/specs/resource-manager/legacy/non-standard-properties/main.tsp +++ b/packages/samples/specs/resource-manager/legacy/non-standard-properties/main.tsp @@ -4,8 +4,6 @@ import "@typespec/versioning"; import "@azure-tools/typespec-azure-core"; import "@azure-tools/typespec-azure-resource-manager"; -using Http; -using Rest; using Versioning; using Azure.ResourceManager; diff --git a/packages/samples/specs/resource-manager/resource-types/private-endpoints/private-endpoints.tsp b/packages/samples/specs/resource-manager/resource-types/private-endpoints/private-endpoints.tsp index d90f755aed..51c6f73e65 100644 --- a/packages/samples/specs/resource-manager/resource-types/private-endpoints/private-endpoints.tsp +++ b/packages/samples/specs/resource-manager/resource-types/private-endpoints/private-endpoints.tsp @@ -120,10 +120,18 @@ interface Dependents { delete is ArmResourceDeleteSync; list is ArmResourceListByParent; getPrivateEndpointConnection is PrivateEndpointOperations.Read; - createOrUpdatePrivateEndpointConnection is PrivateEndpointOperations.CreateOrUpdateAsync; - updatePrivateEndpointConnection is PrivateEndpointOperations.CustomPatchAsync; + createOrUpdatePrivateEndpointConnection is Azure.ResourceManager.Legacy.PrivateEndpoints.CreateOrReplaceAsync< + Dependent, + PrivateEndpointConnection, + OptionalRequestBody = true + >; + updatePrivateEndpointConnection is Azure.ResourceManager.Legacy.PrivateEndpoints.CustomPatchAsync< + Dependent, + PrivateEndpointConnection, + PatchModel = void + >; deletePrivateEndpointConnection is PrivateEndpointOperations.DeleteAsync; - listPrivateEndpointConnections is Azure.ResourceManager.Legacy.ListSinglePageByParent< + listPrivateEndpointConnections is Azure.ResourceManager.Legacy.PrivateEndpoints.ListSinglePageByParent< Dependent, PrivateEndpointConnection >; diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/private-endpoints/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/private-endpoints/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 4166d6e0d8..b9dbfe3be6 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/private-endpoints/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/private-endpoints/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -812,7 +812,7 @@ "name": "resource", "in": "body", "description": "Resource create parameters.", - "required": true, + "required": false, "schema": { "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/privatelinks.json#/definitions/PrivateEndpointConnection" } @@ -888,15 +888,6 @@ }, { "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/privatelinks.json#/parameters/PrivateEndpointConnectionName" - }, - { - "name": "properties", - "in": "body", - "description": "The resource properties to be updated.", - "required": true, - "schema": { - "$ref": "#/definitions/Azure.ResourceManager.PrivateEndpointConnectionUpdate" - } } ], "responses": { diff --git a/packages/typespec-azure-resource-manager/lib/Legacy/extension.tsp b/packages/typespec-azure-resource-manager/lib/Legacy/extension.tsp index b8755730eb..188ddae2f0 100644 --- a/packages/typespec-azure-resource-manager/lib/Legacy/extension.tsp +++ b/packages/typespec-azure-resource-manager/lib/Legacy/extension.tsp @@ -28,6 +28,7 @@ interface ExtensionOperations< * @template OptionalRequestBody Optional. Indicates whether the request body is optional * @template ErrorType Optional. The error response, if non-standard. * @template OperationOptions Optional. The route options for the operation. + * @template Request Optional. The request body for the createOrUpdate operation. */ @armOperationRoute(OperationOptions) @doc("Create a {name}", Resource) @@ -45,12 +46,13 @@ interface ExtensionOperations< >, OptionalRequestBody extends valueof boolean = false, ErrorType extends {} = ErrorResponse, - OperationOptions extends valueof ArmOperationOptions = #{ useStaticRoute: false } + OperationOptions extends valueof ArmOperationOptions = #{ useStaticRoute: false }, + Request extends {} | void = Resource >( ...TargetParameters, ...ExtensionInstanceParameters, ...Parameters, - @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Resource, + @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Request, ): Response | ErrorType; /** @@ -61,6 +63,7 @@ interface ExtensionOperations< * @template OptionalRequestBody Optional. Indicates whether the request body is optional * @template ErrorType Optional. The error response, if non-standard. * @template OperationOptions Optional. The route options for the operation. + * @template Request Optional. The request body for the createOrUpdate operation. */ #suppress "@azure-tools/typespec-azure-core/no-private-usage" @armOperationRoute(OperationOptions) @@ -73,12 +76,13 @@ interface ExtensionOperations< Response extends {} = ArmResourceUpdatedResponse | ArmResourceCreatedSyncResponse, OptionalRequestBody extends valueof boolean = false, ErrorType extends {} = ErrorResponse, - OperationOptions extends valueof ArmOperationOptions = #{ useStaticRoute: false } + OperationOptions extends valueof ArmOperationOptions = #{ useStaticRoute: false }, + Request extends {} | void = Resource >( ...TargetParameters, ...ExtensionInstanceParameters, ...Parameters, - @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Resource, + @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Request, ): Response | ErrorType; /** @@ -98,7 +102,7 @@ interface ExtensionOperations< @patch(#{ implicitOptionality: false }) CustomPatchAsync< Resource extends Foundations.SimpleResource, - PatchModel extends {} = Azure.ResourceManager.Foundations.TagsUpdateModel, + PatchModel extends {} | void = Azure.ResourceManager.Foundations.TagsUpdateModel, LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader< Azure.Core.StatusMonitorPollingOptions, Resource, @@ -136,7 +140,7 @@ interface ExtensionOperations< @patch(#{ implicitOptionality: false }) CustomPatchSync< Resource extends Foundations.SimpleResource, - PatchModel extends {} = Azure.ResourceManager.Foundations.TagsUpdateModel, + PatchModel extends {} | void = Azure.ResourceManager.Foundations.TagsUpdateModel, Parameters extends {} = {}, Response extends {} = ArmResponse, OptionalRequestBody extends valueof boolean = false, @@ -261,6 +265,27 @@ interface ExtensionOperations< OperationOptions extends valueof ArmOperationOptions = #{ useStaticRoute: false } >(...TargetParameters, ...ExtensionParentParameters, ...Parameters): Response | ErrorType; + /** + * List a resource, without pagination + * @template Resource The resource being listed + * @template Parameters Optional. Additional parameters after the path parameters + * @template Response Optional. The response returned by the list + * @template ErrorType Optional. The error response, if non-standard. + * @template OperationOptions Optional. The route options for the operation. + */ + @armOperationRoute(OperationOptions) + @doc("List a {name}", Resource) + @get + @listsResource(Resource) + @armResourceList(Resource) + ListSinglePage< + Resource extends Foundations.SimpleResource, + Parameters extends {} = {}, + Response extends {} = ArmResponse>, + ErrorType extends {} = ErrorResponse, + OperationOptions extends valueof ArmOperationOptions = #{ useStaticRoute: false } + >(...TargetParameters, ...ExtensionParentParameters, ...Parameters): Response | ErrorType; + /** * A synchronous resource action. * @template Resource The resource being acted upon @@ -279,7 +304,7 @@ interface ExtensionOperations< @returnsDoc("Azure operation completed successfully.") ActionSync< Resource extends Foundations.SimpleResource, - Request extends TypeSpec.Reflection.Model | void, + Request, Response extends TypeSpec.Reflection.Model | void, Parameters extends {} = {}, OptionalRequestBody extends valueof boolean = false, @@ -316,7 +341,7 @@ interface ExtensionOperations< @returnsDoc("Azure operation completed successfully.") ActionAsync< Resource extends Foundations.SimpleResource, - Request extends TypeSpec.Reflection.Model | void, + Request, Result extends TypeSpec.Reflection.Model | void, LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader< Azure.Core.StatusMonitorPollingOptions, diff --git a/packages/typespec-azure-resource-manager/lib/Legacy/operations.tsp b/packages/typespec-azure-resource-manager/lib/Legacy/operations.tsp index 8b28bcdcf8..2cba9aceb2 100644 --- a/packages/typespec-azure-resource-manager/lib/Legacy/operations.tsp +++ b/packages/typespec-azure-resource-manager/lib/Legacy/operations.tsp @@ -45,6 +45,7 @@ interface RoutedOperations< * @template OptionalRequestBody Optional. Indicates whether the request body is optional * @template OverrideErrorType Optional. The error response, if non-standard. * @template OverrideRouteOptions Optional. The route options for the operation. + * @template Request Optional. The request body for the createOrUpdate operation. */ @doc("Create a {name}", Resource) @armOperationRoute(OverrideRouteOptions) @@ -63,12 +64,13 @@ interface RoutedOperations< >, OptionalRequestBody extends valueof boolean = false, OverrideErrorType extends {} = ErrorType, - OverrideRouteOptions extends valueof ArmOperationOptions = ResourceRoute + OverrideRouteOptions extends valueof ArmOperationOptions = ResourceRoute, + Request extends {} | void = Resource >( ...ParentParameters, ...ResourceTypeParameter, ...Parameters, - @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Resource, + @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Request, ): Response | OverrideErrorType; /** @@ -79,6 +81,7 @@ interface RoutedOperations< * @template OptionalRequestBody Optional. Indicates whether the request body is optional * @template OverrideErrorType Optional. The error response, if non-standard. * @template OverrideRouteOptions Optional. The route options for the operation. + * @template Request Optional. The request body for the createOrUpdate operation. */ #suppress "@azure-tools/typespec-azure-core/no-private-usage" @armOperationRoute(OverrideRouteOptions) @@ -92,12 +95,13 @@ interface RoutedOperations< Response extends {} = ArmResourceUpdatedResponse | ArmResourceCreatedSyncResponse, OptionalRequestBody extends valueof boolean = false, OverrideErrorType extends {} = ErrorType, - OverrideRouteOptions extends valueof ArmOperationOptions = ResourceRoute + OverrideRouteOptions extends valueof ArmOperationOptions = ResourceRoute, + Request extends {} | void = Resource >( ...ParentParameters, ...ResourceTypeParameter, ...Parameters, - @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Resource, + @doc("Resource create parameters.") @armBodyRoot(OptionalRequestBody) resource: Request, ): Response | OverrideErrorType; /** @@ -118,7 +122,7 @@ interface RoutedOperations< @patch(#{ implicitOptionality: false }) CustomPatchAsync< Resource extends Foundations.SimpleResource, - PatchModel extends {} = Azure.ResourceManager.Foundations.TagsUpdateModel, + PatchModel extends {} | void = Azure.ResourceManager.Foundations.TagsUpdateModel, LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader< Azure.Core.StatusMonitorPollingOptions, Resource, @@ -157,7 +161,7 @@ interface RoutedOperations< @patch(#{ implicitOptionality: false }) CustomPatchSync< Resource extends Foundations.SimpleResource, - PatchModel extends {} = Azure.ResourceManager.Foundations.TagsUpdateModel, + PatchModel extends {} | void = Azure.ResourceManager.Foundations.TagsUpdateModel, Parameters extends {} = {}, Response extends {} = ArmResponse, OptionalRequestBody extends valueof boolean = false, diff --git a/packages/typespec-azure-resource-manager/lib/Legacy/private-endpoints.tsp b/packages/typespec-azure-resource-manager/lib/Legacy/private-endpoints.tsp index 105bb6314d..5681219166 100644 --- a/packages/typespec-azure-resource-manager/lib/Legacy/private-endpoints.tsp +++ b/packages/typespec-azure-resource-manager/lib/Legacy/private-endpoints.tsp @@ -1,7 +1,7 @@ import "@typespec/rest"; import "@typespec/http"; -namespace Azure.ResourceManager.Legacy; +namespace Azure.ResourceManager.Legacy.PrivateEndpoints; using Http; using Azure.ResourceManager.Foundations; @@ -37,3 +37,160 @@ op ListSinglePageByParent< Response, Error >; + +/** + * @dev Synchronous PUT operation for a Private endpoint connection to a resource + * @template ParentResource the parent resource of the PrivateEndpointConnection + * @template Resource the PrivateEndpointConnection resource being created or updated + * @template BaseParameters Optional. Allows overriding the operation parameters + * @template Parameters Optional. Additional parameters after the path parameters + * @template Response Optional. The success response for the createOrUpdate operation + * @template Error Optional. The error response, if non-standard. + * @template OptionalRequestBody Optional. Indicates whether the request body is optional. + * @template Request Optional. The request body for the operation. + */ +@autoRoute +@doc("Create a {name} PrivateEndpointConnection", ParentResource) +@armResourceCreateOrUpdate(Resource) +@Private.enforceConstraint(ParentResource, Foundations.Resource) +@put +op CreateOrReplaceSync< + ParentResource extends Foundations.SimpleResource, + Resource extends PrivateEndpointConnectionResource, + BaseParameters = DefaultBaseParameters, + Parameters extends {} = {}, + Response extends {} = ArmResourceUpdatedResponse | ArmResourceCreatedSyncResponse, + Error extends {} = ErrorResponse, + OptionalRequestBody extends valueof boolean = false, + Request extends {} | void = Resource +> is Azure.ResourceManager.Legacy.CreateOperation< + ResourceInstanceParameters & + KeysOf & + Parameters, + Request, + Response, + Error, + OptionalRequestBody +>; + +/** + * @dev A long-running resource CreateOrUpdate (PUT) for a PrivateEndpointConnection to a resource + * @template ParentResource the parent resource of the PrivateEndpointConnection + * @template Resource the PrivateEndpointConnection resource being created or updated + * @template BaseParameters Optional. Allows overriding the operation parameters + * @template LroHeaders Optional. Allows overriding the lro headers returned on resource create + * @template Parameters Optional. Additional parameters after the path parameters + * @template Response Optional. The success response for the createOrReplace operation + * @template Error Optional. The error response, if non-standard. + * @template OptionalRequestBody Optional. Indicates whether the request body is optional. + * @template Request Optional. The request body for the operation. + */ +@autoRoute +@doc("Create a {name} PrivateEndpointConnection", ParentResource) +@armResourceCreateOrUpdate(Resource) +@Private.enforceConstraint(ParentResource, Foundations.Resource) +@Azure.Core.Foundations.Private.defaultFinalStateVia(#["location", "azure-async-operation"]) +@put +op CreateOrReplaceAsync< + ParentResource extends Foundations.SimpleResource, + Resource extends PrivateEndpointConnectionResource, + BaseParameters = DefaultBaseParameters, + LroHeaders extends TypeSpec.Reflection.Model = ArmAsyncOperationHeader & + Azure.Core.Foundations.RetryAfterHeader, + Parameters extends {} = {}, + Response extends {} = ArmResourceUpdatedResponse | ArmResourceCreatedResponse< + Resource, + LroHeaders + >, + Error extends {} = ErrorResponse, + OptionalRequestBody extends valueof boolean = false, + Request extends {} | void = Resource +> is Azure.ResourceManager.Legacy.CreateOperation< + ResourceInstanceParameters & + KeysOf & + Parameters, + Request, + Response, + Error, + OptionalRequestBody +>; + +/** + * A long-running resource update using a custom PATCH payload (Asynchronous) to update a PrivateEndpointConnection to a resource. + * @template ParentResource the parent resource of the PrivateEndpointConnection + * @template Resource the PrivateEndpointConnection resource being updated + * @template PatchModel The input model for the PATCH request + * @template BaseParameters Optional. Allows overriding the operation parameters + * @template LroHeaders Optional. Allows overriding the lro headers returned in the Accepted response + * @template Parameters Optional. Additional parameters after the path parameters + * @template Response Optional. The success response for the patch operation + * @template Error Optional. The error response, if non-standard. + * @template OptionalRequestBody Optional. Indicates whether the request body is optional. + */ +@autoRoute +@doc("Update a {name} PrivateEndpointConnection", ParentResource) +@armResourceUpdate(Resource) +@Private.enforceConstraint(ParentResource, Foundations.Resource) +@patch(#{ implicitOptionality: false }) +op CustomPatchAsync< + ParentResource extends Foundations.SimpleResource, + Resource extends PrivateEndpointConnectionResource, + PatchModel extends {} | void = PrivateEndpointConnectionUpdate, + BaseParameters = DefaultBaseParameters, + LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader< + Azure.Core.StatusMonitorPollingOptions, + Resource, + string + > & + Azure.Core.Foundations.RetryAfterHeader, + Parameters extends {} = {}, + Response extends {} = ArmResponse | ArmAcceptedLroResponse< + "Resource update request accepted.", + LroHeaders + >, + Error extends {} = ErrorResponse, + OptionalRequestBody extends valueof boolean = false +> is Azure.ResourceManager.Legacy.UpdateOperation< + ResourceInstanceParameters & + KeysOf & + Parameters, + PatchModel, + Response, + Error, + OptionalRequestBody +>; + +/** + * @dev A resource update using a custom PATCH payload (synchronous) to update a PrivateEndpointConnection to a resource + * @template ParentResource The parent resource of the PrivateEndpointConnection + * @template Resource Optional. The PrivateEndpointConnection resource being patched + * @template PatchModel The input model for the PATCH request + * @template BaseParameters Optional. Allows overriding the operation parameters + * @template Parameters Optional. Additional parameters after the path parameters + * @template Response Optional. The success response for the patch operation + * @template Error Optional. The error response, if non-standard. + * @template OptionalRequestBody Optional. Indicates whether the request body is optional. + */ +@autoRoute +@doc("Update a {name PrivateEndpointConnection}", ParentResource) +@armResourceUpdate(Resource) +@Private.enforceConstraint(ParentResource, Foundations.Resource) +@patch(#{ implicitOptionality: false }) +op CustomPatchSync< + ParentResource extends Foundations.SimpleResource, + Resource extends PrivateEndpointConnectionResource, + PatchModel extends {} | void = PrivateEndpointConnectionUpdate, + BaseParameters = DefaultBaseParameters, + Parameters extends {} = {}, + Response extends {} = ArmResponse, + Error extends {} = ErrorResponse, + OptionalRequestBody extends valueof boolean = false +> is Azure.ResourceManager.Legacy.UpdateOperation< + ResourceInstanceParameters & + KeysOf & + Parameters, + PatchModel, + Response, + Error, + OptionalRequestBody +>; diff --git a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/index.mdx b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/index.mdx index e124aaed22..3095478bc5 100644 --- a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/index.mdx +++ b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/index.mdx @@ -335,7 +335,6 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`CreateOrReplaceSync`](./interfaces.md#Azure.ResourceManager.Legacy.CreateOrReplaceSync) - [`CustomPatchAsync`](./interfaces.md#Azure.ResourceManager.Legacy.CustomPatchAsync) - [`CustomPatchSync`](./interfaces.md#Azure.ResourceManager.Legacy.CustomPatchSync) -- [`ListSinglePageByParent`](./interfaces.md#Azure.ResourceManager.Legacy.ListSinglePageByParent) - [`UpdateOperation`](./interfaces.md#Azure.ResourceManager.Legacy.UpdateOperation) ### Models @@ -359,3 +358,13 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`CreateOrReplaceSync`](./interfaces.md#Azure.ResourceManager.Legacy.Extension.CreateOrReplaceSync) - [`CustomPatchAsync`](./interfaces.md#Azure.ResourceManager.Legacy.Extension.CustomPatchAsync) - [`CustomPatchSync`](./interfaces.md#Azure.ResourceManager.Legacy.Extension.CustomPatchSync) + +## Azure.ResourceManager.Legacy.PrivateEndpoints + +### Operations + +- [`CreateOrReplaceAsync`](./interfaces.md#Azure.ResourceManager.Legacy.PrivateEndpoints.CreateOrReplaceAsync) +- [`CreateOrReplaceSync`](./interfaces.md#Azure.ResourceManager.Legacy.PrivateEndpoints.CreateOrReplaceSync) +- [`CustomPatchAsync`](./interfaces.md#Azure.ResourceManager.Legacy.PrivateEndpoints.CustomPatchAsync) +- [`CustomPatchSync`](./interfaces.md#Azure.ResourceManager.Legacy.PrivateEndpoints.CustomPatchSync) +- [`ListSinglePageByParent`](./interfaces.md#Azure.ResourceManager.Legacy.PrivateEndpoints.ListSinglePageByParent) diff --git a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/interfaces.md b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/interfaces.md index d5018a14e0..7c72235416 100644 --- a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/interfaces.md +++ b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/interfaces.md @@ -1735,7 +1735,7 @@ interface Azure.ResourceManager.Legacy.ExtensionOperations