Skip to content
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6f73624
convert without /{policyAssignmentId} path
weidongxu-microsoft Oct 27, 2025
a9e2626
tspconfig
weidongxu-microsoft Oct 29, 2025
b05c372
prettier
weidongxu-microsoft Oct 29, 2025
8fb7e4e
fix PolicyDefinition
weidongxu-microsoft Oct 29, 2025
d95decc
fix PolicySetDefinitionVersion
weidongxu-microsoft Oct 29, 2025
a57417a
fix PolicyDefinitionVersion
weidongxu-microsoft Oct 29, 2025
2e03abd
fix PolicySetDefinition
weidongxu-microsoft Oct 29, 2025
ecafb25
fix back-compatible
weidongxu-microsoft Oct 29, 2025
85eb40d
format
weidongxu-microsoft Oct 29, 2025
4857ebc
fix model
weidongxu-microsoft Oct 29, 2025
998a289
fix warning
weidongxu-microsoft Oct 29, 2025
163413b
regen
weidongxu-microsoft Oct 29, 2025
a081067
add client.tsp
weidongxu-microsoft Oct 29, 2025
86c76e5
remove operationId
weidongxu-microsoft Oct 30, 2025
18bbded
fix listForResourceGroup
weidongxu-microsoft Oct 30, 2025
204b2d3
use v6 common-types
weidongxu-microsoft Oct 30, 2025
4f2b11f
use CommonTypes.ManagementGroupNameParameter
weidongxu-microsoft Oct 30, 2025
b98663d
revert back to common-types v5
weidongxu-microsoft Oct 30, 2025
0a77e24
temp solution for /providers/microsoft.Management/managementGroups/{m…
weidongxu-microsoft Oct 30, 2025
eeb6530
fix PolicyAssignments_ListForManagementGroup
weidongxu-microsoft Oct 30, 2025
9803a45
remove suppress
weidongxu-microsoft Oct 30, 2025
75c4088
fix PolicyAssignments_List
weidongxu-microsoft Oct 30, 2025
52c87fa
fix PolicyAssignments_ListForResource
weidongxu-microsoft Oct 30, 2025
2d9d161
add examples
weidongxu-microsoft Oct 30, 2025
662271f
fix go tspconfig
weidongxu-microsoft Oct 30, 2025
5b81ce1
fix
weidongxu-microsoft Oct 30, 2025
f7ebb41
fix example
weidongxu-microsoft Oct 30, 2025
2d4e167
use template for listForManagementGroup
weidongxu-microsoft Oct 30, 2025
51eaea4
Merge branch 'main' into tsp-convertion_resources-policy
weidongxu-microsoft Nov 4, 2025
7aa8790
use ListSinglePage
weidongxu-microsoft Nov 4, 2025
1b81221
use PolicyAssignmentGenericOps
weidongxu-microsoft Nov 4, 2025
be323dc
update others
weidongxu-microsoft Nov 4, 2025
e7bdeda
backward compatible
weidongxu-microsoft Nov 4, 2025
739e131
Merge branch 'main' into tsp-convertion_resources-policy
weidongxu-microsoft Nov 10, 2025
2967570
api in client
weidongxu-microsoft Nov 10, 2025
898d941
skip-url-encoding
weidongxu-microsoft Nov 10, 2025
e530012
fix a ref
weidongxu-microsoft Nov 10, 2025
81d3906
copy existing suppress to openapi.json file
weidongxu-microsoft Nov 10, 2025
a61d2d7
update package name
v-jiaodi Nov 19, 2025
3c83b6f
update client name
v-jiaodi Nov 19, 2025
31faa2c
Merge branch 'main' into tsp-convertion_resources-policy
weidongxu-microsoft Nov 25, 2025
8770a17
for tsp 1.6.0
weidongxu-microsoft Nov 25, 2025
95a1dcf
fix conflicts from folder structure refactor
zedy-wj Dec 8, 2025
e0ba8b8
Merge branch 'main' into tsp-convertion_resources-policy
v-jiaodi Dec 12, 2025
5265bc0
Update client.tsp
ChenxiJiang333 Dec 16, 2025
9161354
Update client.tsp
ChenxiJiang333 Dec 17, 2025
c9f3acc
Update tspconfig.yaml
ChenxiJiang333 Dec 17, 2025
3e509b1
Update client location annotation in policy client
ChenxiJiang333 Dec 22, 2025
c131197
add code
jliusan Dec 22, 2025
7a67306
Merge branch 'main' into tsp-convertion_resources-policy
weidongxu-microsoft Jan 6, 2026
bc62110
use Record type directly on property
weidongxu-microsoft Jan 6, 2026
64f849f
Merge branch 'main' into tsp-convertion_resources-policy
pshao25 Jan 6, 2026
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,197 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.Authorization;
/**
* The policy assignment.
*/
model PolicyAssignment
is Azure.ResourceManager.ExtensionResource<PolicyAssignmentProperties> {
...ResourceNameParameter<
Resource = PolicyAssignment,
KeyName = "policyAssignmentName",
SegmentName = "policyAssignments",
NamePattern = "^[^<>*%&:\\?.+/]*[^<>*%&:\\?.+/ ]+$"
>;

/**
* The location of the policy assignment. Only required when utilizing managed identity.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "For backward compatibility"
location?: string;

/**
* The managed identity associated with the policy assignment.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "For backward compatibility"
identity?: Identity;
}

alias PolicyAssignmentListParameters = {
/**
* The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. If $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is everything in the unfiltered list except those applied to sub scopes contained within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the given scope. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}.
*/
@query("$filter")
$filter?: string;

/**
* Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'.
*/
@query("$expand")
$expand?: string;

/**
* Maximum number of records to return. When the $top filter is not provided, it will return 500 records.
*/
@maxValue(1000)
@minValue(1)
@query("$top")
$top?: int32;
};

#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator"
interface PolicyAssignmentGenericOps
extends Azure.ResourceManager.Legacy.ExtensionOperations<
{
...SubscriptionIdParameter,
...ResourceGroupParameter,

/**
* The namespace of the resource provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines)
*/
@path
@segment("providers")
resourceProviderNamespace: string,

/**
* The parent resource path. Use empty string if there is none.
*/
@path(#{ allowReserved: true })
parentResourcePath: string,

/**
* The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites).
*/
@path(#{ allowReserved: true })
resourceType: string,

/**
* The name of the resource.
*/
@path
@pattern("^.+$")
resourceName: string,

...ApiVersionParameter,
},
{
...Extension.ExtensionProviderNamespace<PolicyAssignment>,
},
{
...Extension.ExtensionProviderNamespace<PolicyAssignment>,
...KeysOf<PolicyAssignment>,
}
> {}

@armResourceOperations
interface PolicyAssignments {
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go has breaking change like these, and there are no ops named as these in tsp file but exist in swagger on main branch, are these funcs removed by designed ?

- Function `*AssignmentsClient.CreateByID` has been removed
- Function `*AssignmentsClient.DeleteByID` has been removed
- Function `*AssignmentsClient.GetByID` has been removed
- Function `*AssignmentsClient.UpdateByID` has been removed

@weidongxu-microsoft weidongxu-microsoft Jan 6, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are moved into client.tsp, because these ops are not the genuine "CRUD" on the resource model, but describing another equivalent route to it (e.g. route {endpoint}/{policyAssignmentId}). Also see PR description.

Chenjie seems fine to remove them from Go SDK.

If you'd like to have them, you can add "go" scope to these ops in client.tsp (currently it be @scope("java"))

Also note for #38509 (comment) on the get op

* This operation retrieves a single policy assignment, given its name and the scope it was created at.
*/
get is Extension.Read<
Extension.ScopeParameter,
PolicyAssignment,
Parameters = {
/**
* Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, EffectiveDefinitionVersion'.
*/
@query("$expand")
$expand?: string;
}
>;

/**
* This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "For backward compatibility"
create is Extension.CreateOrReplaceSync<
Extension.ScopeParameter,
PolicyAssignment,
Response = ArmResourceCreatedSyncResponse<PolicyAssignment>
>;

/**
* This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.
*/
@patch(#{ implicitOptionality: false })
update is Extension.CustomPatchSync<
Extension.ScopeParameter,
PolicyAssignment,
PatchModel = PolicyAssignmentUpdate
>;

/**
* This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'.
*/
delete is Extension.DeleteSync<
Extension.ScopeParameter,
PolicyAssignment,
Response = ArmResponse<PolicyAssignment> | ArmDeletedNoContentResponse
>;

/**
* This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group.
*/
listForResourceGroup is Extension.ListByTarget<
Extension.ResourceGroup,
PolicyAssignment,
Parameters = PolicyAssignmentListParameters
>;

/**
* This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group.
*/
@summary("Retrieves all policy assignments that apply to a management group.")
listForManagementGroup is Extension.ListByTarget<
Extension.ManagementGroup<"managementGroupId">,
PolicyAssignment,
Parameters = PolicyAssignmentListParameters
>;

/**
* This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}.
*/
@summary("Retrieves all policy assignments that apply to a subscription.")
list is Extension.ListByTarget<
Extension.Subscription,
PolicyAssignment,
Parameters = PolicyAssignmentListParameters
>;

/**
* This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp').
*/
@summary("Retrieves all policy assignments that apply to a resource.")
@get
listForResource is PolicyAssignmentGenericOps.List<
PolicyAssignment,
PolicyAssignmentListParameters
>;
}

@@doc(PolicyAssignment.name, "The name of the policy assignment to get.");
@@doc(PolicyAssignment.properties, "Properties for the policy assignment.");
@@doc(PolicyAssignments.create::parameters.resource,
"Parameters for the policy assignment."
);
@@doc(PolicyAssignments.update::parameters.properties,
"Parameters for policy assignment patch request."
);
Loading
Loading