Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add armResourceType scalar in typespec-azure-core #1272

Merged
merged 18 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .chronus/changes/add-resource-type-2024-6-31-14-6-51.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-azure-core"
- "@azure-tools/typespec-azure-resource-manager"
---

Add `armResourceType` scalar, and changed some properties to be `armResourceType` instead of string
1 change: 1 addition & 0 deletions packages/samples/common-types/gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function cleanupDocument(original: OpenAPI2Document): OpenAPI2Document {

replaceUuidRefs(document, "Azure.Core.uuid");
replaceUuidRefs(document, "Azure.Core.azureLocation");
replaceUuidRefs(document, "Azure.Core.armResourceType");
markcowl marked this conversation as resolved.
Show resolved Hide resolved

return document;
}
Expand Down
13 changes: 12 additions & 1 deletion packages/typespec-azure-core/lib/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ scalar eTag extends string;
*/
scalar azureLocation extends string;

/**
* Represents an Azure Resource Type.
*
* @example
*
* ```
* Microsoft.Network/virtualNetworks/subnets
* ```
*/
scalar armResourceType extends string;

/**
* A type definition that refers the id to an Azure Resource Manager resource.
*
Expand Down Expand Up @@ -392,7 +403,7 @@ alias AllArmResourceDeploymentScopes = [

model ArmResourceIdentifierAllowedResource {
/** The type of resource that is being referred to. For example Microsoft.Network/virtualNetworks or Microsoft.Network/virtualNetworks/subnets. See Example Types for more examples. */
type: string;
type: armResourceType;

/**
* An array of scopes. If not specified, the default scope is ["ResourceGroup"].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ model Resource {

/** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */
@visibility("read")
type?: string;
type?: armResourceType;

/** Azure Resource Manager metadata containing createdBy and modifiedBy information. */
@visibility("read")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ model Azure.Core.ArmResourceIdentifierAllowedResource

#### Properties

| Name | Type | Description |
| ------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| type | `string` | The type of resource that is being referred to. For example Microsoft.Network/virtualNetworks or Microsoft.Network/virtualNetworks/subnets. See Example Types for more examples. |
| scopes? | `Core.ArmResourceDeploymentScope[]` | An array of scopes. If not specified, the default scope is ["ResourceGroup"].<br />See [Allowed Scopes](https://github.com/Azure/autorest/tree/main/docs/extensions#allowed-scopes). |
| Name | Type | Description |
| ------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| type | [`armResourceType`](#Azure.Core.armResourceType) | The type of resource that is being referred to. For example Microsoft.Network/virtualNetworks or Microsoft.Network/virtualNetworks/subnets. See Example Types for more examples. |
| scopes? | `Core.ArmResourceDeploymentScope[]` | An array of scopes. If not specified, the default scope is ["ResourceGroup"].<br />See [Allowed Scopes](https://github.com/Azure/autorest/tree/main/docs/extensions#allowed-scopes). |

### `AzureApiKeyAuthentication` {#Azure.Core.AzureApiKeyAuthentication}

Expand Down Expand Up @@ -535,6 +535,20 @@ model MyModel {
}
```

### `armResourceType` {#Azure.Core.armResourceType}

Represents an Azure Resource Type.

```typespec
scalar Azure.Core.armResourceType
```

#### Examples

```
Microsoft.Network/virtualNetworks/subnets
```

### `azureLocation` {#Azure.Core.azureLocation}

Represents an Azure geography region where supported resource providers live.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,7 @@ model Azure.ResourceManager.CommonTypes.Resource
| ----------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id? | `Core.armResourceIdentifier` | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
| name? | `string` | The name of the resource |
| type? | `string` | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" |
| type? | `Core.armResourceType` | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" |
| systemData? | [`SystemData`](./data-types.md#Azure.ResourceManager.CommonTypes.SystemData) | Azure Resource Manager metadata containing createdBy and modifiedBy information. |

### `ResourceAssociation` {#Azure.ResourceManager.CommonTypes.ResourceAssociation}
Expand Down
Loading