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

Test ARM, test case for location-based resource #703

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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/fair-socks-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Added tests for ARM, test case for LocationResource.
156 changes: 156 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,162 @@ Expected response body:
}
```

### Azure_ResourceManager_Models_Resources_LocationTrackedResources_createOrUpdate

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

Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

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

Expected response body:

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

### Azure_ResourceManager_Models_Resources_LocationTrackedResources_delete

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

Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
Expected query parameter: api-version=2023-12-01-preview

````
Expected response status code: 204

### Azure_ResourceManager_Models_Resources_LocationTrackedResources_get

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

Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
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.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location",
"name": "location",
"type": "Azure.ResourceManager.Models.Resources/locationTrackedResources",
"location": "eastus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
````

### Azure_ResourceManager_Models_Resources_LocationTrackedResources_listByLocation

- 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.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources
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.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location",
"name": "location",
"type": "Azure.ResourceManager.Models.Resources/locationTrackedResources",
"location": "westus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}]
}
```

### Azure_ResourceManager_Models_Resources_LocationTrackedResources_update

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

Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"location": "westus",
"properties": {
"description": "valid2"
}
}
```

Expected response body:

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

### Azure_ResourceManager_Models_Resources_NestedProxyResources_createOrReplace

- Endpoint: `put https://management.azure.com`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

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

namespace Azure.ResourceManager.Models.Resources;

@resource("locationTrackedResources")
@parentResource(ResourceGroupLocationResource)
model LocationTrackedResource is TrackedResource<LocationTrackedResourceProperties> {
v-hongli1 marked this conversation as resolved.
Show resolved Hide resolved
...ResourceNameParameter<LocationTrackedResource>;
}

/** Employee properties */
model LocationTrackedResourceProperties {
@doc("The description of the resource.")
description?: string;

/** The status of the last operation. */
@visibility("read")
provisioningState?: ProvisioningState;
}

@armResourceOperations
interface LocationTrackedResources {
v-hongli1 marked this conversation as resolved.
Show resolved Hide resolved
@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
v-hongli1 marked this conversation as resolved.
Show resolved Hide resolved
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.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location",
"name": "location",
"type": "Azure.ResourceManager.Models.Resources/locationTrackedResources",
"location": "eastus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```
""")
get is ArmResourceRead<LocationTrackedResource>;

@scenario
@scenarioDoc("""
Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
{
"location": "westus",
"properties": {
"description": "valid",
}
}
```
Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location",
"name": "location",
"type": "Azure.ResourceManager.Models.Resources/locationTrackedResources",
"location": "westus",
"properties": {
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```
""")
createOrUpdate is ArmResourceCreateOrReplaceSync<LocationTrackedResource>;

@scenario
@scenarioDoc("""
Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
{
"location": "westus",
"properties": {
"description": "valid2",
}
}
```
Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location",
"name": "location",
"type": "Azure.ResourceManager.Models.Resources/locationTrackedResources",
"location": "westus",
"properties":{
"description": "valid2",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```
""")
update is ArmResourcePatchSync<LocationTrackedResource, LocationTrackedResourceProperties>;

@scenario
@scenarioDoc("""
Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location
Expected query parameter: api-version=2023-12-01-preview
```
Expected response status code: 204
""")
delete is ArmResourceDeleteSync<LocationTrackedResource>;

@scenario
@scenarioDoc("""
Resource LIST by resource group operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources
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.ResourceManager.Models.Resources/locations/eastus/locationTrackedResources/location",
"name": "location",
"type": "Azure.ResourceManager.Models.Resources/locationTrackedResources",
"location": "westus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}]
}
```
""")
listByLocation is ArmResourceListByParent<LocationTrackedResource>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "@azure-tools/typespec-azure-resource-manager";
import "@azure-tools/typespec-client-generator-core";
import "./toplevel.tsp";
import "./nested.tsp";
import "./location.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;
Expand Down
Loading
Loading