This repository has been archived by the owner on Jan 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reopen Test ARM, test case for location-based resource
- Loading branch information
Showing
5 changed files
with
457 additions
and
0 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"@azure-tools/cadl-ranch-specs": patch | ||
--- | ||
|
||
Added tests for ARM, test case for LocationResource. |
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
172 changes: 172 additions & 0 deletions
172
packages/cadl-ranch-specs/http/azure/resource-manager/resources/location.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,172 @@ | ||
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.Resources; | ||
|
||
@locationResource | ||
model LocationResource is ProxyResource<LocationResourceProperties> { | ||
...ResourceNameParameter<LocationResource>; | ||
} | ||
|
||
/** Location resource properties */ | ||
model LocationResourceProperties { | ||
@doc("The description of the resource.") | ||
description?: string; | ||
|
||
/** The status of the last operation. */ | ||
@visibility("read") | ||
provisioningState?: ProvisioningState; | ||
} | ||
|
||
@armResourceOperations | ||
interface LocationResources { | ||
@scenario | ||
@scenarioDoc(""" | ||
Resource GET operation. | ||
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource | ||
Expected query parameter: api-version=2023-12-01-preview | ||
Expected response body: | ||
```json | ||
{ | ||
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Resources/locationResources", | ||
"properties":{ | ||
"description": "valid", | ||
"provisioningState": "Succeeded" | ||
}, | ||
"systemData": { | ||
"createdBy": "AzureSDK", | ||
"createdByType": "User", | ||
"createdAt": <any date>, | ||
"lastModifiedBy": "AzureSDK", | ||
"lastModifiedAt": <any date>, | ||
"lastModifiedByType": "User", | ||
} | ||
} | ||
``` | ||
""") | ||
get is ArmResourceRead<LocationResource>; | ||
|
||
@scenario | ||
@scenarioDoc(""" | ||
Resource PUT operation. | ||
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource | ||
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/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Resources/locationResources", | ||
"properties": { | ||
"description": "valid", | ||
"provisioningState": "Succeeded" | ||
}, | ||
"systemData": { | ||
"createdBy": "AzureSDK", | ||
"createdByType": "User", | ||
"createdAt": <any date>, | ||
"lastModifiedBy": "AzureSDK", | ||
"lastModifiedAt": <any date>, | ||
"lastModifiedByType": "User", | ||
} | ||
} | ||
``` | ||
""") | ||
createOrUpdate is ArmResourceCreateOrUpdateAsync<LocationResource>; | ||
|
||
@scenario | ||
@scenarioDoc(""" | ||
Resource PATCH operation. | ||
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource | ||
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/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Resources/locationResources", | ||
"properties":{ | ||
"description": "valid2", | ||
"provisioningState": "Succeeded" | ||
}, | ||
"systemData": { | ||
"createdBy": "AzureSDK", | ||
"createdByType": "User", | ||
"createdAt": <any date>, | ||
"lastModifiedBy": "AzureSDK", | ||
"lastModifiedAt": <any date>, | ||
"lastModifiedByType": "User", | ||
} | ||
} | ||
``` | ||
""") | ||
update is ArmResourcePatchSync<LocationResource, LocationResourceProperties>; | ||
|
||
@scenario | ||
@scenarioDoc(""" | ||
Resource DELETE operation. | ||
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource | ||
Expected query parameter: api-version=2023-12-01-preview | ||
``` | ||
Expected response status code: 204 | ||
""") | ||
delete is ArmResourceDeleteSync<LocationResource>; | ||
|
||
@scenario | ||
@scenarioDoc(""" | ||
Resource LIST by resource group operation. | ||
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources | ||
Expected query parameter: api-version=2023-12-01-preview | ||
Expected response body: | ||
```json | ||
{ | ||
"value": [{ | ||
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Resources/locationResources", | ||
"properties":{ | ||
"description": "valid", | ||
"provisioningState": "Succeeded" | ||
}, | ||
"systemData": { | ||
"createdBy": "AzureSDK", | ||
"createdByType": "User", | ||
"createdAt": <any date>, | ||
"lastModifiedBy": "AzureSDK", | ||
"lastModifiedAt": <any date>, | ||
"lastModifiedByType": "User", | ||
} | ||
}] | ||
} | ||
``` | ||
""") | ||
listByParent is ArmResourceListByParent<LocationResource>; | ||
} |
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
Oops, something went wrong.