Skip to content

Commit b90e64f

Browse files
m-nashbquantumpnisha-bhatiaallenjzhangYalin Li
authored
merge Azure.ResourceManager.Core into main (#22507)
* initial checkin for core / tests (#18968) * initial checkin for core / tests * Add readme.md file * Fix header in readme * remove autorest until we convert off hand written types * update azure.core reference remove sets to tags ignore tests which require credentials for now * Add the proto client which will be used until the autogen work is complete * Add missing readmes for proto client * update to require linq 4.0.0 so that don't have to upgrade bcl * add changlog for CI * change system.linq.async to update * update to use source vs binary for the temporary generation of Azure.ResourceManager.Authorization * Add changelog for azure.resourcemanager.authorization and update version to be beta * update typos in readme * update name of proto client sln * merge in changes from proto repo this week * fixed unit test failures missed a few files from the merge from proto repo updated compute and network sdk version to use latest azure.core with readonly list types * ignore tests which require live azure until 5122 is closed * Update failing scenario test * Subnet Container list still returns SubnetOperations and not Subnet #5584 (#19109) * 5584 * Update async test * Test * WIP: test * Update Proto.Authorization.csproj * Update Proto.Authorization.csproj * Update Proto.Authorization.csproj * Update Proto.Authorization.csproj * add param checking to resource (#19134) * Adding parameter check for track 2 Azure.ResourceManager.core (#19162) * initial checkin * adding test cases * nibhati-5142-add Params and testing for ApiVersionBase.cs (#19193) * add tests for ApiVersionBase * update methods * nibhati - 5142 - add tests for ArmBuilder.cs (#19231) * add tests for ArmBuilder * Update ArmBuilderTests.cs * Update SubscriptionContainer.cs * Update test project to consume framework for recorded tests (#19171) * Update test project to consume framework for recorded tests * Changes required to get instrumentation working for the new armClient added support for session recording for onetimesetup and onetimeteardown * move unit test files * update tests to not use username for prefix * update targets to separate existing track 2 libraries from new core until autorest changes are finished * merge in armbuildertest and update to use new framework * remove necessity on session files if no onetimesetup * Address review comments * Move ApiVersionOverrides to ARMClientOptions class (#19358) * Rename list operations (#19386) * tenant resource sample (#19195) * WIP: tenant resource * WIP: updates * Update ResourceIdentifier.cs * Update ResourceIdentifier.cs * Update ResourceType.cs * WIP update check * WIP * Add readme for billing * Stylecop * WIP * Remove style * wip: update * WIP: updates * WIP * WIP: update * WIP * Updates * WIP: updates * Update * WIP: updates * WIP * Update tests * WIP: updates * Remove reference for Azure.Identity (#19434) * Remove reference for Azure.Identity * fixing ArmClient construction in proto client * resync and fix build error * 5521 - Rename TryGetValue to TryGet/TryGetAsync (#19478) * Rename TryGetValue to TryGet/TryGetAsync * Update ContainerBase.cs * Update ContainerBase.cs * Update TryGet method and test class * Update CheckResourceExists.cs * Rename TryGetValue to TryGet/TryGetAsync * Update ContainerBase.cs * Update ContainerBase.cs * Update TryGet method and test class * Update CheckResourceExists.cs * Update ContainerBaseTest.cs * Update TryGet Test * Update tests * Update tests and framework to instrument all clients recursively (#19443) * Framework changes * Azure.ResourceManager.Core changes to support client interceptors * Test changes * proto client changes * updates after merge * Address review comments * WIP * updates after WIP * Update the implicit operator (#19720) * Remove System.Linq.Async dependency. (#19745) * Change the accessibility to virtual for Resource.Id (#19804) * Sku Serialization (#19819) * Sku Serialization * Divide Sku class * Update Sku * Add lookup mechanism for ID to apiversion (#19437) * WIP: updates * WIP: updates * Update test * Update ResourceListOperationsTest.cs * Update CreateSingleVmExample.cs * Update CreateSingleVmExample.cs * Update CreateSingleVmExample.cs * Update CreateSingleVmExample.cs * WIP: Updates * Add extra line * Update * WIP: * WIP: updates * WIp: updates * Remove API version extensions * WIP: updates * Updates * Update test * WIP updates * Updates * WIP * Remove blank lines * Update filtering * Updates * Update * WIP: updates * WIP: updates * Add space * Remove debug * Updates * WIP: updates * WIP * Change the accessbility to virtual for Resource.Id * WIP: updates * WIP Updates * WIP updates * WIP * WIP * WIP: * revert * WIP: updates * WIP: updates * WIP: updated * WIP Co-authored-by: YalinLi0312 <yall@microsoft.com> * Resource Identifier changes (#19636) * Resource Identifier changes * Adapting Container classes to base class change in Id property * Fixing xml documentation comments for ResourceType * Cleaning up resource id ToStrign() and fixing ListLocations client creation * Adjusting new tenant resource operations for resource id scheme * Responding to review comments * Add test coverage, retain string reresentation of resource id * Fixing additional merge issues * Updating comparison tests to use concrete variable types * Plan Serialization (#19820) * Plan Serialization * Divide Plan class * Update Plan * Mnash 5705 rename container (#19932) * Change the accessbility to virtual for Resource.Id * rename ArmClient, ArmClientOptions, Get[Resource]Container * updates after merge * missing one file for rename Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> * 2 missing renames (#19952) * Change the accessbility to virtual for Resource.Id * rename ArmClient, ArmClientOptions, Get[Resource]Container * updates after merge * missing one file for rename * Missed 2 renames Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> * nibhati - 5191 - add ClientContext.cs (#19602) * WIP * WIP * Update ResourceOperationsBase.cs * update for tenant extensions * update csproj * Update Azure.ResourceManager.Network.csproj * update csproj * update csproj * WIP * WIP * update csproj * update csproj * update csproj * add tests * update test * update * fix test cases to use the diagnostics case fix a missing mocking constructor * WIP * update framework for tests * Update Azure.Test.Perf.csproj * merge * revert list json files * revert * WIP * fix ci * Update Program.cs * update proto * fix test * Update ClientContextTests.cs * update proto * Update Azure.ResourceManager.Billing.csproj * update version * update ci * Update Azure.ResourceManager.EventHubs.csproj * add packable Co-authored-by: m-nash <prognash@microsoft.com> * GenericResource Serialization (#19898) * Resource Serialization * Plan Serialization * Divide Plan class * Divide Resource class * Update writer * Update Plan * TrackedResource Serialization * Update GenericResource * Clean Up * Update GenericResource * Remove read only * Update tests * TrackedResource Serialization (#19855) * Resource Serialization * Divide Resource class * Update writer * TrackedResource Serialization * Update Deserialization * Update Test * Update Tests * Update Tracked Resource * Fix PR * Remove readonly * Remove the Get[Resource]Operations methods except for client extensions (#20136) * Change the accessbility to virtual for Resource.Id * wip * ignore test temporarily * update to remove Get[Resource]Operations Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> * nibhati - 5572 - make Credentials and Options internal (#20243) * Change the accessbility to virtual for Resource.Id * add transport * update test * add jsons * add json * remove transport Co-authored-by: YalinLi0312 <yall@microsoft.com> * Remove ignore on tests that were failing due to faulted tasks in interceptor (#20341) * Change the accessbility to virtual for Resource.Id * remove ignore on tests and update intrumentation to handle faulted tasks Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <micnash@microsoft.com> * Make the Reference type generic (#20358) * Change the accessbility to virtual for Resource.Id * Make the reference type generic Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * nibhati 5401 - add CancellationToken to GetResource() (#20396) * Change the accessbility to virtual for Resource.Id * add token Co-authored-by: YalinLi0312 <yall@microsoft.com> * JonathanCrd 5574 - remove system.collections.immutable (#20437) * Change the accessbility to virtual for Resource.Id * Removing package reference to System.Collections.Immutable * Removing use of ImmutableList Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * JonathanCrd 5003 - comparison methods for ResourceIdentifier (#20456) * Change the accessbility to virtual for Resource.Id * Operators == and != overloads in ResourceIdentifier * Added EqualsToString Tests and TestCases Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * update constructors for reference types (#20477) * update constructors for reference types * fix stylecop issue * fixes after merge * add two way implicit for autorest deserialization (#20557) * update constructors for reference types * fix stylecop issue * add two way implicit for autorest deserialization * Add a common definition for sub-resource (#20524) * add SubResource * serialization of the two classes * protected internal; full subresource namespace Co-authored-by: Yeming Liu <yeliu@microsoft.com> * Add default constructors to resource classes (#20583) * update constructor signatures for autogen (#20607) * update constructors for reference types * fix stylecop issue * add two way implicit for autorest deserialization * update constructor signatures for autogen * Remove ProxyResource since its intended to be used any longer (#20608) * adding reference constructors attributes (#20611) * update constructors for reference types * fix stylecop issue * add two way implicit for autorest deserialization * update constructor signatures for autogen * add attributes to define ctor types for autogen * Cache the creation of HTTP pipeline in ArmClient (#20636) * Remove create from container base; remove ArmBuilder abstract class (#20684) * Remove create from container base; remove ArmBuilder abstract class * UnTypedContainer->Container; fix doc issues * make createAsync() virtual Co-authored-by: Yeming Liu <yeliu@microsoft.com> * fixes after merge * adding singleton pattern in Arm.Core and Proto (#20591) * adding initial singleton base classs and proto code * PR comment fix. * Completed singleton VMSS test case. * Fix merge issue around ArmBuilder removal * Fix build issue. * Fixing test failure * CR comment. * Flattend the builder to partial classes. * CR fix * Update arm response types to match current Azure.Core pattern (#20738) * WIP * wip * Change the accessbility to virtual for Resource.Id * update strawman for operation changes * finalize changes before testing * update ph overloads * move pipeline creation into armoperation * wip * updates based on new OperationInternals * address PR comments * update test classes to use new pattern * final fixes for arm core tests * use mock response instead of null * updates to proto code * add null check around basetype Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> * Fix a bug in ArmClient (#20897) * Move generic resource from resources to core (#20927) * initial changes to move generic resource items over * wip updating tests * more work on test cases * updates to adapt the operation changes * remove arm response / operation * remove unused classes now and finish move resource test * update resourcegroup operation tests * update tests for genericresource operations * add genericresource container tests * update proto solution * update proto comments * address naming comments * update comments which no longer have inheritance address wildcard comment in csproj * update ResourceContainerBase (#20981) Co-authored-by: Yeming Liu <yeliu@microsoft.com> * updates to subresource type (#21010) clean up extensions meant for Operation now * VM image, extension image (edgezone not included as it is new not in Compute sdk yet) (#20971) * update reference types and add unit tests to validate (#21031) * updates to subresource type clean up extensions meant for Operation now * need protected internal serialization constructor for reference types, added unit tests to validate for future * updates after merge * update policy copying for clone and convert (#21069) * 5771 - GetGenericResourceOperations in ArmClient (#21066) * Change the accessbility to virtual for Resource.Id * GetGenericResourceOperations extension method implementation * Create ArmClientTests.cs * Scenario Tests * GetGenericResourceOperations for single ID * Single ID tests * Addressing comments * Tests recordings * Tests recordings Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * 5844 Rename SubResourceWritable to WritableSubResource (#21092) * Rename symbol * Rename class * Rename serialization class * Merge Azure.ResourceManager.Resources.Models.Subscription with Azure.ResourceManager.Core.SubscriptionData (#20751) * Initial * Merge * Update SubscriptionOperations.cs * Fix error * Update using * Update test * Fix tests * Update json * Update ClientContextTests.cs * update based on comments * Add get test * Remove unnecessary file * Update LocationListResult.cs * Update ClientContextTests.cs * Update operation class & add tests * move models to model folder Co-authored-by: m-nash <prognash@gmail.com> * remove id type from container base to match operation base (#21150) * remove id type from container base to match operation base * update proto references * add support for root resource Id container (#21175) * remove id type from container base to match operation base * update proto references * add support for root resource Id container * Merge ResourceGroup model in Resources with ResourceGroupData in Core (#20904) * Change the accessbility to virtual for Resource.Id * Merge ResourceGroup model in Resources with Core ResourceGroupData * Add and update scenario tests * Resolve merge conflicts * Update scenario tests * Record ResourceGroupContainerTests * Initialize Tags in base class * Update ResourceGroupOperationsTests and re-record * Fix the errors in Proto.Client scenario tests * Move some files in Generated folder back * Address review comments * Add records * Fix the failing test StartExportTemplate * Address comments * Change tag lro operations to return its lro type * Change rg CreateOrUpdate lro operations to return its lro object * Update CreateOrUpdate lro object * Run tests Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Delete PhTaskDeferringAsyncPageable.cs (#21183) * Remove PhArmResponse (#21139) * Remove PhArmResponse part 1 * Remove PhArmResponse part 2 * Delete PhArmResponse.cs Co-authored-by: m-nash <prognash@gmail.com> * Remove PhArmOperation (#21290) * Remove PhArmOperation * Disable TestResourceTypeFilterParamCheck Test * Disable SA warning * remove unused file Co-authored-by: m-nash <prognash@gmail.com> * 5841 - Update List methods from proto clients. (#21314) * Remove List methods with inner Get() call in Compute * Remove List methods with inner Get() call in Network * Removing scenario tests referencing deleted List() methods * Add lambda wrapper in armclient for getting container objects in othe… (#21390) * Add lambda wrapper in armclient for getting container objects in other RPs * update xml comments * 5285 Remove TrackedResource<TIdentifier, TModel> class. (#21376) * Delete TrackedResource.cs * Removed class from Core added to individual Proto Libraries * Removing imported class in Proto.Client * Add missing new lines * update to allow external access to a constructor that doesn't have an operation base (#21395) * Add lambda wrapper in armclient for getting container objects in other RPs * update xml comments * update to add externally accesible constructor that doesn't have an operation base like armclient as the parent * Move Azure.ResourceManager.Resources Tenants objects to Azure.ResourceManager,Core (#21413) * Change the accessbility to virtual for Resource.Id * Move Azure.ResourceManager.Resources Tenants objects to Azure.ResourceManager.Core * Resolve conflicts Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Templetize SubResource and WritableSubResource classes, and added unit tests (#21397) * Change the accessbility to virtual for Resource.Id * Sub resource template and tests * public class , public constructor * some PR comments * PR comments and phonecall around silent errors and casting Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Remove the suppression for namespace in mgmt sdks (#21534) * remove no warn AZC0001 * remove the namespace warn suppression from mgmt plane sdks * remove old todo * update tenant and subscription list resource hooks to follow the same pattern (#21568) * fix the attribute of subresource (#21685) * fix the attribute of writableSubResource (#21688) * Add ArmClient tests (#21620) * Change the accessbility to virtual for Resource.Id * Add tests for ArmClient * Address review comment * Update recordings Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Add GenericResourceContainer tests (#21759) * Change the accessbility to virtual for Resource.Id * Add CreateOrUpdate tests * Add StartCreateOrUpdate tests * Add Get tests * Add GetApiVersion and ListByResourceGroup tests * Update test records Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Bug System.ArgumentOutOfRangeException thrown in ResourceIdentifier - 5879 - nibhati (#21537) * add list resources apis to resourceGroupOperations (#21809) * [Azure.ResourceManager.Core] Introduce the `UseClientContext` to `SubscriptionOperations` and `ResourceGroupOperations` (#21811) * introduce the useClientContext to subscriptionOperations and ResourceGroupOperations * resolve comments * resolve comments * fix compile errors in other solutions * Add ResourceGroupContainer tests (#21832) * Change the accessbility to virtual for Resource.Id * Add ResourceGroupContainer tests Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * remove ph classes (#21852) * remove ph classes * add temp files to proto * change Parent in ContainerBase to OperationsBase type (#21872) * Add GenericResourceOperations tests (#21828) * Change the accessbility to virtual for Resource.Id * Add GenericResourceOperations tests * Merge GenericResourceOperationsTests and GenericResourceTests Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Add ResourceGroupOperations tests (#21893) * Change the accessbility to virtual for Resource.Id * Add ResourceGroupOperations tests * Remove parallelizable tag * Update session records Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * update to be inside core namespace (#21892) * update to be inside core namespace * update proto references to removed namespace * remove references from test proj * remove unused interfaces (#21898) * update to be inside core namespace * update proto references to removed namespace * remove unused interfaces * Add ResourceGroupBuilder tests (#21897) * Change the accessbility to virtual for Resource.Id * Add ResourceGroupBuilder tests * Address comment * Extract the test for Build() to a seperate method Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Update Track 2 Mgmt Plane Template (#21876) * Update Track 2 Mgmt Plane Template * Moving the package ref into the actual project file * Fixing Management tests and updating sln to include missed project * Update build for core.test and invert the mgmt shared test code include. * Fix CI * Add ResourceGroupDeleteOperation tests (#21927) * 5966 sync code coverage fix (#21925) * consolidate test classes * update interceptors to get code coverage on sync methods for LRO responses * Remove ArmResponse since that is no longer needed * update test cases that moved with recordings * remove TA dependency on core sln * put back ai dependency which we should remove * update to cover .net 5 case * consolidate code * remove extension sub classes since they aren't needed (#21945) rename some parameters * Mnash apiview cleanup (#21952) * remove extension sub classes since they aren't needed rename some parameters * update instrumentation for generic resource and tenant * remove Get() from ResourceOperationsBase (#21963) Co-authored-by: Yeming Liu <yeliu@microsoft.com> * update to use zero wait on playback (#22066) * update to use zero wait on playback * update resourcemanager ci to run when shared files change * one more mgmt shared folder * Update sub resource CC to 94%. (#22117) * Add ResourceGroupsRestOperations tests (#21981) * Added support for implicit provider resource type ResourceIdentifier p… (#22142) * Added support for impicit provider resource type ResourceIdentifier parsing * Update clearer list name based on CR comment * Azure.ResourceManager.Core readmes and samples (#21858) * Change the accessbility to virtual for Resource.Id * Readme and sample files * Fixing links * Fixing links * Fixing links * Delete OLD README.md * Migrating to new SDK * samples rename * Update ManagingResourceGroups.md Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Addressing comments in Managing Resource Groups example * Hello World added * Update Sample1_HelloWorld.md * Delete README.md * Create README.md * Addressing HelloWorld comments * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Addressing comments in readme * Commenting relative links * Fix CI Link errors * Fixing CI errors * Snippets IDs deleted * Changing Prerequisites and Auth info * Don't use .Construct in rg example * Migration guides in future PR * Fix CI * Prerequisites * Remove Links comments temporarily * Typo in Readme * Apply suggestions from code review Co-authored-by: m-nash <64171366+m-nash@users.noreply.github.com> * Changing all links to absolute links * Spelling * Commenting not existing links * Fix CI * Typo * Update Sample1_HelloWorld.md * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: m-nash <64171366+m-nash@users.noreply.github.com> * Move Providers and ProviderOperations from Azure.ResourceManager.Resources into Azure.ResourceManager.Core-nibhati-5862 (#21337) * Change the accessbility to virtual for Resource.Id * WIP * WIP * WIP * wip * Update TenantOperations.cs * wip * WIP * wip * wip * wip * wip * fix formatting * wip * Update ProviderContainer.cs * Update ProviderContainer.cs * wip * wip * Update ProviderContainerTests.cs * wip * wip * update to interceptor to handle targetinvocation on a failed task * remove expand parameter from LoadApiVersion methods Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * remove need to copy policies (#22280) * Add ResourceListOperations tests (#22279) * Change the accessbility to virtual for Resource.Id * Add ResourceListOperations tests Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * remove proto (#22282) * Follow up PR - 5593 Azure.ResourceManager.Core Readme (#22262) * Change the accessbility to virtual for Resource.Id * Changing temporary links to absolute ones. Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Add PropertyReferenceType attribute in ResourceIdentity (#22255) * Add PropertyReferenceTypeAttribute attribute in ResourceIdentity * Feedback * remove resources dependency (#22293) * wip * remove remaining references to azure.resourcemanager.resources * update tests to handle new changes * update summary for gets or sets * Updating GenericResource.Lists to return GenericResourceExpanded. (#22284) * Updating GenericResourceList to return GenericResourceExpanded * Added missing expand and related test cases. * Adding missing test recordings. * cleanup the warnings that were supressed (#22318) * fix CA1036 * remove CA1067 * remove CA1065 * remove SA1028 * Exposing expand on ListAtContext as well in preparation to expose that in each of the generated ListAsGeneric methods in autorest (#22351) * Updating GenericResourceList to return GenericResourceExpanded * Added missing expand and related test cases. * Adding missing test recordings. * Exposing expand on ListAtContext as well in preparation to expose that in each of the generated ListAsGeneric methods in autorest * Catch TargetInvocationException in interceptor (#22207) * Change the accessbility to virtual for Resource.Id * Catch TargetInvocationException in interceptor Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Add JsonConverter for ResourceIdentity (#22373) * Add JsonConverter for ResourceIdentity * Feedback * Format file * Update to use common rest api for OperationsList (#22343) * wip changes to add common rest api * update variable name * address pr comments * update recording * Add SubscriptionContainer tests (#22348) * Add SubscriptionsRestOperations tests (#22482) * ADO-5881 Move Azure.ResourceManager.Resources Tags objects to Azure.ResourceManager.Core (#21439) * Initial * Intial part 2 * Update tests * Update Tags * Update operation and container * Update PreDefinedTags * Update ResourceIdentifier.cs * Update at scope Tag * Create TestUpdateAllTags.json * Update ResourceGroupOperations.cs * Update-1 * Update-2 * Update resource type * Update testing coverage * Update to use single * Update tags * Update-2 * Update-3 * Update-4 * Update for rename and move method * Update to use replacewith * Add test coverage * Update for remove LRO methods * Update TaggableResourceTests.cs * minor PR comment fixes * fix tag resource container ctor * update generic resource to use new implementation remove unused test recordings Co-authored-by: m-nash <prognash@gmail.com> * changes to arm core (#22524) * [Bug Fix] Methods in ResourceGroupContainer.cs in Azure.ResourceManager.Core passes in null params (#22551) * [BugFix] Methods in ResourceGroupContainer.cs in Azure.ResourceManager.Core passes in null params * Add ResponseExtensions tests (#22553) * Move feature operations to azure.resourcemanager.core (#22570) * move features operations to core * update xml docs * Remove GetResource() from ResourceOperationsBase (#22571) * Change the accessbility to virtual for Resource.Id * Add SubscriptionContainer tests (#22348) * Remove GetResource() from ResourceOperationsBase * Remove GetResource() in ResourceGroup * Remove GetResource() in Feature Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Updating code snippets in Samples and Readme (#22518) * Change the accessbility to virtual for Resource.Id * Initial setup * Adding Snippets to tests\Samples * Generate snippets in markdown files * Sample 3 code snippets * Update Sample2_ManagingResourceGroups.cs * Update Snippets with generator * Fix Sample2 snippets * Delete Azure - Backup.ResourceManager.Core.Tests.csproj * Ignoring dummy subscription id tests * Adding namespaces to examples * Modify code snippets in main readme * Add ignore tags * Adding Azure.ResourceManager.Core namespace * Update code snippets * Adjust indentation * Removing auto-gen snippets for Sample3 Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * nibhati-5273-merge location (#22483) * Change the accessbility to virtual for Resource.Id * wip * WIP * Update ResourceOperationsBase.cs * wip * wip * wip * wip * wip * update loc based on feedback * update after merge * update to core framework tests * update samples after location changes * update readme based on code changes Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: Nisha Bhatia <nibhati@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * add management object group to core (#22592) * wip * Add mgmt group to core * remove temp files * update to not have nullable but share the same operations between ManagementGroup and ManagementGroupInfo * address PR comments * change location to string to return name instead of display name (#22606) * update location name and corresponding tests * update comments * Make the Parent of ResourceContainerBase to be the OperationsBase type (#22589) * Add WritableSubResource tests (#22618) * Change the accessbility to virtual for Resource.Id * Add SubscriptionContainer tests (#22348) * Change SubResource constructors to protected * Fix a bug in ReferenceType tests * Add WritableSubResource tests * Delete not in use class UpdateResourceGroupOperation * Update unit test * Update reference type tests Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * organize classes - move custom code outside of generated folder - remove duplicate identity (#22626) * organize classes move custom code outside of generated folder remove duplicate identity * remove unused method * Add ListExtensions tests (#22628) * Change the accessbility to virtual for Resource.Id * Add SubscriptionContainer tests (#22348) * Add ListExtensions tests * Add a positive test Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * Add missing sections from the QuickStart to the main Readme (#22634) * Change the accessbility to virtual for Resource.Id * Adding missing sections from workshop quickstart * Adding missing code snippets * Updating code snippets in main readme * Small fixes in comments in code snippets Co-authored-by: YalinLi0312 <yall@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: m-nash <prognash@gmail.com> * remove default location from armclientoptions (#22633) * organize classes move custom code outside of generated folder remove duplicate identity * remove unused method * remove defaut location from armclientoptions * address pr comments * update arm core version * remove unneeded abstract property * make Types public (#22612) Co-authored-by: bquantump <53361486+bquantump@users.noreply.github.com> Co-authored-by: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Co-authored-by: Allen Zhang <allenzhang@live.com> Co-authored-by: Yalin Li <yall@microsoft.com> Co-authored-by: Minghao Chen <30464227+HarveyLink@users.noreply.github.com> Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com> Co-authored-by: m-nash <prognash@microsoft.com> Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com> Co-authored-by: Yeming Liu <Yeming.Liu@microsoft.com> Co-authored-by: Yeming Liu <yeliu@microsoft.com> Co-authored-by: George Arama <50641385+gearama@users.noreply.github.com> Co-authored-by: Arcturus <dapzhang@microsoft.com> Co-authored-by: Feng Zhou <55177366+fengzhou-msft@users.noreply.github.com> Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: ShivangiReja <45216704+ShivangiReja@users.noreply.github.com> Co-authored-by: Nisha Bhatia <nibhati@microsoft.com>
1 parent 555bf4e commit b90e64f

File tree

766 files changed

+1263995
-224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

766 files changed

+1263995
-224
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using Azure.Core;
6+
using Azure.Core.Pipeline;
7+
8+
namespace Azure.ResourceManager.Core
9+
{
10+
/// <summary>
11+
/// helper class
12+
/// </summary>
13+
internal class ClientContext
14+
{
15+
/// <summary>
16+
/// client options
17+
/// </summary>
18+
public ArmClientOptions ClientOptions { get; set; }
19+
20+
/// <summary>
21+
/// credential
22+
/// </summary>
23+
public TokenCredential Credential { get; set; }
24+
25+
/// <summary>
26+
/// baseuri
27+
/// </summary>
28+
public Uri BaseUri { get; set; }
29+
30+
/// <summary>
31+
/// pipeline
32+
/// </summary>
33+
public HttpPipeline Pipeline { get; set; }
34+
35+
/// <summary>
36+
/// Initializes a new instance of the <see cref="ClientContext"/> class.
37+
/// </summary>
38+
/// <param name="clientOptions"></param>
39+
/// <param name="credential"></param>
40+
/// <param name="uri"></param>
41+
/// <param name="pipeline"></param>
42+
internal ClientContext(ArmClientOptions clientOptions, TokenCredential credential, Uri uri, HttpPipeline pipeline)
43+
{
44+
ClientOptions = clientOptions;
45+
Credential = credential;
46+
BaseUri = uri;
47+
Pipeline = pipeline;
48+
}
49+
}
50+
}

common/ManagementTestShared/ManagementRecordedTestBase.cs renamed to common/ManagementTestShared/Current/ManagementRecordedTestBase.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,7 @@ protected ManagementRecordedTestBase(bool isAsync, RecordedTestMode mode) : base
2727

2828
protected ValueTask<Response<T>> WaitForCompletionAsync<T>(Operation<T> operation)
2929
{
30-
if (Mode == RecordedTestMode.Playback)
31-
{
32-
return operation.WaitForCompletionAsync(ZeroPollingInterval, default);
33-
}
34-
else
35-
{
36-
return operation.WaitForCompletionAsync();
37-
}
30+
return operation.WaitForCompletionAsync();
3831
}
3932

4033
protected ResourcesManagementClient GetResourceManagementClient()

common/ManagementTestShared/ResourceGroupCleanupPolicy.cs renamed to common/ManagementTestShared/Current/ResourceGroupCleanupPolicy.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Azure.ResourceManager.TestFramework
1111
{
1212
public class ResourceGroupCleanupPolicy : HttpPipelineSynchronousPolicy
1313
{
14+
private readonly object _listLock = new object();
1415
private Regex _resourceGroupPattern = new Regex(@"/subscriptions/[^/]+/resourcegroups/([^?/]+)\?api-version");
1516
private readonly IList<string> _resourceGroupCreated = new List<string>();
1617

@@ -26,7 +27,10 @@ public override void OnSendingRequest(HttpMessage message)
2627
var match = _resourceGroupPattern.Match(message.Request.Uri.ToString());
2728
if (match.Success)
2829
{
29-
_resourceGroupCreated.Add(match.Groups[1].Value);
30+
lock (_listLock)
31+
{
32+
_resourceGroupCreated.Add(match.Groups[1].Value);
33+
}
3034
}
3135
}
3236
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.IO;
5+
using System.Text;
6+
using System.Text.Json;
7+
using Azure.Core;
8+
using NUnit.Framework;
9+
10+
namespace Azure.ResourceManager.TestFramework
11+
{
12+
internal static class JsonHelper
13+
{
14+
private static readonly JsonWriterOptions PrettyJsonOptions = new JsonWriterOptions() { Indented = true };
15+
private static readonly JsonWriterOptions CompactJsonOptions = new JsonWriterOptions();
16+
17+
/// <summary>
18+
/// This methods serialize the complete resource data to string.
19+
/// </summary>
20+
/// <param name="data"> Resource data that implements <see cref="IUtf8JsonSerializable"/>. </param>
21+
/// <returns> Json string represent the data. </returns>
22+
public static string SerializeToString(IUtf8JsonSerializable data, bool indented = false)
23+
{
24+
var stream = new MemoryStream();
25+
Utf8JsonWriter writer = new(stream, indented ? PrettyJsonOptions : CompactJsonOptions);
26+
writer.WriteObjectValue(data);
27+
writer.Flush();
28+
return Encoding.UTF8.GetString(stream.ToArray());
29+
}
30+
31+
/// <summary>
32+
/// This methods serialize the data properties to string under "properties" tag.
33+
/// Please note if data has top level properties needed that goes outside of "properties",
34+
/// use <see cref="JsonHelper.SerializeToString"/> instead.
35+
/// </summary>
36+
/// <param name="data"> data that implements <see cref="IUtf8JsonSerializable"/>. </param>
37+
/// <returns> Json string represent the data object's properties. </returns>
38+
public static string SerializePropertiesToString(IUtf8JsonSerializable data, bool indented = false)
39+
{
40+
var stream = new MemoryStream();
41+
Utf8JsonWriter writer = new(stream, indented ? PrettyJsonOptions : CompactJsonOptions);
42+
writer.WriteStartObject();
43+
writer.WritePropertyName("properties");
44+
writer.WriteObjectValue(data);
45+
writer.WriteEndObject();
46+
writer.Flush();
47+
return Encoding.UTF8.GetString(stream.ToArray());
48+
}
49+
}
50+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Azure.Core;
5+
using Azure.Core.Pipeline;
6+
using System.Collections.Generic;
7+
using System.Text.RegularExpressions;
8+
9+
namespace Azure.ResourceManager.TestFramework
10+
{
11+
public class ManagementGroupCleanupPolicy : HttpPipelineSynchronousPolicy
12+
{
13+
private readonly object _listLock = new object();
14+
private Regex _mgmtGroupPattern = new Regex(@"(/providers/Microsoft\.Management/managementGroups/[^?/]+)\?api-version");
15+
private readonly IList<string> _mgmtGroupCreated = new List<string>();
16+
17+
public IList<string> ManagementGroupsCreated
18+
{
19+
get { return _mgmtGroupCreated; }
20+
}
21+
22+
public override void OnSendingRequest(HttpMessage message)
23+
{
24+
if (message.Request.Method == RequestMethod.Put)
25+
{
26+
var match = _mgmtGroupPattern.Match(message.Request.Uri.ToString());
27+
if (match.Success)
28+
{
29+
lock (_listLock)
30+
{
31+
_mgmtGroupCreated.Add(match.Groups[1].Value);
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Azure.Core;
5+
using Azure.Core.TestFramework;
6+
using Azure.ResourceManager.Core;
7+
using Castle.DynamicProxy;
8+
using NUnit.Framework;
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using System.Reflection;
13+
using System.Threading.Tasks;
14+
15+
namespace Azure.ResourceManager.TestFramework
16+
{
17+
public abstract class ManagementRecordedTestBase<TEnvironment> : RecordedTestBase<TEnvironment>
18+
where TEnvironment: TestEnvironment, new()
19+
{
20+
protected ResourceGroupCleanupPolicy ResourceGroupCleanupPolicy = new ResourceGroupCleanupPolicy();
21+
22+
protected ResourceGroupCleanupPolicy OneTimeResourceGroupCleanupPolicy = new ResourceGroupCleanupPolicy();
23+
24+
protected ManagementGroupCleanupPolicy ManagementGroupCleanupPolicy = new ManagementGroupCleanupPolicy();
25+
26+
protected ManagementGroupCleanupPolicy OneTimeManagementGroupCleanupPolicy = new ManagementGroupCleanupPolicy();
27+
28+
protected ArmClient GlobalClient { get; private set; }
29+
30+
public TestEnvironment SessionEnvironment { get; private set; }
31+
32+
public TestRecording SessionRecording { get; private set; }
33+
34+
private ArmClient _cleanupClient;
35+
36+
protected ManagementRecordedTestBase(bool isAsync) : base(isAsync)
37+
{
38+
SessionEnvironment = new TEnvironment();
39+
SessionEnvironment.Mode = Mode;
40+
Initialize();
41+
}
42+
43+
protected ManagementRecordedTestBase(bool isAsync, RecordedTestMode mode) : base(isAsync, mode)
44+
{
45+
SessionEnvironment = new TEnvironment();
46+
SessionEnvironment.Mode = Mode;
47+
Initialize();
48+
}
49+
50+
private void Initialize()
51+
{
52+
if (Mode == RecordedTestMode.Playback)
53+
{
54+
var pollField = typeof(OperationInternals).GetField("<DefaultPollingInterval>k__BackingField", BindingFlags.Static | BindingFlags.NonPublic);
55+
pollField.SetValue(null, TimeSpan.Zero);
56+
}
57+
}
58+
59+
private ArmClient GetCleanupClient()
60+
{
61+
if (Mode != RecordedTestMode.Playback)
62+
{
63+
return new ArmClient(
64+
TestEnvironment.SubscriptionId,
65+
TestEnvironment.Credential,
66+
new ArmClientOptions());
67+
}
68+
return null;
69+
}
70+
71+
protected TClient InstrumentClientExtension<TClient>(TClient client) => (TClient)InstrumentClient(typeof(TClient), client, new IInterceptor[] { new ManagementInterceptor(this) });
72+
73+
protected ArmClient GetArmClient(ArmClientOptions clientOptions = default)
74+
{
75+
var options = InstrumentClientOptions(clientOptions ?? new ArmClientOptions());
76+
options.AddPolicy(ResourceGroupCleanupPolicy, HttpPipelinePosition.PerCall);
77+
options.AddPolicy(ManagementGroupCleanupPolicy, HttpPipelinePosition.PerCall);
78+
79+
return CreateClient<ArmClient>(
80+
TestEnvironment.SubscriptionId,
81+
TestEnvironment.Credential,
82+
options);
83+
}
84+
85+
[SetUp]
86+
protected void CreateCleanupClient()
87+
{
88+
_cleanupClient ??= GetCleanupClient();
89+
}
90+
91+
[TearDown]
92+
protected void CleanupResourceGroups()
93+
{
94+
if (Mode != RecordedTestMode.Playback)
95+
{
96+
Parallel.ForEach(ResourceGroupCleanupPolicy.ResourceGroupsCreated, resourceGroup =>
97+
{
98+
try
99+
{
100+
var sub = _cleanupClient.GetSubscriptions().TryGet(TestEnvironment.SubscriptionId);
101+
sub?.GetResourceGroups().Get(resourceGroup).Value.StartDelete();
102+
}
103+
catch (RequestFailedException e) when (e.Status == 404)
104+
{
105+
//we assume the test case cleaned it up if it no longer exists.
106+
}
107+
});
108+
109+
Parallel.ForEach(ManagementGroupCleanupPolicy.ManagementGroupsCreated, mgmtGroupId =>
110+
{
111+
try
112+
{
113+
_cleanupClient.GetManagementGroupOperations(mgmtGroupId).StartDelete();
114+
}
115+
catch (RequestFailedException e) when (e.Status == 404 || e.Status == 403)
116+
{
117+
//we assume the test case cleaned it up if it no longer exists.
118+
}
119+
});
120+
}
121+
}
122+
123+
private void StartSessionRecording()
124+
{
125+
// Only create test recordings for the latest version of the service
126+
TestContext.TestAdapter test = TestContext.CurrentContext.Test;
127+
if (Mode != RecordedTestMode.Live &&
128+
test.Properties.ContainsKey("SkipRecordings"))
129+
{
130+
throw new IgnoreException((string)test.Properties.Get("SkipRecordings"));
131+
}
132+
SessionRecording = new TestRecording(Mode, GetSessionFilePath(), Sanitizer, Matcher);
133+
SessionEnvironment.SetRecording(SessionRecording);
134+
ValidateClientInstrumentation = SessionRecording.HasRequests;
135+
}
136+
137+
protected void StopSessionRecording()
138+
{
139+
if (ValidateClientInstrumentation)
140+
{
141+
throw new InvalidOperationException("The test didn't instrument any clients but had recordings. Please call InstrumentClient for the client being recorded.");
142+
}
143+
144+
SessionRecording?.Dispose(true);
145+
GlobalClient = null;
146+
}
147+
148+
[OneTimeSetUp]
149+
public void OneTimeSetUp()
150+
{
151+
if (!HasOneTimeSetup())
152+
return;
153+
154+
StartSessionRecording();
155+
156+
var options = InstrumentClientOptions(new ArmClientOptions(), SessionRecording);
157+
options.AddPolicy(OneTimeResourceGroupCleanupPolicy, HttpPipelinePosition.PerCall);
158+
options.AddPolicy(OneTimeManagementGroupCleanupPolicy, HttpPipelinePosition.PerCall);
159+
160+
GlobalClient = CreateClient<ArmClient>(
161+
SessionEnvironment.SubscriptionId,
162+
SessionEnvironment.Credential,
163+
options);
164+
}
165+
166+
private bool HasOneTimeSetup()
167+
{
168+
HashSet<Type> types = new HashSet<Type>();
169+
Type type = GetType();
170+
Type endType = typeof(ManagementRecordedTestBase<TEnvironment>);
171+
while (type != endType)
172+
{
173+
types.Add(type);
174+
type = type.BaseType;
175+
}
176+
177+
var methods = GetType().GetMethods().Where(m => types.Contains(m.DeclaringType));
178+
foreach (var method in methods)
179+
{
180+
foreach (var attr in method.GetCustomAttributes(false))
181+
{
182+
if (attr is OneTimeSetUpAttribute)
183+
return true;
184+
}
185+
}
186+
return false;
187+
}
188+
189+
[OneTimeTearDown]
190+
public void OneTimeCleanupResourceGroups()
191+
{
192+
if (Mode != RecordedTestMode.Playback)
193+
{
194+
Parallel.ForEach(OneTimeResourceGroupCleanupPolicy.ResourceGroupsCreated, resourceGroup =>
195+
{
196+
var sub = _cleanupClient.GetSubscriptions().TryGet(SessionEnvironment.SubscriptionId);
197+
sub?.GetResourceGroups().Get(resourceGroup).Value.StartDelete();
198+
});
199+
Parallel.ForEach(OneTimeManagementGroupCleanupPolicy.ManagementGroupsCreated, mgmtGroupId =>
200+
{
201+
_cleanupClient.GetManagementGroupOperations(mgmtGroupId).StartDelete();
202+
});
203+
}
204+
205+
if (!(GlobalClient is null))
206+
throw new InvalidOperationException("StopSessionRecording was never called please make sure you call that at the end of your OneTimeSetup");
207+
}
208+
209+
protected override object InstrumentOperation(Type operationType, object operation)
210+
{
211+
return InstrumentMgmtOperation(operationType, operation, new ManagementInterceptor(this));
212+
}
213+
}
214+
}

0 commit comments

Comments
 (0)