-
Notifications
You must be signed in to change notification settings - Fork 4k
[Resources] Added ExpandProperties functionality to GetAzureResourceGroup
#28161
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
Conversation
Test-AzResourceGroupDeployment output an empty warning as the conditionals were not accounting for all cases
Co-authored-by: Vincent Dai <[email protected]>
Introduces new filter models (GenericResourceFilterWithExpand, ResourceGroupFilterWithExpand) and updates SDK interfaces and implementations to support the $expand query parameter for retrieving createdTime and changedTime on resources and resource groups. Updates related cmdlets and tests to validate the new properties.
Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
GetAzureResource
and GetAzureResourceGroup
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.
Pull Request Overview
This PR adds $expand
support to the GetAzureResource and GetAzureResourceGroup cmdlets so that CreatedTime
and ChangedTime
are returned, and updates models, SDK clients, and tests accordingly.
- Extend
$expand
parameter usage in OData queries and direct GET calls to includecreatedTime,changedTime
- Augment
PSResource
/PSResourceGroup
models and extensions withCreatedTime
/ChangedTime
- Add and update tests to verify expanded properties and update SDK transforms and changelog
Reviewed Changes
Copilot reviewed 10 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/Resources/Resources/ChangeLog.md | Documented new expand functionality and fixed warnings |
src/Resources/Resources.Test/ResourceGroups/GetAzureResourceGroupCommandTests.cs | Added tests for timestamps on resource group cmdlet |
src/Resources/Resources.Test/Resource/GetAzureResourceCommandTests.cs | Updated tests to use expanded model and assert timestamps |
src/Resources/Resources.Test/Models.ResourceGroups/ResourceClientTests.cs | Updated mock setups to include $expand parameter |
src/Resources/Resources.Management.Sdk/README.md | Insert SDK readme transforms for $expand |
src/Resources/ResourceManager/SdkModels/ResourceGroups/PSResourceGroup.cs | Added CreatedTime and ChangedTime properties |
src/Resources/ResourceManager/SdkExtensions/NewResourcesExtensions.cs | Populate new timestamp properties in extension method |
src/Resources/ResourceManager/SdkClient/ResourceManagerSdkClient.cs | Change ListResources/ListByResourceGroup to use expanded filter |
src/Resources/ResourceManager/SdkClient/NewResourceManagerSdkClient.cs | Update FilterResourceGroups to set Expand and call GET with expand |
src/Resources/ResourceManager/Implementation/Resource/GetAzureResourceCmdlet.cs | Switch to expanded filter and set Expand in cmdlet |
Comments suppressed due to low confidence (2)
src/Resources/Resources/ChangeLog.md:23
- [nitpick] Add a space before the issue references, e.g.
...GetAzureResourceGroup
[#5814] [#27865], for consistent formatting.
* Added functionality for cmdlet `GetAzureResource` and `GetAzureResourceGroup`[#5814][#27865]
src/Resources/Resources.Test/Resource/GetAzureResourceCommandTests.cs:76
- [nitpick] Consider adding a test for the list (subscription-level) path of the Get-AzureResource cmdlet to verify
CreatedTime
andChangedTime
are returned when no ResourceId is provided.
public void GetsResourcesById()
Co-authored-by: Vincent Dai <[email protected]>
Introduces new filter models (GenericResourceFilterWithExpand, ResourceGroupFilterWithExpand) and updates SDK interfaces and implementations to support the $expand query parameter for retrieving createdTime and changedTime on resources and resource groups. Updates related cmdlets and tests to validate the new properties.
Fixed changelog
Deleted the GetsResourceGroupsWithTimestamps test, which duplicated the logic of an existing test. This reduces redundancy and simplifies the test suite.
Please fix the test errors. Don't forget to submit the recording files. |
This PR was labeled "needs-revision" because it has unresolved review comments or CI failures. |
src/Resources/ResourceManager/Implementation/Resource/GetAzureResourceCmdlet.cs
Outdated
Show resolved
Hide resolved
Hi @a0x1ab , please check wyunchi-ms's comment. |
GetAzureResource
and GetAzureResourceGroup
GetAzureResourceGroup
Added documentation for the -ExpandProperties parameter and related examples to Get-AzResource and Get-AzResourceGroup help files. Updated parameter type annotations and added missing parameter descriptions to improve clarity.
Updated Test-GetResourceGroupWithCreatedTimeAndChangedTime to use the -ExpandProperties flag when retrieving the resource group. Added a new session record to reflect the updated test behavior.
…mmands.Resources.Test.ScenarioTests.ResourceGroupTests/TestGetResourceGroupWithExpandProperties.json
Replaced explicit new CancellationToken() with It.IsAny<CancellationToken>() in Moq setups to make the tests less brittle and more flexible. Also updated a test call to FilterResourceGroups to include additional parameters.
Corrected the tag filter logic in FilterResourceGroups to use PSTagValuePair and improved formatting. Updated unit tests to use explicit CancellationToken instances instead of It.IsAny<CancellationToken>() for GetWithHttpMessagesAsync setups.
Description
PR pertains to the following issues:
Get-AzResourceGroup
: IncludecreatedTime
andchangedTime
, at least optionally #27865This PR introduces the following changes:
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.md
and reviewed the following information:ChangeLog.md
file(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
.## Upcoming Release
header in the past tense.ChangeLog.md
if no new release is required, such as fixing test case only.