forked from Azure/azure-rest-api-specs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TypeSpec conversion for Purview Policy (Azure#26460)
* Initial Purview Policy TypeSpec conversion * Update examples * Fixing doc, ProxyResource and other fixes * Fixing output * Fixing example values * fix example values * Fixing addition of name * Fixing prettier on example json * Adding {scope} backcompat override * Fix model validation * Fixing model errors * Fixing format error * Work around scope size bug
- Loading branch information
1 parent
cec34cc
commit bbcbeaf
Showing
12 changed files
with
570 additions
and
214 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
specification/purviewpolicy/PurviewPolicy.Management/backcompat.tsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import "@typespec/http"; | ||
import "@azure-tools/typespec-azure-resource-manager"; | ||
|
||
using TypeSpec.Http; | ||
using Azure.ResourceManager; | ||
|
||
@@path(ResourceUriParameter.resourceUri, "scope"); | ||
@@Azure.ResourceManager.Private.armCommonParameter(ResourceUriParameter.resourceUri, | ||
"ScopeParameter", | ||
Azure.ResourceManager.CommonTypes.Versions.v5 | ||
); | ||
|
||
@@doc(Azure.ResourceManager.ResourceUriParameter.resourceUri, | ||
"The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'" | ||
); |
28 changes: 28 additions & 0 deletions
28
.../PurviewPolicy.Management/examples/2023-06-01-preview/Operations_List_MaximumSet_Gen.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"title": "Operations_List - generated by [MaximumSet] rule - generated by [MaximumSet] rule", | ||
"operationId": "Operations_List", | ||
"parameters": { | ||
"api-version": "2023-06-01-preview" | ||
}, | ||
"responses": { | ||
"200": { | ||
"body": { | ||
"value": [ | ||
{ | ||
"name": "Microsoft.Purview/operations/read", | ||
"display": { | ||
"provider": "Microsoft Purview", | ||
"resource": "Operations", | ||
"operation": "Read all operations", | ||
"description": "ybbxwadhxjnogglp" | ||
}, | ||
"isDataAction": true, | ||
"origin": "user", | ||
"actionType": "Internal" | ||
} | ||
], | ||
"nextLink": "https://management.azure.com/providers/Microsoft.Purview/operations?api-version=2023-06-01-preview&$skiptoken=asdreg" | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
.../PurviewPolicy.Management/examples/2023-06-01-preview/Operations_List_MinimumSet_Gen.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"title": "Operations_List - generated by [MinimumSet] rule", | ||
"operationId": "Operations_List", | ||
"parameters": { | ||
"api-version": "2023-06-01-preview" | ||
}, | ||
"responses": { | ||
"200": { | ||
"body": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
specification/purviewpolicy/PurviewPolicy.Management/main.tsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import "@typespec/rest"; | ||
import "@typespec/versioning"; | ||
import "@azure-tools/typespec-azure-core"; | ||
import "@azure-tools/typespec-azure-resource-manager"; | ||
import "./policy.tsp"; | ||
import "./backcompat.tsp"; | ||
|
||
using TypeSpec.Rest; | ||
using TypeSpec.Http; | ||
using Azure.ResourceManager.Foundations; | ||
using Azure.Core; | ||
using Azure.ResourceManager; | ||
using TypeSpec.Versioning; | ||
|
||
/** Creates a Microsoft.Purview management client. */ | ||
@armProviderNamespace | ||
@service({ | ||
title: "PurviewPolicyClient", | ||
}) | ||
@versioned(Versions) | ||
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) | ||
namespace Microsoft.Purview; | ||
|
||
/** The available API versions. */ | ||
enum Versions { | ||
/** 2023-06-01-preview version */ | ||
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) | ||
@useDependency(Azure.Core.Versions.v1_0_Preview_1) | ||
v2023_06_01_preview: "2023-06-01-preview", | ||
} | ||
|
||
interface Operations extends Azure.ResourceManager.Operations {} |
142 changes: 142 additions & 0 deletions
142
specification/purviewpolicy/PurviewPolicy.Management/policy.tsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import "@typespec/rest"; | ||
import "@typespec/http"; | ||
import "@typespec/openapi"; | ||
import "@azure-tools/typespec-azure-core"; | ||
import "@azure-tools/typespec-azure-resource-manager"; | ||
|
||
using Rest; | ||
using Http; | ||
using OpenAPI; | ||
using Azure.ResourceManager; | ||
|
||
namespace Microsoft.Purview; | ||
|
||
@armResourceOperations | ||
interface PurviewPolicies { | ||
/** The API lists the Azure purview RBAC policies affecting the scope. The scope can be any valid ARM resource id */ | ||
@summary("API to list the purview RBAC policies based on a scope") | ||
@tag("PolicyListing") | ||
list is ArmResourceListByParent< | ||
Policy, | ||
{ | ||
...Foundations.BaseParameters<Policy>; | ||
...SkipTokenParameter; | ||
|
||
/** Supported filters : $filter=policyType eq SelfService, $filter=policyType eq SqlDevops. Returns only the policies of the specified type. If not specified, all policies are returned. */ | ||
@extension("x-ms-skip-url-encoding", true) | ||
@query("$filter") | ||
filter?: string; | ||
} | ||
>; | ||
} | ||
|
||
/** The skipToken parameter definition. */ | ||
model SkipTokenParameter { | ||
/** Paging key to paginate to next page. */ | ||
@extension("x-ms-parameter-location", "method") | ||
@query | ||
skipToken?: string; | ||
} | ||
|
||
/** The objectType of the member. */ | ||
enum ObjectType { | ||
/** AAD User object type. */ | ||
User, | ||
|
||
/** AAD Group object type. */ | ||
Group, | ||
|
||
/** Service Principal object type. */ | ||
ServicePrincipal, | ||
} | ||
|
||
/** The effect for rule */ | ||
enum Decision { | ||
/** Access permitted */ | ||
Permit, | ||
|
||
/** Access denied */ | ||
Deny, | ||
} | ||
|
||
/** A paginated list of purview RBAC policies */ | ||
model PolicyList is Azure.Core.Page<Policy>; | ||
|
||
/** Purview RBAC policy */ | ||
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "Special ARM resource with no property bag" | ||
@extensionResource | ||
@segment("policies") | ||
model Policy extends Azure.ResourceManager.Foundations.ProxyResourceBase { | ||
/** The policy kind */ | ||
kind?: string; | ||
|
||
/** The policy source */ | ||
source: string; | ||
|
||
/** The etag version of a policy */ | ||
etag: string; | ||
|
||
/** Array of scopes where the policy is published */ | ||
scopes: string[]; | ||
|
||
/** Members of the policy */ | ||
members: PolicyMembers; | ||
|
||
/** Array of decision rules for the policy */ | ||
decisionRules: PolicyDecisionRule[]; | ||
|
||
/** The timestamp of the expiry time of the policy (UTC). */ | ||
// FIXME: (utcDateTime) Please double check that this is the correct type for your scenario. | ||
expiryTime?: utcDateTime; | ||
|
||
/** The AAD member who requested the policy */ | ||
requestor?: string; | ||
} | ||
|
||
/** Policy member */ | ||
model PolicyMembers { | ||
/** Array of azure active directory members */ | ||
fabricItemMembers?: FabricItemMember[]; | ||
|
||
/** Array of azure active directory members */ | ||
aadMembers?: AadMember[]; | ||
} | ||
|
||
/** Microsoft fabric item member */ | ||
model FabricItemMember { | ||
/** Source path of the member */ | ||
sourcePath?: string; | ||
|
||
/** Array of access items for the member */ | ||
itemAccess?: string[]; | ||
} | ||
|
||
/** Azure active directory member */ | ||
model AadMember { | ||
/** The tenantId of the member */ | ||
tenantId?: string; | ||
|
||
/** The objectId of the member */ | ||
objectId?: string; | ||
|
||
/** The objectType of the member. */ | ||
objectType?: ObjectType; | ||
} | ||
|
||
/** Purview RBAC policy decision rule */ | ||
model PolicyDecisionRule { | ||
/** The effect for rule */ | ||
effect: Decision; | ||
|
||
/** Array of attribute predicates */ | ||
permission?: AttributePredicate[]; | ||
} | ||
|
||
/** Attribute predicate for a policy permission */ | ||
model AttributePredicate { | ||
/** AttributeName of a policy permission */ | ||
attributeName?: string; | ||
|
||
/** values for a policy permission */ | ||
attributeValueIncludedIn?: string[]; | ||
} |
12 changes: 12 additions & 0 deletions
12
specification/purviewpolicy/PurviewPolicy.Management/tspconfig.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
emit: | ||
- "@azure-tools/typespec-autorest" | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
emitter-output-dir: "{project-root}/.." | ||
azure-resource-provider-folder: "resource-manager" | ||
output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/policy.json" | ||
examples-directory: "{project-root}/examples" | ||
omit-unreachable-types: true | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-resource-manager/all" |
29 changes: 0 additions & 29 deletions
29
...source-manager/Microsoft.Purview/preview/2023-06-01-preview/examples/Operations_List.json
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
...Microsoft.Purview/preview/2023-06-01-preview/examples/Operations_List_MaximumSet_Gen.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"title": "Operations_List - generated by [MaximumSet] rule - generated by [MaximumSet] rule", | ||
"operationId": "Operations_List", | ||
"parameters": { | ||
"api-version": "2023-06-01-preview" | ||
}, | ||
"responses": { | ||
"200": { | ||
"body": { | ||
"value": [ | ||
{ | ||
"name": "Microsoft.Purview/operations/read", | ||
"display": { | ||
"provider": "Microsoft Purview", | ||
"resource": "Operations", | ||
"operation": "Read all operations", | ||
"description": "ybbxwadhxjnogglp" | ||
}, | ||
"isDataAction": true, | ||
"origin": "user", | ||
"actionType": "Internal" | ||
} | ||
], | ||
"nextLink": "https://management.azure.com/providers/Microsoft.Purview/operations?api-version=2023-06-01-preview&$skiptoken=asdreg" | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...Microsoft.Purview/preview/2023-06-01-preview/examples/Operations_List_MinimumSet_Gen.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"title": "Operations_List - generated by [MinimumSet] rule", | ||
"operationId": "Operations_List", | ||
"parameters": { | ||
"api-version": "2023-06-01-preview" | ||
}, | ||
"responses": { | ||
"200": { | ||
"body": {} | ||
} | ||
} | ||
} |
Oops, something went wrong.