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

Tests for ARM, adds TrackedResource #588

Merged
merged 23 commits into from
Jun 18, 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
5 changes: 5 additions & 0 deletions .changeset/short-owls-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": minor
---

Added tests for ARM's tracked resource and nested resource.
337 changes: 337 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,343 @@ Expects header 'x-ms-api-key': 'valid-key'

Expects header 'authorization': 'Bearer https://security.microsoft.com/.default'

### Azure_Arm_Models_Resources_NestedProxyResources_createOrReplace

- Endpoint: `put https://management.azure.com`

Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"properties": {
"description": "valid"
}
}
```

Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested",
"name": "nested",
"type": "nested",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```

### Azure_Arm_Models_Resources_NestedProxyResources_delete

- Endpoint: `delete https://management.azure.com`

Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested
Expected query parameter: api-version=2023-12-01-preview
Expected response status code: 204

### Azure_Arm_Models_Resources_NestedProxyResources_get

- Endpoint: `get https://management.azure.com`

Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested",
"name": "nested",
"type": "nested",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```

### Azure_Arm_Models_Resources_NestedProxyResources_listByTopLevelTrackedResource

- Endpoint: `get https://management.azure.com`

Resource LIST by parent resource operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"value": [{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested",
"name": "nested",
"type": "nested",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}]
}
```

### Azure_Arm_Models_Resources_NestedProxyResources_update

- Endpoint: `patch https://management.azure.com`

Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"properties": {
"description": "valid2"
}
}
```

Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top/nestedProxyResources/nested",
"name": "nested",
"type": "nested",
"properties":{
"description": "valid2",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```

### Azure_Arm_Models_Resources_TopLevelTrackedResources_createOrReplace

- Endpoint: `put https://management.azure.com`

Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"location": "eastus",
"properties": {
"description": "valid"
}
}
```

Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top",
"name": "top",
"type": "topLevel",
"location": "eastus",
"properties": {
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```

### Azure_Arm_Models_Resources_TopLevelTrackedResources_delete

- Endpoint: `delete https://management.azure.com`

Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top
Expected query parameter: api-version=2023-12-01-preview

````
Expected response status code: 204

### Azure_Arm_Models_Resources_TopLevelTrackedResources_get

- Endpoint: `get https://management.azure.com`

Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top
Expected query parameter: api-version=2023-12-01-preview

Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top",
"name": "top",
"type": "topLevel",
"location": "eastus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
````

### Azure_Arm_Models_Resources_TopLevelTrackedResources_listByResourceGroup

- Endpoint: `get https://management.azure.com`

Resource LIST by resource group operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"value": [{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top",
"name": "top",
"type": "topLevel",
"location": "eastus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}]
}
```

### Azure_Arm_Models_Resources_TopLevelTrackedResources_listBySubscription

- Endpoint: `get https://management.azure.com`

Resource LIST by subscription operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"value": [{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top",
"name": "top",
"type": "topLevel",
"location": "eastus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}]
}
```

### Azure_Arm_Models_Resources_TopLevelTrackedResources_update

- Endpoint: `patch https://management.azure.com`

Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"properties": {
"description": "valid2"
}
}
```

Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.Arm.Models.Resources/topLevelTrackedResources/top",
"name": "top",
"type": "topLevel",
"location": "eastus",
"properties":{
"description": "valid2",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```

### Azure_ClientGenerator_Core_Access_InternalOperation

- Endpoints:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import "@azure-tools/cadl-ranch-expect";
import "@typespec/http";
import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@azure-tools/typespec-client-generator-core";
import "./toplevel.tsp";
import "./nested.tsp";

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

@armProviderNamespace
@service
@versioned(Versions)
@doc("Arm Resource Provider management API.")
namespace Azure.Arm.Models.Resources;

@doc("Azure API versions.")
enum Versions {
@armCommonTypesVersion(CommonTypes.Versions.v5)
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1)
@doc("Preview API version 2023-12-01-preview.")
v2023_12_01_preview: "2023-12-01-preview",
XiaofeiCao marked this conversation as resolved.
Show resolved Hide resolved
}

union ProvisioningState {
ResourceProvisioningState,
Provisioning: "Provisioning",
Updating: "Updating",
Deleting: "Deleting",
Accepted: "Accepted",
}
Loading
Loading