From 4fbcc5e1c1ae4bb9110c408f72fa1ed0369bd415 Mon Sep 17 00:00:00 2001 From: Mark Cowlishaw Date: Tue, 23 Sep 2025 19:25:46 -0700 Subject: [PATCH] Fix #3294 Add support for private links --- .../private-links-2025-8-23-19-24-41.md | 7 + .../resource-types/private-links/main.tsp | 1 + .../private-links/private-links.tsp | 140 ++ .../2021-10-01-preview/openapi.json | 1224 +++++++++++++++++ .../Azure.ResourceManager.Private.ts | 19 +- .../lib/arm.tsp | 1 + .../lib/private-links.tsp | 144 ++ .../lib/private.decorators.tsp | 3 + .../src/lib.ts | 7 + .../src/private.decorators.ts | 18 + .../reference/data-types.md | 35 + .../reference/index.mdx | 2 + .../reference/interfaces.md | 78 ++ 13 files changed, 1678 insertions(+), 1 deletion(-) create mode 100644 .chronus/changes/private-links-2025-8-23-19-24-41.md create mode 100644 packages/samples/specs/resource-manager/resource-types/private-links/main.tsp create mode 100644 packages/samples/specs/resource-manager/resource-types/private-links/private-links.tsp create mode 100644 packages/samples/test/output/azure/resource-manager/resource-types/private-links/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json create mode 100644 packages/typespec-azure-resource-manager/lib/private-links.tsp diff --git a/.chronus/changes/private-links-2025-8-23-19-24-41.md b/.chronus/changes/private-links-2025-8-23-19-24-41.md new file mode 100644 index 0000000000..2d64c8b85d --- /dev/null +++ b/.chronus/changes/private-links-2025-8-23-19-24-41.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Fix #3294 Add model and operation templates for private link \ No newline at end of file diff --git a/packages/samples/specs/resource-manager/resource-types/private-links/main.tsp b/packages/samples/specs/resource-manager/resource-types/private-links/main.tsp new file mode 100644 index 0000000000..61358c5ec3 --- /dev/null +++ b/packages/samples/specs/resource-manager/resource-types/private-links/main.tsp @@ -0,0 +1 @@ +import "./private-links.tsp"; diff --git a/packages/samples/specs/resource-manager/resource-types/private-links/private-links.tsp b/packages/samples/specs/resource-manager/resource-types/private-links/private-links.tsp new file mode 100644 index 0000000000..64f09f0cbc --- /dev/null +++ b/packages/samples/specs/resource-manager/resource-types/private-links/private-links.tsp @@ -0,0 +1,140 @@ +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; + +using Rest; +using Versioning; +using Azure.Core; +using Azure.ResourceManager; + +/** Contoso Resource Provider management API. */ +@armProviderNamespace +@service(#{ title: "ContosoProviderHubClient" }) +@versioned(Versions) +namespace Microsoft.ContosoProviderHub; + +/** Contoso API versions */ +enum Versions { + /** 2021-10-01-preview version */ + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) + `2021-10-01-preview`, +} + +// For more information about the proxy vs tracked, +// see https://armwiki.azurewebsites.net/rp_onboarding/tracked_vs_proxy_resources.html?q=proxy%20resource +/** A ContosoProviderHub resource */ +model Employee is TrackedResource { + ...ResourceNameParameter; +} + +/** Employee properties */ +model EmployeeProperties { + /** Age of employee */ + age?: int32; + + /** City of employee */ + city?: string; + + /** Profile of employee */ + @encode("base64url") + profile?: bytes; + + /** The status of the last operation. */ + @visibility(Lifecycle.Read) + provisioningState?: ProvisioningState; +} + +/** The provisioning state of a resource. */ +@lroStatus +union ProvisioningState { + ResourceProvisioningState, + + /** The resource is being provisioned */ + Provisioning: "Provisioning", + + /** The resource is updating */ + Updating: "Updating", + + /** The resource is being deleted */ + Deleting: "Deleting", + + /** The resource create request has been accepted */ + Accepted: "Accepted", + + string, +} + +interface Operations extends Azure.ResourceManager.Operations {} +model MyPrivateLinkResource is PrivateLink; +alias PrivateLinkOperations = PrivateLinks; + +@armResourceOperations +interface Employees { + get is ArmResourceRead; + createOrUpdate is ArmResourceCreateOrReplaceAsync; + update is ArmCustomPatchSync< + Employee, + Azure.ResourceManager.Foundations.ResourceUpdateModel + >; + delete is ArmResourceDeleteSync; + listByResourceGroup is ArmResourceListByParent; + listBySubscription is ArmListBySubscription; + /** A sample resource action that move employee to different location */ + move is ArmResourceActionSync; + + /** A sample HEAD operation to check resource existence */ + checkExistence is ArmResourceCheckExistence; + + getPrivateLink is PrivateLinkOperations.Read; + listPrivateLinks is PrivateLinkOperations.ListByParent; +} + +/** Employee move request */ +model MoveRequest { + /** The moving from location */ + from: string; + + /** The moving to location */ + to: string; +} + +/** Employee move response */ +model MoveResponse { + /** The status of the move */ + movingStatus: string; +} + +@armResourceOperations +interface Dependents { + get is ArmResourceRead; + createOrUpdate is ArmResourceCreateOrReplaceAsync; + update is ArmCustomPatchSync< + Dependent, + Azure.ResourceManager.Foundations.ResourceUpdateModel + >; + delete is ArmResourceDeleteSync; + list is ArmResourceListByParent; + getPrivateLink is PrivateLinkOperations.Read; + #suppress "@azure-tools/typespec-azure-resource-manager/legacy-type-usage" "Using legacy type as a sample" + listPrivateLinks is PrivateLinkOperations.ListSinglePageByParent; +} + +/** An employee dependent */ +@parentResource(Employee) +model Dependent is ProxyResource { + ...ResourceNameParameter; +} + +/** Dependent properties */ +model DependentProperties { + /** Age of dependent */ + age: int32; + + /** Gender of dependent */ + gender: string; + + /** The status of the last operation. */ + @visibility(Lifecycle.Read) + provisioningState?: ProvisioningState; +} diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/private-links/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/private-links/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json new file mode 100644 index 0000000000..bf0c5f7704 --- /dev/null +++ b/packages/samples/test/output/azure/resource-manager/resource-types/private-links/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -0,0 +1,1224 @@ +{ + "swagger": "2.0", + "info": { + "title": "ContosoProviderHubClient", + "version": "2021-10-01-preview", + "description": "Contoso Resource Provider management API.", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] + }, + "schemes": [ + "https" + ], + "host": "management.azure.com", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow.", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "tags": [ + { + "name": "Operations" + }, + { + "name": "Employees" + }, + { + "name": "Dependents" + } + ], + "paths": { + "/providers/Microsoft.ContosoProviderHub/operations": { + "get": { + "operationId": "Operations_List", + "tags": [ + "Operations" + ], + "description": "List the operations for the provider", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/OperationListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/providers/Microsoft.ContosoProviderHub/employees": { + "get": { + "operationId": "Employees_ListBySubscription", + "tags": [ + "Employees" + ], + "description": "List Employee resources by subscription ID", + "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": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/EmployeeListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees": { + "get": { + "operationId": "Employees_ListByResourceGroup", + "tags": [ + "Employees" + ], + "description": "List Employee resources by resource group", + "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/ResourceGroupNameParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/EmployeeListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}": { + "get": { + "operationId": "Employees_Get", + "tags": [ + "Employees" + ], + "description": "Get a Employee", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/Employee" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "put": { + "operationId": "Employees_CreateOrUpdate", + "tags": [ + "Employees" + ], + "description": "Create a Employee", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/Employee" + } + } + ], + "responses": { + "200": { + "description": "Resource 'Employee' update operation succeeded", + "schema": { + "$ref": "#/definitions/Employee" + } + }, + "201": { + "description": "Resource 'Employee' create operation succeeded", + "schema": { + "$ref": "#/definitions/Employee" + }, + "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, + "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": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Employees_Update", + "tags": [ + "Employees" + ], + "description": "Update a Employee", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/EmployeeUpdate" + } + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/Employee" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "delete": { + "operationId": "Employees_Delete", + "tags": [ + "Employees" + ], + "description": "Delete a Employee", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "204": { + "description": "Resource does not exist." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "head": { + "operationId": "Employees_CheckExistence", + "tags": [ + "Employees" + ], + "description": "A sample HEAD operation to check resource existence", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "204": { + "description": "The Azure resource exists" + }, + "404": { + "description": "The Azure resource is not found" + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/dependents": { + "get": { + "operationId": "Dependents_List", + "tags": [ + "Dependents" + ], + "description": "List Dependent resources by Employee", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/DependentListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/dependents/{dependentName}": { + "get": { + "operationId": "Dependents_Get", + "tags": [ + "Dependents" + ], + "description": "Get a Dependent", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "dependentName", + "in": "path", + "description": "The name of the Dependent", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/Dependent" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "put": { + "operationId": "Dependents_CreateOrUpdate", + "tags": [ + "Dependents" + ], + "description": "Create a Dependent", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "dependentName", + "in": "path", + "description": "The name of the Dependent", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/Dependent" + } + } + ], + "responses": { + "200": { + "description": "Resource 'Dependent' update operation succeeded", + "schema": { + "$ref": "#/definitions/Dependent" + } + }, + "201": { + "description": "Resource 'Dependent' create operation succeeded", + "schema": { + "$ref": "#/definitions/Dependent" + }, + "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, + "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": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Dependents_Update", + "tags": [ + "Dependents" + ], + "description": "Update a Dependent", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "dependentName", + "in": "path", + "description": "The name of the Dependent", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/DependentUpdate" + } + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/Dependent" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "delete": { + "operationId": "Dependents_Delete", + "tags": [ + "Dependents" + ], + "description": "Delete a Dependent", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "dependentName", + "in": "path", + "description": "The name of the Dependent", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "204": { + "description": "Resource does not exist." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/dependents/{dependentName}/privateLinkResources": { + "get": { + "operationId": "Dependents_ListPrivateLinks", + "tags": [ + "Dependents" + ], + "description": "List Dependent PrivateLinks", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "dependentName", + "in": "path", + "description": "The name of the Dependent", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/MyPrivateLinkResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/dependents/{dependentName}/privateLinkResources/{privateLinkResourceName}": { + "get": { + "operationId": "Dependents_GetPrivateLink", + "tags": [ + "Dependents" + ], + "description": "Get a Dependent PrivateLink", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "dependentName", + "in": "path", + "description": "The name of the Dependent", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "privateLinkResourceName", + "in": "path", + "description": "The name of the private link associated with the Azure resource.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/privatelinks.json#/definitions/PrivateLinkResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/move": { + "post": { + "operationId": "Employees_Move", + "tags": [ + "Employees" + ], + "description": "A sample resource action that move employee to different location", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "$ref": "#/definitions/MoveRequest" + } + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/MoveResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/privateLinkResources": { + "get": { + "operationId": "Employees_ListPrivateLinks", + "tags": [ + "Employees" + ], + "description": "List Employee PrivateLinks", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/MyPrivateLinkResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/privateLinkResources/{privateLinkResourceName}": { + "get": { + "operationId": "Employees_GetPrivateLink", + "tags": [ + "Employees" + ], + "description": "Get a Employee PrivateLink", + "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/ResourceGroupNameParameter" + }, + { + "name": "employeeName", + "in": "path", + "description": "The name of the Employee", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "privateLinkResourceName", + "in": "path", + "description": "The name of the private link associated with the Azure resource.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/privatelinks.json#/definitions/PrivateLinkResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + } + } + }, + "definitions": { + "Dependent": { + "type": "object", + "description": "An employee dependent", + "properties": { + "properties": { + "$ref": "#/definitions/DependentProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true + } + }, + "allOf": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ProxyResource" + } + ] + }, + "DependentListResult": { + "type": "object", + "description": "The response of a Dependent list operation.", + "properties": { + "value": { + "type": "array", + "description": "The Dependent items on this page", + "items": { + "$ref": "#/definitions/Dependent" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "DependentProperties": { + "type": "object", + "description": "Dependent properties", + "properties": { + "age": { + "type": "integer", + "format": "int32", + "description": "Age of dependent" + }, + "gender": { + "type": "string", + "description": "Gender of dependent" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the last operation.", + "readOnly": true + } + }, + "required": [ + "age", + "gender" + ] + }, + "DependentUpdate": { + "type": "object", + "description": "The type used for update operations of the Dependent.", + "properties": { + "properties": { + "$ref": "#/definitions/DependentUpdateProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true + } + } + }, + "DependentUpdateProperties": { + "type": "object", + "description": "The updatable properties of the Dependent.", + "properties": { + "age": { + "type": "integer", + "format": "int32", + "description": "Age of dependent" + }, + "gender": { + "type": "string", + "description": "Gender of dependent" + } + } + }, + "Employee": { + "type": "object", + "description": "A ContosoProviderHub resource", + "properties": { + "properties": { + "$ref": "#/definitions/EmployeeProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true + } + }, + "allOf": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/TrackedResource" + } + ] + }, + "EmployeeListResult": { + "type": "object", + "description": "The response of a Employee list operation.", + "properties": { + "value": { + "type": "array", + "description": "The Employee items on this page", + "items": { + "$ref": "#/definitions/Employee" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "EmployeeProperties": { + "type": "object", + "description": "Employee properties", + "properties": { + "age": { + "type": "integer", + "format": "int32", + "description": "Age of employee" + }, + "city": { + "type": "string", + "description": "City of employee" + }, + "profile": { + "type": "string", + "format": "base64url", + "description": "Profile of employee" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the last operation.", + "readOnly": true + } + } + }, + "EmployeeUpdate": { + "type": "object", + "description": "The type used for update operations of the Employee.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/EmployeeUpdateProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true + } + } + }, + "EmployeeUpdateProperties": { + "type": "object", + "description": "The updatable properties of the Employee.", + "properties": { + "age": { + "type": "integer", + "format": "int32", + "description": "Age of employee" + }, + "city": { + "type": "string", + "description": "City of employee" + }, + "profile": { + "type": "string", + "format": "base64url", + "description": "Profile of employee" + } + } + }, + "MoveRequest": { + "type": "object", + "description": "Employee move request", + "properties": { + "from": { + "type": "string", + "description": "The moving from location" + }, + "to": { + "type": "string", + "description": "The moving to location" + } + }, + "required": [ + "from", + "to" + ] + }, + "MoveResponse": { + "type": "object", + "description": "Employee move response", + "properties": { + "movingStatus": { + "type": "string", + "description": "The status of the move" + } + }, + "required": [ + "movingStatus" + ] + }, + "MyPrivateLinkResourceListResult": { + "type": "object", + "description": "The response of a MyPrivateLinkResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The MyPrivateLinkResource items on this page", + "items": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/privatelinks.json#/definitions/PrivateLinkResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "ProvisioningState": { + "type": "string", + "description": "The provisioning state of a resource.", + "enum": [ + "Succeeded", + "Failed", + "Canceled", + "Provisioning", + "Updating", + "Deleting", + "Accepted" + ], + "x-ms-enum": { + "name": "ProvisioningState", + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + }, + { + "name": "Provisioning", + "value": "Provisioning", + "description": "The resource is being provisioned" + }, + { + "name": "Updating", + "value": "Updating", + "description": "The resource is updating" + }, + { + "name": "Deleting", + "value": "Deleting", + "description": "The resource is being deleted" + }, + { + "name": "Accepted", + "value": "Accepted", + "description": "The resource create request has been accepted" + } + ] + }, + "readOnly": true + } + }, + "parameters": {} +} diff --git a/packages/typespec-azure-resource-manager/generated-defs/Azure.ResourceManager.Private.ts b/packages/typespec-azure-resource-manager/generated-defs/Azure.ResourceManager.Private.ts index 71ffcce520..8484ce3826 100644 --- a/packages/typespec-azure-resource-manager/generated-defs/Azure.ResourceManager.Private.ts +++ b/packages/typespec-azure-resource-manager/generated-defs/Azure.ResourceManager.Private.ts @@ -1,4 +1,12 @@ -import type { DecoratorContext, Model, ModelProperty, Operation, Type } from "@typespec/compiler"; +import type { + DecoratorContext, + Interface, + Model, + ModelProperty, + Operation, + Scalar, + Type, +} from "@typespec/compiler"; /** * @@ -191,6 +199,14 @@ export type ArmBodyRootDecorator = ( isOptional: boolean, ) => void; +/** + * designates a type as a legacy type and emits a warning diagnostic when used + */ +export type LegacyTypeDecorator = ( + context: DecoratorContext, + target: Model | Operation | Interface | Scalar, +) => void; + export type AzureResourceManagerPrivateDecorators = { resourceParameterBaseFor: ResourceParameterBaseForDecorator; resourceBaseParametersOf: ResourceBaseParametersOfDecorator; @@ -207,4 +223,5 @@ export type AzureResourceManagerPrivateDecorators = { armRenameListByOperation: ArmRenameListByOperationDecorator; armResourcePropertiesOptionality: ArmResourcePropertiesOptionalityDecorator; armBodyRoot: ArmBodyRootDecorator; + legacyType: LegacyTypeDecorator; }; diff --git a/packages/typespec-azure-resource-manager/lib/arm.tsp b/packages/typespec-azure-resource-manager/lib/arm.tsp index 90fb31540c..f7f27cbb1e 100644 --- a/packages/typespec-azure-resource-manager/lib/arm.tsp +++ b/packages/typespec-azure-resource-manager/lib/arm.tsp @@ -18,6 +18,7 @@ import "./interfaces.tsp"; import "./responses.tsp"; import "./parameters.tsp"; import "./private-endpoints.tsp"; +import "./private-links.tsp"; using Http; using Rest; diff --git a/packages/typespec-azure-resource-manager/lib/private-links.tsp b/packages/typespec-azure-resource-manager/lib/private-links.tsp new file mode 100644 index 0000000000..4462caee7a --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/private-links.tsp @@ -0,0 +1,144 @@ +using Http; +using Rest; +using Azure.ResourceManager.Foundations; +using Azure.ResourceManager.Private; + +namespace Azure.ResourceManager; + +/** + * A private link resource. + * Resource providers must declare a private link resource type in their provider namespace if + * they support private link resources + * @template Description Optional. The documentary description of the private link resource name parameter. + * @template KeyName Optional. The name of the private link resource name parameter. + * @example + * ```ts + * namespace Microsoft.Contoso; + * model PrivateLink is PrivateLinkResource {} + * alias EmployeeConnectionOps is PrivateLinks; + * @armResourceOperations + * interface Employees { + * @doc("get a private endpoint connection for resource employee") + * getPrivateEndpointConnection is EmployeeConnectionOps.Read; + * } + * ``` + */ +@doc(Description) +@armResourceWithParameter( + CommonTypes.PrivateLinkResourceProperties, + "privateLinkResources", + "privateLinkResourceName" +) +@Http.Private.includeInapplicableMetadataInPayload(false) +model PrivateLink + is CommonTypes.PrivateLinkResource; + +/** + * Operations over private link resources. + * @template PrivateLinkResourceModel The type of the private link resource. You must declare a private link resource type in your provider namespace. + * + * @example + * ```ts + * namespace Microsoft.Contoso; + * model PrivateLink is PrivateLinkResource {} + * alias EmployeeConnectionOps is PrivateLinks; + * @armResourceOperations + * interface Employees { + * @doc("get a private link for resource employee") + * getPrivateLink is EmployeeConnectionOps.Read; + * } + * ``` + */ +interface PrivateLinks { + /** + * @dev List the private links to a resource + * @template ParentResource the parent resource of the PrivateLink + * @template Resource Optional. The PrivateLink resource being listed + * @template BaseParameters Optional. Allows overriding the operation parameters + * @template ParentName Optional. The name of the parent resource + * @template ParentFriendlyName Optional. The friendly name of the parent resource + * @template Parameters Optional. Additional parameters after the path parameters + * @template Response Optional. The success response for the list operation + * @template Error Optional. The error response, if non-standard. + */ + @doc("List {name} PrivateLinks", ParentResource) + @get + @autoRoute + @list + @listsResource(Resource) + @segmentOf(PrivateLinkResourceParameter) + @armResourceList(Resource) + @Private.enforceConstraint(ParentResource, Foundations.Resource) + ListByParent< + ParentResource extends Foundations.SimpleResource, + Resource extends PrivateLink = PrivateLinkResourceModel, + BaseParameters = DefaultBaseParameters, + Parameters extends {} = {}, + Response extends {} = ArmResponse>, + Error extends {} = ErrorResponse + > is ArmReadOperation< + ResourceInstanceParameters & Parameters, + Response, + Error + >; + + /** + * @dev List the private links to a resource - this should only be used for legacy operations + * @template ParentResource the parent resource of the PrivateLink + * @template Resource Optional. The PrivateLink resource being listed + * @template BaseParameters Optional. Allows overriding the operation parameters + * @template ParentName Optional. The name of the parent resource + * @template ParentFriendlyName Optional. The friendly name of the parent resource + * @template Parameters Optional. Additional parameters after the path parameters + * @template Response Optional. The success response for the list operation + * @template Error Optional. The error response, if non-standard. + */ + @Private.legacyType + @doc("List {name} PrivateLinks", ParentResource) + @get + @autoRoute + @listsResource(Resource) + @segmentOf(PrivateLinkResourceParameter) + @armResourceList(Resource) + @Private.enforceConstraint(ParentResource, Foundations.Resource) + ListSinglePageByParent< + ParentResource extends Foundations.SimpleResource, + Resource extends PrivateLink = PrivateLinkResourceModel, + BaseParameters = DefaultBaseParameters, + Parameters extends {} = {}, + Response extends {} = ArmResponse>, + Error extends {} = ErrorResponse + > is ArmReadOperation< + ResourceInstanceParameters & Parameters, + Response, + Error + >; + + /** + * @dev GET the a private link to a particular resource + * @template ParentResource the parent resource of the PrivateLink + * @template Resource the PrivateLink resource being read + * @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 read operation + * @template Error Optional. The error response, if non-standard. + */ + @autoRoute + @doc("Get a {name} PrivateLink", ParentResource) + @get + @armResourceRead(Resource) + Read< + ParentResource extends Foundations.SimpleResource, + Resource extends PrivateLink = PrivateLinkResourceModel, + BaseParameters = DefaultBaseParameters, + Parameters extends {} = {}, + Response extends {} = ArmResponse, + Error extends {} = ErrorResponse + > is ArmReadOperation< + ResourceInstanceParameters & + KeysOf & + Parameters, + Response, + Error + >; +} diff --git a/packages/typespec-azure-resource-manager/lib/private.decorators.tsp b/packages/typespec-azure-resource-manager/lib/private.decorators.tsp index 04b1041c27..19f040317d 100644 --- a/packages/typespec-azure-resource-manager/lib/private.decorators.tsp +++ b/packages/typespec-azure-resource-manager/lib/private.decorators.tsp @@ -126,3 +126,6 @@ extern dec armResourcePropertiesOptionality(target: ModelProperty, isOptional: v /** designates a parameter as an explicit bodyRoot and sets the optionality of the parameter */ extern dec armBodyRoot(target: ModelProperty, isOptional: valueof boolean); + +/** designates a type as a legacy type and emits a warning diagnostic when used */ +extern dec legacyType(target: Model | Operation | Interface | Scalar); diff --git a/packages/typespec-azure-resource-manager/src/lib.ts b/packages/typespec-azure-resource-manager/src/lib.ts index 9c89b820e0..f5f26c16d0 100644 --- a/packages/typespec-azure-resource-manager/src/lib.ts +++ b/packages/typespec-azure-resource-manager/src/lib.ts @@ -124,6 +124,13 @@ export const $lib = createTypeSpecLibrary({ notpath: paramMessage`The parameter "${"oldName"}" is not a path parameter and so cannot be renamed.`, }, }, + "legacy-type-usage": { + severity: "warning", + messages: { + default: + "This type is meant for conversion of legacy service APIs. This type should not be used in new service APIs.", + }, + }, }, }); diff --git a/packages/typespec-azure-resource-manager/src/private.decorators.ts b/packages/typespec-azure-resource-manager/src/private.decorators.ts index 3496297acd..7b21eb4edd 100644 --- a/packages/typespec-azure-resource-manager/src/private.decorators.ts +++ b/packages/typespec-azure-resource-manager/src/private.decorators.ts @@ -6,12 +6,14 @@ import { ModelProperty, Operation, Program, + Scalar, Tuple, Type, addVisibilityModifiers, clearVisibilityModifiersForClass, getKeyName, getLifecycleVisibilityEnum, + getNamespaceFullName, getTypeName, isKey, sealVisibilityModifiers, @@ -43,6 +45,7 @@ import { ConditionalClientFlattenDecorator, DefaultResourceKeySegmentNameDecorator, EnforceConstraintDecorator, + LegacyTypeDecorator, OmitIfEmptyDecorator, ResourceBaseParametersOfDecorator, ResourceParameterBaseForDecorator, @@ -613,6 +616,20 @@ const $armBodyRoot: ArmBodyRootDecorator = ( context.call($bodyRoot, target); }; +const $legacyType: LegacyTypeDecorator = ( + context: DecoratorContext, + target: Model | Operation | Interface | Scalar, +) => { + const { program } = context; + if ( + target.namespace && + getNamespaceFullName(target.namespace).startsWith("Azure.ResourceManager") + ) { + return; + } + reportDiagnostic(program, { code: "legacy-type-usage", target }); +}; + /** @internal */ export const $decorators = { "Azure.ResourceManager.Private": { @@ -631,6 +648,7 @@ export const $decorators = { armResourcePropertiesOptionality: $armResourcePropertiesOptionality, armBodyRoot: $armBodyRoot, armResourceWithParameter: $armResourceWithParameter, + legacyType: $legacyType, } satisfies AzureResourceManagerPrivateDecorators, "Azure.ResourceManager.Extension.Private": { builtInResource: $builtInResource, diff --git a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/data-types.md b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/data-types.md index 340b238d0e..2e0ad6de20 100644 --- a/website/src/content/docs/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/website/src/content/docs/docs/libraries/azure-resource-manager/reference/data-types.md @@ -891,6 +891,41 @@ model Azure.ResourceManager.PrivateEndpointConnectionUpdate | ----------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------ | | properties? | `OptionalProperties>` | The private endpoint connection properties | +### `PrivateLink` {#Azure.ResourceManager.PrivateLink} + +A private link resource. +Resource providers must declare a private link resource type in their provider namespace if +they support private link resources + +```typespec +model Azure.ResourceManager.PrivateLink +``` + +#### Template Parameters + +| Name | Description | +| ----------- | ---------------------------------------------------------------------------------- | +| Description | Optional. The documentary description of the private link resource name parameter. | + +#### Examples + +```ts +namespace Microsoft.Contoso; +model PrivateLink is PrivateLinkResource {} +alias EmployeeConnectionOps is PrivateLinks; +@armResourceOperations +interface Employees { + @doc("get a private endpoint connection for resource employee") + getPrivateEndpointConnection is EmployeeConnectionOps.Read; +} +``` + +#### Properties + +| Name | Type | Description | +| ----------- | ------------------------------------------------------------------------------------------------------------------ | -------------------- | +| properties? | [`PrivateLinkResourceProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties) | Resource properties. | + ### `ProviderNamespace` {#Azure.ResourceManager.ProviderNamespace} Model describing the provider namespace. 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 add894506e..b145483876 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 @@ -64,6 +64,7 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`ExtensionResourceOperations`](./interfaces.md#Azure.ResourceManager.ExtensionResourceOperations) - [`Operations`](./interfaces.md#Azure.ResourceManager.Operations) - [`PrivateEndpoints`](./interfaces.md#Azure.ResourceManager.PrivateEndpoints) +- [`PrivateLinks`](./interfaces.md#Azure.ResourceManager.PrivateLinks) - [`ProxyResourceOperations`](./interfaces.md#Azure.ResourceManager.ProxyResourceOperations) - [`ResourceCollectionOperations`](./interfaces.md#Azure.ResourceManager.ResourceCollectionOperations) - [`ResourceCreateAsync`](./interfaces.md#Azure.ResourceManager.ResourceCreateAsync) @@ -151,6 +152,7 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`ParentKeysOf`](./data-types.md#Azure.ResourceManager.ParentKeysOf) - [`PrivateEndpointConnectionResource`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnectionResource) - [`PrivateEndpointConnectionUpdate`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnectionUpdate) +- [`PrivateLink`](./data-types.md#Azure.ResourceManager.PrivateLink) - [`ProviderNamespace`](./data-types.md#Azure.ResourceManager.ProviderNamespace) - [`ProxyResource`](./data-types.md#Azure.ResourceManager.ProxyResource) - [`ResourceGroupLocationResource`](./data-types.md#Azure.ResourceManager.ResourceGroupLocationResource) 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 4f1b6af43f..1273581a81 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 @@ -332,6 +332,84 @@ interface Employees { } ``` +### `PrivateLinks` {#Azure.ResourceManager.PrivateLinks} + +Operations over private link resources. + +```typespec +interface Azure.ResourceManager.PrivateLinks +``` + +#### Template Parameters + +| Name | Description | +| ------------------------ | ---------------------------------------------------------------------------------------------------------------- | +| PrivateLinkResourceModel | The type of the private link resource. You must declare a private link resource type in your provider namespace. | + +#### `PrivateLinks.ListByParent` {#Azure.ResourceManager.PrivateLinks.ListByParent} + +```typespec +op Azure.ResourceManager.PrivateLinks.ListByParent(provider: "Microsoft.ThisWillBeReplaced"): Response | Error +``` + +##### Template Parameters + +| Name | Description | +| -------------- | --------------------------------------------------------- | +| ParentResource | the parent resource of the PrivateLink | +| Resource | Optional. The PrivateLink resource being listed | +| BaseParameters | Optional. Allows overriding the operation parameters | +| Parameters | Optional. Additional parameters after the path parameters | +| Response | Optional. The success response for the list operation | +| Error | Optional. The error response, if non-standard. | + +#### `PrivateLinks.ListSinglePageByParent` {#Azure.ResourceManager.PrivateLinks.ListSinglePageByParent} + +```typespec +op Azure.ResourceManager.PrivateLinks.ListSinglePageByParent(provider: "Microsoft.ThisWillBeReplaced"): Response | Error +``` + +##### Template Parameters + +| Name | Description | +| -------------- | --------------------------------------------------------- | +| ParentResource | the parent resource of the PrivateLink | +| Resource | Optional. The PrivateLink resource being listed | +| BaseParameters | Optional. Allows overriding the operation parameters | +| Parameters | Optional. Additional parameters after the path parameters | +| Response | Optional. The success response for the list operation | +| Error | Optional. The error response, if non-standard. | + +#### `PrivateLinks.Read` {#Azure.ResourceManager.PrivateLinks.Read} + +```typespec +op Azure.ResourceManager.PrivateLinks.Read(provider: "Microsoft.ThisWillBeReplaced", privateLinkResourceName: string): Response | Error +``` + +##### Template Parameters + +| Name | Description | +| -------------- | --------------------------------------------------------- | +| ParentResource | the parent resource of the PrivateLink | +| Resource | the PrivateLink resource being read | +| BaseParameters | Optional. Allows overriding the operation parameters | +| Parameters | Optional. Additional parameters after the path parameters | +| Response | Optional. The success response for the read operation | +| Error | Optional. The error response, if non-standard. | + +#### Examples + +```ts +namespace Microsoft.Contoso; +model PrivateLink is PrivateLinkResource {} +alias EmployeeConnectionOps is PrivateLinks; +@armResourceOperations +interface Employees { + @doc("get a private link for resource employee") + getPrivateLink is EmployeeConnectionOps.Read; +} +``` + ### `ProxyResourceOperations` {#Azure.ResourceManager.ProxyResourceOperations} A composite interface for Proxy resources that include `ResourceInstanceOperations`