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
Test ARM, test case for location-based resource #703
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5dce139
Test ARM, test case for location-based resource
v-hongli1 b4ef4db
Fixed value of resource type.
v-hongli1 b99c9f6
Fixed value of resource name.
v-hongli1 218837d
Fixed comments https://github.com/Azure/cadl-ranch/pull/703#discussio…
v-hongli1 ee18727
Fixed comments https://github.com/Azure/cadl-ranch/pull/703#discussio…
v-hongli1 a113795
Merge branch 'main' into issues#686
v-hongli1 571af43
Merge branch 'main' into issues#686
v-hongli1 ba81c29
Fixed comments https://github.com/Azure/cadl-ranch/pull/703#discussio…
v-hongli1 575ac00
Fixed comment https://github.com/Azure/cadl-ranch/pull/703#discussion…
v-hongli1 370a3c1
Merge branch 'main' into issues#686
v-hongli1 3ae61f7
Merge branch 'main' into issues#686
v-hongli1 cd2eb5c
Merge branch 'main' into issues#686
v-hongli1 0c483cf
Change the referenced ARM Resource Type to `@locationResource`.
v-hongli1 c706c41
Merge branch 'main' into issues#686
v-hongli1 a88c290
Merge branch 'main' into issues#686
v-hongli1 e64fa4b
Merge branch 'main' into issues#686
v-hongli1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/models/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.Models.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.Models.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.Models.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Models.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.Models.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.Models.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Models.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.Models.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.Models.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Models.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.Models.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.Models.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.Models.Resources/locationResources/resource", | ||
"name": "resource", | ||
"type": "Azure.ResourceManager.Models.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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to call this scenario
Azure_ResourceManager_Models_Resources_Location_ResourceGroup_createOrUpdate
or
Azure_ResourceManager_Models_Resources_Location_ResourceGroupLocationResource_createOrUpdate
,since this PR covers
ResourceGroupLocationResource
, and we also haveSubscriptionLocationResource
andTenantLocationResource
which we don't cover here.@weidongxu-microsoft @tadelesh Would like your opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer the shorter one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iscai-msft Here's another case where we may need
@clientName
:We want the scenario name be
Azure_ResourceManager_Models_Resources_Location_ResourceGroup_createOrUpdate
, this may require an interface calledResourceGroup
.For generated SDK, it'll generate a client called
ResourceGroup
... This is not a big issue since it resides under the corresponding namespace, though still a bit weird to me...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XiaofeiCao is it possible for you to compile a list of all of the categories and subcategories, so we can agree on the current ordering? Everything's getting long and confusing imo. Something like
For example, I don't think we need
Models
as a namespaceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iscai-msft Here's what's intended to be:
Basically it's following this issue's structure, and
typespec-azure
's sample folder. Any suggestions are welcome too!Models
seems unnecessary, we could remove that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my suggestion, @timotheeguerin please lmk your thoughts