From 8367d3b2e09f6b277ffd628fee1b3e85aa38997e Mon Sep 17 00:00:00 2001 From: Arthur Ma Date: Thu, 11 Jan 2024 17:35:33 +0800 Subject: [PATCH] Add getEntities operation for Azure.ResourceManager (#41106) --- .../Azure.ResourceManager/CHANGELOG.md | 10 +- .../Azure.ResourceManager.netstandard2.0.cs | 137 +++++- .../Sample_ManagementGroupCollection.cs | 30 ++ .../Samples/Sample_TenantCollection.cs | 22 + .../src/Azure.ResourceManager.csproj | 2 +- .../Custom/ResourceManagerModelFactory.cs | 2 +- .../Generated/ManagementGroupCollection.cs | 80 +++- .../Generated/ManagementGroupResource.cs | 16 +- .../Models/EntityData.Serialization.cs | 418 ++++++++++++++++++ .../Generated/Models/EntityData.cs | 116 +++++ .../Models/EntityListResult.Serialization.cs | 162 +++++++ .../Generated/Models/EntityListResult.cs | 75 ++++ .../Models/EntityPermission.Serialization.cs | 32 ++ .../Generated/Models/EntityPermission.cs | 22 + .../Generated/Models/EntitySearchOption.cs | 60 +++ .../Generated/Models/EntityViewOption.cs | 57 +++ ...gementGroupCollectionGetEntitiesOptions.cs | 48 ++ .../Generated/ResourceManagerModelFactory.cs | 24 + .../RestOperations/EntitiesRestOperations.cs | 289 ++++++++++++ .../ManagementGroupsRestOperations.cs | 64 +-- ...urceNameValidationContent.Serialization.cs | 127 ++++++ .../Models/ResourceNameValidationContent.cs | 82 ++++ ...ourceNameValidationResult.Serialization.cs | 152 +++++++ .../Models/ResourceNameValidationResult.cs | 74 ++++ .../Models/ResourceNameValidationStatus.cs | 51 +++ .../Generated/ResourceGroupResource.cs | 116 ++--- .../Generated/ResourceManagerModelFactory.cs | 10 + .../ResourceGroupsRestOperations.cs | 146 ------ .../ResourceManagementRestOperations.cs | 104 +++++ .../RestOperations/ResourcesRestOperations.cs | 146 ++++++ .../Resources/Generated/TenantCollection.cs | 75 ++++ .../Azure.ResourceManager/src/autorest.md | 58 +-- ...iterImplementationValidation.Exceptions.cs | 4 +- .../ManagementGroupCollectionTests.cs | 13 + .../tests/Scenario/TenantCollectionTests.cs | 10 +- .../tests/Unit/GenericResourceDataTests.cs | 2 +- 36 files changed, 2541 insertions(+), 295 deletions(-) create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.Serialization.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntitySearchOption.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityViewOption.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCollectionGetEntitiesOptions.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/EntitiesRestOperations.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.Serialization.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationStatus.cs create mode 100644 sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs diff --git a/sdk/resourcemanager/Azure.ResourceManager/CHANGELOG.md b/sdk/resourcemanager/Azure.ResourceManager/CHANGELOG.md index 486c009d93f3f..e5b355845c708 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/CHANGELOG.md +++ b/sdk/resourcemanager/Azure.ResourceManager/CHANGELOG.md @@ -1,14 +1,12 @@ # Release History -## 1.10.0-beta.1 (Unreleased) +## 1.10.0 (2024-01-12) ### Features Added -### Breaking Changes - -### Bugs Fixed - -### Other Changes +- Add `GetEntities` operation. +- Add `CheckResourceName` operation. +- Enable the new model serialization by using the System.ClientModel, refer this [document](https://aka.ms/azsdk/net/mrw) for more details. ## 1.9.0 (2023-11-14) diff --git a/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs b/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs index e9b5aa9716d36..99f6fe1efb1ba 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/api/Azure.ResourceManager.netstandard2.0.cs @@ -134,9 +134,11 @@ protected ManagementGroupCollection() { } public virtual Azure.Response Exists(string groupId, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ExistsAsync(string groupId, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(string groupId, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Pageable GetAll(string cacheControl = null, string skiptoken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AsyncPageable GetAllAsync(string cacheControl = null, string skiptoken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(string cacheControl = null, string skipToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(string cacheControl = null, string skipToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(string groupId, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetEntities(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupCollectionGetEntitiesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetEntitiesAsync(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupCollectionGetEntitiesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.NullableResponse GetIfExists(string groupId, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string groupId, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } @@ -167,8 +169,8 @@ protected ManagementGroupResource() { } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType? expand = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupExpandType?), bool? recurse = default(bool?), string filter = null, string cacheControl = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Pageable GetDescendants(string skiptoken = null, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AsyncPageable GetDescendantsAsync(string skiptoken = null, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetDescendants(string skipToken = null, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetDescendantsAsync(string skipToken = null, int? top = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response GetManagementGroupPolicyDefinition(string policyDefinitionName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetManagementGroupPolicyDefinitionAsync(string policyDefinitionName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.Resources.ManagementGroupPolicyDefinitionCollection GetManagementGroupPolicyDefinitions() { throw null; } @@ -205,6 +207,73 @@ internal DescendantData() { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class EntityData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal EntityData() { } + public string DisplayName { get { throw null; } } + public Azure.ResourceManager.ManagementGroups.Models.EntityPermission? InheritedPermissions { get { throw null; } } + public int? NumberOfChildGroups { get { throw null; } } + public int? NumberOfChildren { get { throw null; } } + public int? NumberOfDescendants { get { throw null; } } + public System.Collections.Generic.IReadOnlyList ParentDisplayNameChain { get { throw null; } } + public Azure.Core.ResourceIdentifier ParentId { get { throw null; } } + public System.Collections.Generic.IReadOnlyList ParentNameChain { get { throw null; } } + public Azure.ResourceManager.ManagementGroups.Models.EntityPermission? Permissions { get { throw null; } } + public System.Guid? TenantId { get { throw null; } } + Azure.ResourceManager.ManagementGroups.Models.EntityData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ManagementGroups.Models.EntityData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public enum EntityPermission + { + NoAccess = 0, + View = 1, + Edit = 2, + Delete = 3, + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EntitySearchOption : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EntitySearchOption(string value) { throw null; } + public static Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption AllowedChildren { get { throw null; } } + public static Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption AllowedParents { get { throw null; } } + public static Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption ChildrenOnly { get { throw null; } } + public static Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption ParentAndFirstLevelChildren { get { throw null; } } + public static Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption ParentOnly { get { throw null; } } + public bool Equals(Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption left, Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption right) { throw null; } + public static implicit operator Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption left, Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EntityViewOption : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EntityViewOption(string value) { throw null; } + public static Azure.ResourceManager.ManagementGroups.Models.EntityViewOption Audit { get { throw null; } } + public static Azure.ResourceManager.ManagementGroups.Models.EntityViewOption FullHierarchy { get { throw null; } } + public static Azure.ResourceManager.ManagementGroups.Models.EntityViewOption GroupsOnly { get { throw null; } } + public static Azure.ResourceManager.ManagementGroups.Models.EntityViewOption SubscriptionsOnly { get { throw null; } } + public bool Equals(Azure.ResourceManager.ManagementGroups.Models.EntityViewOption other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ManagementGroups.Models.EntityViewOption left, Azure.ResourceManager.ManagementGroups.Models.EntityViewOption right) { throw null; } + public static implicit operator Azure.ResourceManager.ManagementGroups.Models.EntityViewOption (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ManagementGroups.Models.EntityViewOption left, Azure.ResourceManager.ManagementGroups.Models.EntityViewOption right) { throw null; } + public override string ToString() { throw null; } + } public partial class ManagementGroupChildInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal ManagementGroupChildInfo() { } @@ -251,6 +320,19 @@ internal ManagementGroupChildOptions() { } public static bool operator !=(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType left, Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType right) { throw null; } public override string ToString() { throw null; } } + public partial class ManagementGroupCollectionGetEntitiesOptions + { + public ManagementGroupCollectionGetEntitiesOptions() { } + public string CacheControl { get { throw null; } set { } } + public string Filter { get { throw null; } set { } } + public string GroupName { get { throw null; } set { } } + public Azure.ResourceManager.ManagementGroups.Models.EntitySearchOption? Search { get { throw null; } set { } } + public string Select { get { throw null; } set { } } + public int? Skip { get { throw null; } set { } } + public string SkipToken { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + public Azure.ResourceManager.ManagementGroups.Models.EntityViewOption? View { get { throw null; } set { } } + } public partial class ManagementGroupCreateOrUpdateContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ManagementGroupCreateOrUpdateContent() { } @@ -564,13 +646,14 @@ public static partial class ResourceManagerModelFactory public static Azure.ResourceManager.Resources.DataPolicyManifestData DataPolicyManifestData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IEnumerable namespaces = null, string policyMode = null, bool? isBuiltInOnly = default(bool?), System.Collections.Generic.IEnumerable resourceTypeAliases = null, System.Collections.Generic.IEnumerable effects = null, System.Collections.Generic.IEnumerable fieldValues = null, System.Collections.Generic.IEnumerable standard = null, System.Collections.Generic.IEnumerable customDefinitions = null) { throw null; } public static Azure.ResourceManager.Resources.Models.DataPolicyManifestEffect DataPolicyManifestEffect(string name = null, System.BinaryData detailsSchema = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.DescendantData DescendantData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string displayName = null, Azure.Core.ResourceIdentifier parentId = null) { throw null; } + public static Azure.ResourceManager.ManagementGroups.Models.EntityData EntityData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Guid? tenantId = default(System.Guid?), string displayName = null, Azure.Core.ResourceIdentifier parentId = null, Azure.ResourceManager.ManagementGroups.Models.EntityPermission? permissions = default(Azure.ResourceManager.ManagementGroups.Models.EntityPermission?), Azure.ResourceManager.ManagementGroups.Models.EntityPermission? inheritedPermissions = default(Azure.ResourceManager.ManagementGroups.Models.EntityPermission?), int? numberOfDescendants = default(int?), int? numberOfChildren = default(int?), int? numberOfChildGroups = default(int?), System.Collections.Generic.IEnumerable parentDisplayNameChain = null, System.Collections.Generic.IEnumerable parentNameChain = null) { throw null; } public static Azure.ResourceManager.Resources.FeatureData FeatureData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string featureState = null) { throw null; } public static Azure.ResourceManager.Resources.GenericResourceData GenericResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.Resources.Models.ExtendedLocation extendedLocation = null, Azure.ResourceManager.Models.ArmPlan plan = null, System.BinaryData properties = null, string kind = null, string managedBy = null, Azure.ResourceManager.Resources.Models.ResourcesSku sku = null, Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, System.DateTimeOffset? createdOn = default(System.DateTimeOffset?), System.DateTimeOffset? changedOn = default(System.DateTimeOffset?), string provisioningState = null) { throw null; } public static Azure.ResourceManager.Resources.Models.LocationExpanded LocationExpanded(string id, string subscriptionId, string name, Azure.ResourceManager.Resources.Models.LocationType? locationType, string displayName, string regionalDisplayName, Azure.ResourceManager.Resources.Models.LocationMetadata metadata) { throw null; } public static Azure.ResourceManager.Resources.Models.LocationExpanded LocationExpanded(string id = null, string subscriptionId = null, string name = null, Azure.ResourceManager.Resources.Models.LocationType? locationType = default(Azure.ResourceManager.Resources.Models.LocationType?), string displayName = null, string regionalDisplayName = null, Azure.ResourceManager.Resources.Models.LocationMetadata metadata = null, System.Collections.Generic.IEnumerable availabilityZoneMappings = null) { throw null; } public static Azure.ResourceManager.Resources.Models.LocationMetadata LocationMetadata(Azure.ResourceManager.Resources.Models.RegionType? regionType = default(Azure.ResourceManager.Resources.Models.RegionType?), Azure.ResourceManager.Resources.Models.RegionCategory? regionCategory = default(Azure.ResourceManager.Resources.Models.RegionCategory?), string geography = null, string geographyGroup = null, double? longitude = default(double?), double? latitude = default(double?), string physicalLocation = null, System.Collections.Generic.IEnumerable pairedRegions = null, string homeLocation = null) { throw null; } public static Azure.ResourceManager.Resources.Models.ManagedByTenant ManagedByTenant(System.Guid? tenantId = default(System.Guid?)) { throw null; } - public static Azure.ResourceManager.Models.ManagedServiceIdentity ManagedServiceIdentity(System.Guid? principalId, System.Guid? tenantId, Azure.ResourceManager.Models.ManagedServiceIdentityType managedServiceIdentityType, System.Collections.Generic.IDictionary userAssignedIdentities) { throw null; } + public static Azure.ResourceManager.Models.ManagedServiceIdentity ManagedServiceIdentity(System.Guid? principalId = default(System.Guid?), System.Guid? tenantId = default(System.Guid?), Azure.ResourceManager.Models.ManagedServiceIdentityType managedServiceIdentityType = default(Azure.ResourceManager.Models.ManagedServiceIdentityType), System.Collections.Generic.IDictionary userAssignedIdentities = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildInfo ManagementGroupChildInfo(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType? childType = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType?), string id = null, string name = null, string displayName = null, System.Collections.Generic.IEnumerable children = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildOptions ManagementGroupChildOptions(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType? childType = default(Azure.ResourceManager.ManagementGroups.Models.ManagementGroupChildType?), string id = null, string name = null, string displayName = null, System.Collections.Generic.IEnumerable children = null) { throw null; } public static Azure.ResourceManager.ManagementGroups.Models.ManagementGroupCreateOrUpdateContent ManagementGroupCreateOrUpdateContent(string id = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), string name = null, System.Guid? tenantId = default(System.Guid?), string displayName = null, Azure.ResourceManager.ManagementGroups.Models.CreateManagementGroupDetails details = null, System.Collections.Generic.IEnumerable children = null) { throw null; } @@ -594,6 +677,7 @@ public static partial class ResourceManagerModelFactory public static Azure.ResourceManager.Resources.Models.ProviderResourceType ProviderResourceType(string resourceType = null, System.Collections.Generic.IEnumerable locations = null, System.Collections.Generic.IEnumerable locationMappings = null, System.Collections.Generic.IEnumerable aliases = null, System.Collections.Generic.IEnumerable apiVersions = null, string defaultApiVersion = null, System.Collections.Generic.IEnumerable zoneMappings = null, System.Collections.Generic.IEnumerable apiProfiles = null, string capabilities = null, System.Collections.Generic.IReadOnlyDictionary properties = null) { throw null; } public static Azure.ResourceManager.Resources.ResourceGroupData ResourceGroupData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), string resourceGroupProvisioningState = null, string managedBy = null) { throw null; } public static Azure.ResourceManager.Resources.Models.ResourceGroupExportResult ResourceGroupExportResult(System.BinaryData template = null, Azure.ResponseError error = null) { throw null; } + public static Azure.ResourceManager.Resources.Models.ResourceNameValidationResult ResourceNameValidationResult(string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus? status = default(Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus?)) { throw null; } public static Azure.ResourceManager.Resources.ResourceProviderData ResourceProviderData(Azure.Core.ResourceIdentifier id = null, string @namespace = null, string registrationState = null, string registrationPolicy = null, System.Collections.Generic.IEnumerable resourceTypes = null, Azure.ResourceManager.Resources.Models.ProviderAuthorizationConsentState? providerAuthorizationConsentState = default(Azure.ResourceManager.Resources.Models.ProviderAuthorizationConsentState?)) { throw null; } public static Azure.ResourceManager.Resources.Models.ResourceTypeAlias ResourceTypeAlias(string name = null, System.Collections.Generic.IEnumerable paths = null, Azure.ResourceManager.Resources.Models.ResourceTypeAliasType? aliasType = default(Azure.ResourceManager.Resources.Models.ResourceTypeAliasType?), string defaultPath = null, Azure.ResourceManager.Resources.Models.ResourceTypeAliasPattern defaultPattern = null, Azure.ResourceManager.Resources.Models.ResourceTypeAliasPathMetadata defaultMetadata = null) { throw null; } public static Azure.ResourceManager.Resources.Models.ResourceTypeAliases ResourceTypeAliases(string resourceType = null, System.Collections.Generic.IEnumerable aliases = null) { throw null; } @@ -1294,6 +1378,8 @@ public TagResourceData(Azure.ResourceManager.Resources.Models.Tag properties) { public partial class TenantCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected TenantCollection() { } + public virtual Azure.Response CheckResourceName(Azure.ResourceManager.Resources.Models.ResourceNameValidationContent content = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CheckResourceNameAsync(Azure.ResourceManager.Resources.Models.ResourceNameValidationContent content = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } @@ -1977,6 +2063,47 @@ public ResourceGroupPatch() { } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class ResourceNameValidationContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ResourceNameValidationContent(string name, Azure.Core.ResourceType resourceType) { } + public string Name { get { throw null; } } + public Azure.Core.ResourceType ResourceType { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceNameValidationContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.Resources.Models.ResourceNameValidationContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ResourceNameValidationResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ResourceNameValidationResult() { } + public string Name { get { throw null; } } + public Azure.Core.ResourceType? ResourceType { get { throw null; } } + public Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus? Status { get { throw null; } } + Azure.ResourceManager.Resources.Models.ResourceNameValidationResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.Resources.Models.ResourceNameValidationResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ResourceNameValidationStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ResourceNameValidationStatus(string value) { throw null; } + public static Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus Allowed { get { throw null; } } + public static Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus Reserved { get { throw null; } } + public bool Equals(Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus left, Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus left, Azure.ResourceManager.Resources.Models.ResourceNameValidationStatus right) { throw null; } + public override string ToString() { throw null; } + } public partial class ResourceSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ResourceSelector() { } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs index 7ae0ce410fbce..4bd374179bf00 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs @@ -642,5 +642,35 @@ public async Task CheckNameAvailability_CheckManagementGroupNameAvailability() Console.WriteLine($"Succeeded: {result}"); } + + // GetEntities + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetEntities_GetEntities() + { + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetEntities.json + // this example is just showing the usage of "Entities_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TenantResource created on azure + // for more information of creating TenantResource, please refer to the document of TenantResource + var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this ManagementGroupResource + ManagementGroupCollection collection = tenantResource.GetManagementGroups(); + + // invoke the operation and iterate over the result + ManagementGroupCollectionGetEntitiesOptions options = new ManagementGroupCollectionGetEntitiesOptions() { }; + await foreach (EntityData item in collection.GetEntitiesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantCollection.cs index 04746f0d6cec3..4a390527adcbc 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantCollection.cs @@ -11,6 +11,7 @@ using Azure.Identity; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.Resources.Samples { @@ -43,5 +44,26 @@ public async Task GetAll_GetAllTenants() Console.WriteLine($"Succeeded"); } + + // CheckValidityForAResourceName + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CheckResourceName_CheckValidityForAResourceName() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/CheckResourceName.json + // this example is just showing the usage of "checkResourceName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantCollection collection = client.GetTenants(); + + // invoke the operation + ResourceNameValidationResult result = await collection.CheckResourceNameAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Azure.ResourceManager.csproj b/sdk/resourcemanager/Azure.ResourceManager/src/Azure.ResourceManager.csproj index a588d71e48c1a..a8755b0ba3c31 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Azure.ResourceManager.csproj +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Azure.ResourceManager.csproj @@ -1,7 +1,7 @@ - 1.10.0-beta.1 + 1.10.0 1.9.0 Azure.ResourceManager diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/ResourceManagerModelFactory.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/ResourceManagerModelFactory.cs index e01c46178c061..c5d2b264691e0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/ResourceManagerModelFactory.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/ResourceManagerModelFactory.cs @@ -17,7 +17,7 @@ public static partial class ResourceManagerModelFactory /// Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). /// The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. /// A new instance for mocking. - public static ManagedServiceIdentity ManagedServiceIdentity(Guid? principalId, Guid? tenantId, ManagedServiceIdentityType managedServiceIdentityType, IDictionary userAssignedIdentities) + public static ManagedServiceIdentity ManagedServiceIdentity(Guid? principalId = null, Guid? tenantId = null, ManagedServiceIdentityType managedServiceIdentityType = default, IDictionary userAssignedIdentities = null) { return new ManagedServiceIdentity(principalId, tenantId, managedServiceIdentityType, userAssignedIdentities); } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupCollection.cs index 74ea6e8e6cfa9..aef5456898883 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupCollection.cs @@ -30,6 +30,8 @@ public partial class ManagementGroupCollection : ArmCollection, IEnumerable Initializes a new instance of the class for mocking. protected ManagementGroupCollection() @@ -44,6 +46,8 @@ internal ManagementGroupCollection(ArmClient client, ResourceIdentifier id) : ba _managementGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ManagementGroups", ManagementGroupResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(ManagementGroupResource.ResourceType, out string managementGroupApiVersion); _managementGroupRestClient = new ManagementGroupsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managementGroupApiVersion); + _entitiesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ManagementGroups", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _entitiesRestClient = new EntitiesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); #if DEBUG ValidateResourceId(Id); #endif @@ -282,17 +286,17 @@ public virtual Response Get(string groupId, ManagementG /// /// /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// /// /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(string cacheControl = null, string skiptoken = null, CancellationToken cancellationToken = default) + public virtual AsyncPageable GetAllAsync(string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateListRequest(cacheControl, skiptoken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateListNextPageRequest(nextLink, cacheControl, skiptoken); + HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateListRequest(cacheControl, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateListNextPageRequest(nextLink, cacheControl, skipToken); return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagementGroupResource(Client, ManagementGroupData.DeserializeManagementGroupData(e)), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupCollection.GetAll", "value", "@nextLink", cancellationToken); } @@ -319,17 +323,17 @@ public virtual AsyncPageable GetAllAsync(string cacheCo /// /// /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// /// /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(string cacheControl = null, string skiptoken = null, CancellationToken cancellationToken = default) + public virtual Pageable GetAll(string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateListRequest(cacheControl, skiptoken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateListNextPageRequest(nextLink, cacheControl, skiptoken); + HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateListRequest(cacheControl, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateListNextPageRequest(nextLink, cacheControl, skipToken); return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagementGroupResource(Client, ManagementGroupData.DeserializeManagementGroupData(e)), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupCollection.GetAll", "value", "@nextLink", cancellationToken); } @@ -417,6 +421,66 @@ public virtual Response CheckNameAvailabi } } + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. + /// + /// + /// + /// Request Path + /// /providers/Microsoft.Management/getEntities + /// + /// + /// Operation Id + /// Entities_List + /// + /// + /// Default Api Version + /// 2021-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetEntitiesAsync(ManagementGroupCollectionGetEntitiesOptions options, CancellationToken cancellationToken = default) + { + options ??= new ManagementGroupCollectionGetEntitiesOptions(); + + HttpMessage FirstPageRequest(int? pageSizeHint) => _entitiesRestClient.CreateListRequest(options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _entitiesRestClient.CreateListNextPageRequest(nextLink, options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => EntityData.DeserializeEntityData(e), _entitiesClientDiagnostics, Pipeline, "ManagementGroupCollection.GetEntities", "value", "nextLink", cancellationToken); + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. + /// + /// + /// + /// Request Path + /// /providers/Microsoft.Management/getEntities + /// + /// + /// Operation Id + /// Entities_List + /// + /// + /// Default Api Version + /// 2021-04-01 + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetEntities(ManagementGroupCollectionGetEntitiesOptions options, CancellationToken cancellationToken = default) + { + options ??= new ManagementGroupCollectionGetEntitiesOptions(); + + HttpMessage FirstPageRequest(int? pageSizeHint) => _entitiesRestClient.CreateListRequest(options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _entitiesRestClient.CreateListNextPageRequest(nextLink, options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => EntityData.DeserializeEntityData(e), _entitiesClientDiagnostics, Pipeline, "ManagementGroupCollection.GetEntities", "value", "nextLink", cancellationToken); + } + /// /// Checks to see if the resource exists in azure. /// diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs index a73c63db6d64b..f6412007c6d1e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ManagementGroupResource.cs @@ -380,7 +380,7 @@ public virtual Response Update(ManagementGroupPatch pat /// /// /// - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// @@ -388,10 +388,10 @@ public virtual Response Update(ManagementGroupPatch pat /// Number of elements to return when retrieving results. Passing this in will override $skipToken. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetDescendantsAsync(string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + public virtual AsyncPageable GetDescendantsAsync(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateGetDescendantsRequest(Id.Name, skiptoken, top); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateGetDescendantsNextPageRequest(nextLink, Id.Name, skiptoken, top); + HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateGetDescendantsRequest(Id.Name, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateGetDescendantsNextPageRequest(nextLink, Id.Name, skipToken, top); return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => DescendantData.DeserializeDescendantData(e), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupResource.GetDescendants", "value", "nextLink", cancellationToken); } @@ -417,7 +417,7 @@ public virtual AsyncPageable GetDescendantsAsync(string skiptoke /// /// /// - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// @@ -425,10 +425,10 @@ public virtual AsyncPageable GetDescendantsAsync(string skiptoke /// Number of elements to return when retrieving results. Passing this in will override $skipToken. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetDescendants(string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + public virtual Pageable GetDescendants(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateGetDescendantsRequest(Id.Name, skiptoken, top); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateGetDescendantsNextPageRequest(nextLink, Id.Name, skiptoken, top); + HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateGetDescendantsRequest(Id.Name, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateGetDescendantsNextPageRequest(nextLink, Id.Name, skipToken, top); return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => DescendantData.DeserializeDescendantData(e), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupResource.GetDescendants", "value", "nextLink", cancellationToken); } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs new file mode 100644 index 0000000000000..4db165274d73a --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.Serialization.cs @@ -0,0 +1,418 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + public partial class EntityData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityData)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(TenantId)) + { + if (TenantId != null) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } + else + { + writer.WriteNull("tenantId"); + } + } + if (Optional.IsDefined(DisplayName)) + { + if (DisplayName != null) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + else + { + writer.WriteNull("displayName"); + } + } + if (Optional.IsDefined(Parent)) + { + writer.WritePropertyName("parent"u8); + JsonSerializer.Serialize(writer, Parent); + } + if (Optional.IsDefined(Permissions)) + { + if (Permissions != null) + { + writer.WritePropertyName("permissions"u8); + writer.WriteStringValue(Permissions.Value.ToSerialString()); + } + else + { + writer.WriteNull("permissions"); + } + } + if (Optional.IsDefined(InheritedPermissions)) + { + if (InheritedPermissions != null) + { + writer.WritePropertyName("inheritedPermissions"u8); + writer.WriteStringValue(InheritedPermissions.Value.ToSerialString()); + } + else + { + writer.WriteNull("inheritedPermissions"); + } + } + if (Optional.IsDefined(NumberOfDescendants)) + { + if (NumberOfDescendants != null) + { + writer.WritePropertyName("numberOfDescendants"u8); + writer.WriteNumberValue(NumberOfDescendants.Value); + } + else + { + writer.WriteNull("numberOfDescendants"); + } + } + if (Optional.IsDefined(NumberOfChildren)) + { + if (NumberOfChildren != null) + { + writer.WritePropertyName("numberOfChildren"u8); + writer.WriteNumberValue(NumberOfChildren.Value); + } + else + { + writer.WriteNull("numberOfChildren"); + } + } + if (Optional.IsDefined(NumberOfChildGroups)) + { + if (NumberOfChildGroups != null) + { + writer.WritePropertyName("numberOfChildGroups"u8); + writer.WriteNumberValue(NumberOfChildGroups.Value); + } + else + { + writer.WriteNull("numberOfChildGroups"); + } + } + if (Optional.IsCollectionDefined(ParentDisplayNameChain)) + { + if (ParentDisplayNameChain != null) + { + writer.WritePropertyName("parentDisplayNameChain"u8); + writer.WriteStartArray(); + foreach (var item in ParentDisplayNameChain) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("parentDisplayNameChain"); + } + } + if (Optional.IsCollectionDefined(ParentNameChain)) + { + if (ParentNameChain != null) + { + writer.WritePropertyName("parentNameChain"u8); + writer.WriteStartArray(); + foreach (var item in ParentNameChain) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("parentNameChain"); + } + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + EntityData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityData)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEntityData(document.RootElement, options); + } + + internal static EntityData DeserializeEntityData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional tenantId = default; + Optional displayName = default; + Optional parent = default; + Optional permissions = default; + Optional inheritedPermissions = default; + Optional numberOfDescendants = default; + Optional numberOfChildren = default; + Optional numberOfChildGroups = default; + Optional> parentDisplayNameChain = default; + Optional> parentNameChain = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("tenantId"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + tenantId = null; + continue; + } + tenantId = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("displayName"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + displayName = null; + continue; + } + displayName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("parent"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parent = JsonSerializer.Deserialize(property0.Value.GetRawText()); + continue; + } + if (property0.NameEquals("permissions"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + permissions = null; + continue; + } + permissions = property0.Value.GetString().ToEntityPermission(); + continue; + } + if (property0.NameEquals("inheritedPermissions"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + inheritedPermissions = null; + continue; + } + inheritedPermissions = property0.Value.GetString().ToEntityPermission(); + continue; + } + if (property0.NameEquals("numberOfDescendants"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + numberOfDescendants = null; + continue; + } + numberOfDescendants = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("numberOfChildren"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + numberOfChildren = null; + continue; + } + numberOfChildren = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("numberOfChildGroups"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + numberOfChildGroups = null; + continue; + } + numberOfChildGroups = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("parentDisplayNameChain"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + parentDisplayNameChain = null; + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + parentDisplayNameChain = array; + continue; + } + if (property0.NameEquals("parentNameChain"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + parentNameChain = null; + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + parentNameChain = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new EntityData(id, name, type, systemData.Value, Optional.ToNullable(tenantId), displayName.Value, parent, Optional.ToNullable(permissions), Optional.ToNullable(inheritedPermissions), Optional.ToNullable(numberOfDescendants), Optional.ToNullable(numberOfChildren), Optional.ToNullable(numberOfChildGroups), Optional.ToList(parentDisplayNameChain), Optional.ToList(parentNameChain), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EntityData)} does not support '{options.Format}' format."); + } + } + + EntityData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEntityData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EntityData)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.cs new file mode 100644 index 0000000000000..f60db3650a438 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityData.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + /// The entity. + public partial class EntityData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal EntityData() + { + ParentDisplayNameChain = new ChangeTrackingList(); + ParentNameChain = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000. + /// The friendly name of the management group. + /// (Optional) The ID of the parent management group. + /// The users specific permissions to this item. + /// The users specific permissions to this item. + /// Number of Descendants. + /// Number of children is the number of Groups and Subscriptions that are exactly one level underneath the current Group. + /// Number of children is the number of Groups that are exactly one level underneath the current Group. + /// The parent display name chain from the root group to the immediate parent. + /// The parent name chain from the root group to the immediate parent. + /// Keeps track of any properties unknown to the library. + internal EntityData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, Guid? tenantId, string displayName, SubResource parent, EntityPermission? permissions, EntityPermission? inheritedPermissions, int? numberOfDescendants, int? numberOfChildren, int? numberOfChildGroups, IReadOnlyList parentDisplayNameChain, IReadOnlyList parentNameChain, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + TenantId = tenantId; + DisplayName = displayName; + Parent = parent; + Permissions = permissions; + InheritedPermissions = inheritedPermissions; + NumberOfDescendants = numberOfDescendants; + NumberOfChildren = numberOfChildren; + NumberOfChildGroups = numberOfChildGroups; + ParentDisplayNameChain = parentDisplayNameChain; + ParentNameChain = parentNameChain; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000. + public Guid? TenantId { get; } + /// The friendly name of the management group. + public string DisplayName { get; } + /// (Optional) The ID of the parent management group. + internal SubResource Parent { get; } + /// Gets Id. + public ResourceIdentifier ParentId + { + get => Parent?.Id; + } + + /// The users specific permissions to this item. + public EntityPermission? Permissions { get; } + /// The users specific permissions to this item. + public EntityPermission? InheritedPermissions { get; } + /// Number of Descendants. + public int? NumberOfDescendants { get; } + /// Number of children is the number of Groups and Subscriptions that are exactly one level underneath the current Group. + public int? NumberOfChildren { get; } + /// Number of children is the number of Groups that are exactly one level underneath the current Group. + public int? NumberOfChildGroups { get; } + /// The parent display name chain from the root group to the immediate parent. + public IReadOnlyList ParentDisplayNameChain { get; } + /// The parent name chain from the root group to the immediate parent. + public IReadOnlyList ParentNameChain { get; } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs new file mode 100644 index 0000000000000..aaa9275c68752 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.Serialization.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + internal partial class EntityListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityListResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + EntityListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EntityListResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEntityListResult(document.RootElement, options); + } + + internal static EntityListResult DeserializeEntityListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> value = default; + Optional count = default; + Optional nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(EntityData.DeserializeEntityData(item)); + } + value = array; + continue; + } + if (property.NameEquals("count"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new EntityListResult(Optional.ToList(value), Optional.ToNullable(count), nextLink.Value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EntityListResult)} does not support '{options.Format}' format."); + } + } + + EntityListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEntityListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EntityListResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.cs new file mode 100644 index 0000000000000..628b677bb4b20 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityListResult.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + /// Describes the result of the request to view entities. + internal partial class EntityListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal EntityListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The list of entities. + /// Total count of records that match the filter. + /// The URL to use for getting the next set of results. + /// Keeps track of any properties unknown to the library. + internal EntityListResult(IReadOnlyList value, int? count, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + Count = count; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The list of entities. + public IReadOnlyList Value { get; } + /// Total count of records that match the filter. + public int? Count { get; } + /// The URL to use for getting the next set of results. + public string NextLink { get; } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.Serialization.cs new file mode 100644 index 0000000000000..a83caa1d9101d --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.Serialization.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + internal static partial class EntityPermissionExtensions + { + public static string ToSerialString(this EntityPermission value) => value switch + { + EntityPermission.NoAccess => "noaccess", + EntityPermission.View => "view", + EntityPermission.Edit => "edit", + EntityPermission.Delete => "delete", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EntityPermission value.") + }; + + public static EntityPermission ToEntityPermission(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "noaccess")) return EntityPermission.NoAccess; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "view")) return EntityPermission.View; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "edit")) return EntityPermission.Edit; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "delete")) return EntityPermission.Delete; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown EntityPermission value."); + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.cs new file mode 100644 index 0000000000000..c7a2a6c4cbe8d --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityPermission.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + /// The users specific permissions to this item. + public enum EntityPermission + { + /// noaccess. + NoAccess, + /// view. + View, + /// edit. + Edit, + /// delete. + Delete + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntitySearchOption.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntitySearchOption.cs new file mode 100644 index 0000000000000..0e53f0ef5a296 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntitySearchOption.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + /// The EntitySearchOption. + public readonly partial struct EntitySearchOption : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EntitySearchOption(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AllowedParentsValue = "AllowedParents"; + private const string AllowedChildrenValue = "AllowedChildren"; + private const string ParentAndFirstLevelChildrenValue = "ParentAndFirstLevelChildren"; + private const string ParentOnlyValue = "ParentOnly"; + private const string ChildrenOnlyValue = "ChildrenOnly"; + + /// AllowedParents. + public static EntitySearchOption AllowedParents { get; } = new EntitySearchOption(AllowedParentsValue); + /// AllowedChildren. + public static EntitySearchOption AllowedChildren { get; } = new EntitySearchOption(AllowedChildrenValue); + /// ParentAndFirstLevelChildren. + public static EntitySearchOption ParentAndFirstLevelChildren { get; } = new EntitySearchOption(ParentAndFirstLevelChildrenValue); + /// ParentOnly. + public static EntitySearchOption ParentOnly { get; } = new EntitySearchOption(ParentOnlyValue); + /// ChildrenOnly. + public static EntitySearchOption ChildrenOnly { get; } = new EntitySearchOption(ChildrenOnlyValue); + /// Determines if two values are the same. + public static bool operator ==(EntitySearchOption left, EntitySearchOption right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EntitySearchOption left, EntitySearchOption right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator EntitySearchOption(string value) => new EntitySearchOption(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EntitySearchOption other && Equals(other); + /// + public bool Equals(EntitySearchOption other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityViewOption.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityViewOption.cs new file mode 100644 index 0000000000000..e432cb9e3c59c --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/EntityViewOption.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + /// The EntityViewOption. + public readonly partial struct EntityViewOption : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EntityViewOption(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FullHierarchyValue = "FullHierarchy"; + private const string GroupsOnlyValue = "GroupsOnly"; + private const string SubscriptionsOnlyValue = "SubscriptionsOnly"; + private const string AuditValue = "Audit"; + + /// FullHierarchy. + public static EntityViewOption FullHierarchy { get; } = new EntityViewOption(FullHierarchyValue); + /// GroupsOnly. + public static EntityViewOption GroupsOnly { get; } = new EntityViewOption(GroupsOnlyValue); + /// SubscriptionsOnly. + public static EntityViewOption SubscriptionsOnly { get; } = new EntityViewOption(SubscriptionsOnlyValue); + /// Audit. + public static EntityViewOption Audit { get; } = new EntityViewOption(AuditValue); + /// Determines if two values are the same. + public static bool operator ==(EntityViewOption left, EntityViewOption right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EntityViewOption left, EntityViewOption right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator EntityViewOption(string value) => new EntityViewOption(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EntityViewOption other && Equals(other); + /// + public bool Equals(EntityViewOption other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCollectionGetEntitiesOptions.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCollectionGetEntitiesOptions.cs new file mode 100644 index 0000000000000..fdbf34a7ae00b --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/Models/ManagementGroupCollectionGetEntitiesOptions.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.ManagementGroups.Models +{ + /// The ManagementGroupCollectionGetEntitiesOptions. + public partial class ManagementGroupCollectionGetEntitiesOptions + { + /// Initializes a new instance of . + public ManagementGroupCollectionGetEntitiesOptions() + { + } + + /// + /// Page continuation token is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + /// + /// + public string SkipToken { get; set; } + /// Number of entities to skip over when retrieving results. Passing this in will override $skipToken. + public int? Skip { get; set; } + /// Number of elements to return when retrieving results. Passing this in will override $skipToken. + public int? Top { get; set; } + /// This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override select in $skipToken. + public string Select { get; set; } + /// + /// The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to reparent to as determined by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either direct access to or indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or one of it's descendants for it to show up in the results. + /// + public EntitySearchOption? Search { get; set; } + /// The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + public string Filter { get; set; } + /// The view parameter allows clients to filter the type of data that is returned by the getEntities call. + public EntityViewOption? View { get; set; } + /// A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'"). + public string GroupName { get; set; } + /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + public string CacheControl { get; set; } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs index 86db45a1c9a14..2049becb52b0a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/ResourceManagerModelFactory.cs @@ -158,5 +158,29 @@ public static ManagementGroupNameAvailabilityResult ManagementGroupNameAvailabil { return new ManagementGroupNameAvailabilityResult(nameAvailable, reason, message, serializedAdditionalRawData: null); } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000. + /// The friendly name of the management group. + /// (Optional) The ID of the parent management group. + /// The users specific permissions to this item. + /// The users specific permissions to this item. + /// Number of Descendants. + /// Number of children is the number of Groups and Subscriptions that are exactly one level underneath the current Group. + /// Number of children is the number of Groups that are exactly one level underneath the current Group. + /// The parent display name chain from the root group to the immediate parent. + /// The parent name chain from the root group to the immediate parent. + /// A new instance for mocking. + public static EntityData EntityData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, Guid? tenantId = null, string displayName = null, ResourceIdentifier parentId = null, EntityPermission? permissions = null, EntityPermission? inheritedPermissions = null, int? numberOfDescendants = null, int? numberOfChildren = null, int? numberOfChildGroups = null, IEnumerable parentDisplayNameChain = null, IEnumerable parentNameChain = null) + { + parentDisplayNameChain ??= new List(); + parentNameChain ??= new List(); + + return new EntityData(id, name, resourceType, systemData, tenantId, displayName, parentId != null ? ResourceManagerModelFactory.SubResource(parentId) : null, permissions, inheritedPermissions, numberOfDescendants, numberOfChildren, numberOfChildGroups, parentDisplayNameChain?.ToList(), parentNameChain?.ToList(), serializedAdditionalRawData: null); + } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/EntitiesRestOperations.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/EntitiesRestOperations.cs new file mode 100644 index 0000000000000..4bedd887f4aaf --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/EntitiesRestOperations.cs @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ManagementGroups.Models; + +namespace Azure.ResourceManager.ManagementGroups +{ + internal partial class EntitiesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of EntitiesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public EntitiesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2021-04-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string skipToken, int? skip, int? top, string select, EntitySearchOption? search, string filter, EntityViewOption? view, string groupName, string cacheControl) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/getEntities", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skipToken != null) + { + uri.AppendQuery("$skiptoken", skipToken, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (select != null) + { + uri.AppendQuery("$select", select, true); + } + if (search != null) + { + uri.AppendQuery("$search", search.Value.ToString(), true); + } + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (view != null) + { + uri.AppendQuery("$view", view.Value.ToString(), true); + } + if (groupName != null) + { + uri.AppendQuery("groupName", groupName, true); + } + request.Uri = uri; + if (cacheControl != null) + { + request.Headers.Add("Cache-Control", cacheControl); + } + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. + /// + /// + /// + /// Page continuation token is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing this in will override $skipToken. + /// Number of elements to return when retrieving results. Passing this in will override $skipToken. + /// This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override select in $skipToken. + /// + /// The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to reparent to as determined by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either direct access to or indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or one of it's descendants for it to show up in the results. + /// + /// The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + /// The view parameter allows clients to filter the type of data that is returned by the getEntities call. + /// A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'"). + /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + /// The cancellation token to use. + public async Task> ListAsync(string skipToken = null, int? skip = null, int? top = null, string select = null, EntitySearchOption? search = null, string filter = null, EntityViewOption? view = null, string groupName = null, string cacheControl = null, CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(skipToken, skip, top, select, search, filter, view, groupName, cacheControl); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EntityListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EntityListResult.DeserializeEntityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. + /// + /// + /// + /// Page continuation token is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing this in will override $skipToken. + /// Number of elements to return when retrieving results. Passing this in will override $skipToken. + /// This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override select in $skipToken. + /// + /// The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to reparent to as determined by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either direct access to or indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or one of it's descendants for it to show up in the results. + /// + /// The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + /// The view parameter allows clients to filter the type of data that is returned by the getEntities call. + /// A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'"). + /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + /// The cancellation token to use. + public Response List(string skipToken = null, int? skip = null, int? top = null, string select = null, EntitySearchOption? search = null, string filter = null, EntityViewOption? view = null, string groupName = null, string cacheControl = null, CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(skipToken, skip, top, select, search, filter, view, groupName, cacheControl); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EntityListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EntityListResult.DeserializeEntityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string skipToken, int? skip, int? top, string select, EntitySearchOption? search, string filter, EntityViewOption? view, string groupName, string cacheControl) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + if (cacheControl != null) + { + request.Headers.Add("Cache-Control", cacheControl); + } + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. + /// + /// + /// The URL to the next page of results. + /// + /// Page continuation token is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing this in will override $skipToken. + /// Number of elements to return when retrieving results. Passing this in will override $skipToken. + /// This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override select in $skipToken. + /// + /// The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to reparent to as determined by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either direct access to or indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or one of it's descendants for it to show up in the results. + /// + /// The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + /// The view parameter allows clients to filter the type of data that is returned by the getEntities call. + /// A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'"). + /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + /// The cancellation token to use. + /// is null. + public async Task> ListNextPageAsync(string nextLink, string skipToken = null, int? skip = null, int? top = null, string select = null, EntitySearchOption? search = null, string filter = null, EntityViewOption? view = null, string groupName = null, string cacheControl = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink, skipToken, skip, top, select, search, filter, view, groupName, cacheControl); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EntityListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EntityListResult.DeserializeEntityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. + /// + /// + /// The URL to the next page of results. + /// + /// Page continuation token is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing this in will override $skipToken. + /// Number of elements to return when retrieving results. Passing this in will override $skipToken. + /// This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override select in $skipToken. + /// + /// The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to reparent to as determined by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either direct access to or indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or one of it's descendants for it to show up in the results. + /// + /// The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + /// The view parameter allows clients to filter the type of data that is returned by the getEntities call. + /// A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'"). + /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. + /// The cancellation token to use. + /// is null. + public Response ListNextPage(string nextLink, string skipToken = null, int? skip = null, int? top = null, string select = null, EntitySearchOption? search = null, string filter = null, EntityViewOption? view = null, string groupName = null, string cacheControl = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink, skipToken, skip, top, select, search, filter, view, groupName, cacheControl); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EntityListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EntityListResult.DeserializeEntityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/ManagementGroupsRestOperations.cs b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/ManagementGroupsRestOperations.cs index a2a903544b783..05828d533e8ab 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/ManagementGroupsRestOperations.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/ManagementGroup/Generated/RestOperations/ManagementGroupsRestOperations.cs @@ -37,7 +37,7 @@ public ManagementGroupsRestOperations(HttpPipeline pipeline, string applicationI _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal HttpMessage CreateListRequest(string cacheControl, string skiptoken) + internal HttpMessage CreateListRequest(string cacheControl, string skipToken) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -46,9 +46,9 @@ internal HttpMessage CreateListRequest(string cacheControl, string skiptoken) uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Management/managementGroups", false); uri.AppendQuery("api-version", _apiVersion, true); - if (skiptoken != null) + if (skipToken != null) { - uri.AppendQuery("$skiptoken", skiptoken, true); + uri.AppendQuery("$skiptoken", skipToken, true); } request.Uri = uri; if (cacheControl != null) @@ -65,15 +65,15 @@ internal HttpMessage CreateListRequest(string cacheControl, string skiptoken) /// /// /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// /// /// The cancellation token to use. - public async Task> ListAsync(string cacheControl = null, string skiptoken = null, CancellationToken cancellationToken = default) + public async Task> ListAsync(string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default) { - using var message = CreateListRequest(cacheControl, skiptoken); + using var message = CreateListRequest(cacheControl, skipToken); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -94,15 +94,15 @@ public async Task> ListAsync(string cacheCon /// /// /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// /// /// The cancellation token to use. - public Response List(string cacheControl = null, string skiptoken = null, CancellationToken cancellationToken = default) + public Response List(string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default) { - using var message = CreateListRequest(cacheControl, skiptoken); + using var message = CreateListRequest(cacheControl, skipToken); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { @@ -456,7 +456,7 @@ public Response Delete(string groupId, string cacheControl = null, CancellationT } } - internal HttpMessage CreateGetDescendantsRequest(string groupId, string skiptoken, int? top) + internal HttpMessage CreateGetDescendantsRequest(string groupId, string skipToken, int? top) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -467,9 +467,9 @@ internal HttpMessage CreateGetDescendantsRequest(string groupId, string skiptoke uri.AppendPath(groupId, true); uri.AppendPath("/descendants", false); uri.AppendQuery("api-version", _apiVersion, true); - if (skiptoken != null) + if (skipToken != null) { - uri.AppendQuery("$skiptoken", skiptoken, true); + uri.AppendQuery("$skiptoken", skipToken, true); } if (top != null) { @@ -486,7 +486,7 @@ internal HttpMessage CreateGetDescendantsRequest(string groupId, string skiptoke /// /// /// Management Group ID. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// @@ -495,11 +495,11 @@ internal HttpMessage CreateGetDescendantsRequest(string groupId, string skiptoke /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - public async Task> GetDescendantsAsync(string groupId, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + public async Task> GetDescendantsAsync(string groupId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var message = CreateGetDescendantsRequest(groupId, skiptoken, top); + using var message = CreateGetDescendantsRequest(groupId, skipToken, top); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -520,7 +520,7 @@ public async Task> GetDescendantsAsync(string gro /// /// /// Management Group ID. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// @@ -529,11 +529,11 @@ public async Task> GetDescendantsAsync(string gro /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - public Response GetDescendants(string groupId, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + public Response GetDescendants(string groupId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var message = CreateGetDescendantsRequest(groupId, skiptoken, top); + using var message = CreateGetDescendantsRequest(groupId, skipToken, top); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { @@ -616,7 +616,7 @@ public Response CheckNameAvailability(Man } } - internal HttpMessage CreateListNextPageRequest(string nextLink, string cacheControl, string skiptoken) + internal HttpMessage CreateListNextPageRequest(string nextLink, string cacheControl, string skipToken) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -640,18 +640,18 @@ internal HttpMessage CreateListNextPageRequest(string nextLink, string cacheCont /// /// The URL to the next page of results. /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// /// /// The cancellation token to use. /// is null. - public async Task> ListNextPageAsync(string nextLink, string cacheControl = null, string skiptoken = null, CancellationToken cancellationToken = default) + public async Task> ListNextPageAsync(string nextLink, string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(nextLink, nameof(nextLink)); - using var message = CreateListNextPageRequest(nextLink, cacheControl, skiptoken); + using var message = CreateListNextPageRequest(nextLink, cacheControl, skipToken); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -673,18 +673,18 @@ public async Task> ListNextPageAsync(string /// /// The URL to the next page of results. /// Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// /// /// The cancellation token to use. /// is null. - public Response ListNextPage(string nextLink, string cacheControl = null, string skiptoken = null, CancellationToken cancellationToken = default) + public Response ListNextPage(string nextLink, string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(nextLink, nameof(nextLink)); - using var message = CreateListNextPageRequest(nextLink, cacheControl, skiptoken); + using var message = CreateListNextPageRequest(nextLink, cacheControl, skipToken); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { @@ -700,7 +700,7 @@ public Response ListNextPage(string nextLink, string } } - internal HttpMessage CreateGetDescendantsNextPageRequest(string nextLink, string groupId, string skiptoken, int? top) + internal HttpMessage CreateGetDescendantsNextPageRequest(string nextLink, string groupId, string skipToken, int? top) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -720,7 +720,7 @@ internal HttpMessage CreateGetDescendantsNextPageRequest(string nextLink, string /// /// The URL to the next page of results. /// Management Group ID. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// @@ -729,12 +729,12 @@ internal HttpMessage CreateGetDescendantsNextPageRequest(string nextLink, string /// The cancellation token to use. /// or is null. /// is an empty string, and was expected to be non-empty. - public async Task> GetDescendantsNextPageAsync(string nextLink, string groupId, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + public async Task> GetDescendantsNextPageAsync(string nextLink, string groupId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(nextLink, nameof(nextLink)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var message = CreateGetDescendantsNextPageRequest(nextLink, groupId, skiptoken, top); + using var message = CreateGetDescendantsNextPageRequest(nextLink, groupId, skipToken, top); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -756,7 +756,7 @@ public async Task> GetDescendantsNextPageAsync(st /// /// The URL to the next page of results. /// Management Group ID. - /// + /// /// Page continuation token is only used if a previous operation returned a partial result. /// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls. /// @@ -765,12 +765,12 @@ public async Task> GetDescendantsNextPageAsync(st /// The cancellation token to use. /// or is null. /// is an empty string, and was expected to be non-empty. - public Response GetDescendantsNextPage(string nextLink, string groupId, string skiptoken = null, int? top = null, CancellationToken cancellationToken = default) + public Response GetDescendantsNextPage(string nextLink, string groupId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(nextLink, nameof(nextLink)); Argument.AssertNotNullOrEmpty(groupId, nameof(groupId)); - using var message = CreateGetDescendantsNextPageRequest(nextLink, groupId, skiptoken, top); + using var message = CreateGetDescendantsNextPageRequest(nextLink, groupId, skipToken, top); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.Serialization.cs new file mode 100644 index 0000000000000..0b4095eb3a1d8 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Resources.Models +{ + public partial class ResourceNameValidationContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceNameValidationContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ResourceNameValidationContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceNameValidationContent)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceNameValidationContent(document.RootElement, options); + } + + internal static ResourceNameValidationContent DeserializeResourceNameValidationContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ResourceType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceNameValidationContent(name, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ResourceNameValidationContent)} does not support '{options.Format}' format."); + } + } + + ResourceNameValidationContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeResourceNameValidationContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceNameValidationContent)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.cs new file mode 100644 index 0000000000000..cdf61d36d0970 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationContent.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Name and Type of the Resource. + public partial class ResourceNameValidationContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Name of the resource. + /// The type of the resource. + /// is null. + public ResourceNameValidationContent(string name, ResourceType resourceType) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + ResourceType = resourceType; + } + + /// Initializes a new instance of . + /// Name of the resource. + /// The type of the resource. + /// Keeps track of any properties unknown to the library. + internal ResourceNameValidationContent(string name, ResourceType resourceType, IDictionary serializedAdditionalRawData) + { + Name = name; + ResourceType = resourceType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceNameValidationContent() + { + } + + /// Name of the resource. + public string Name { get; } + /// The type of the resource. + public ResourceType ResourceType { get; } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs new file mode 100644 index 0000000000000..115c6c91b86a0 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Resources.Models +{ + public partial class ResourceNameValidationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceNameValidationResult)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType.Value); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ResourceNameValidationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceNameValidationResult)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceNameValidationResult(document.RootElement, options); + } + + internal static ResourceNameValidationResult DeserializeResourceNameValidationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional name = default; + Optional type = default; + Optional status = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new ResourceNameValidationStatus(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ResourceNameValidationResult(name.Value, Optional.ToNullable(type), Optional.ToNullable(status), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ResourceNameValidationResult)} does not support '{options.Format}' format."); + } + } + + ResourceNameValidationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeResourceNameValidationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceNameValidationResult)} does not support '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.cs new file mode 100644 index 0000000000000..b6f259254a96b --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationResult.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Resource Name valid if not a reserved word, does not contain a reserved word and does not start with a reserved word. + public partial class ResourceNameValidationResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ResourceNameValidationResult() + { + } + + /// Initializes a new instance of . + /// Name of Resource. + /// Type of Resource. + /// Is the resource name Allowed or Reserved. + /// Keeps track of any properties unknown to the library. + internal ResourceNameValidationResult(string name, ResourceType? resourceType, ResourceNameValidationStatus? status, IDictionary serializedAdditionalRawData) + { + Name = name; + ResourceType = resourceType; + Status = status; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of Resource. + public string Name { get; } + /// Type of Resource. + public ResourceType? ResourceType { get; } + /// Is the resource name Allowed or Reserved. + public ResourceNameValidationStatus? Status { get; } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationStatus.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationStatus.cs new file mode 100644 index 0000000000000..b7982543621db --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/Models/ResourceNameValidationStatus.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Resources.Models +{ + /// Is the resource name Allowed or Reserved. + public readonly partial struct ResourceNameValidationStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResourceNameValidationStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AllowedValue = "Allowed"; + private const string ReservedValue = "Reserved"; + + /// Allowed. + public static ResourceNameValidationStatus Allowed { get; } = new ResourceNameValidationStatus(AllowedValue); + /// Reserved. + public static ResourceNameValidationStatus Reserved { get; } = new ResourceNameValidationStatus(ReservedValue); + /// Determines if two values are the same. + public static bool operator ==(ResourceNameValidationStatus left, ResourceNameValidationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResourceNameValidationStatus left, ResourceNameValidationStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ResourceNameValidationStatus(string value) => new ResourceNameValidationStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResourceNameValidationStatus other && Equals(other); + /// + public bool Equals(ResourceNameValidationStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupResource.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupResource.cs index a97b0fd755940..24bd6ca65eed3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceGroupResource.cs @@ -347,15 +347,15 @@ public virtual Response Update(ResourceGroupPatch patch, } /// - /// Captures the specified resource group as a template. + /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. /// /// /// Request Path - /// /subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate + /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources /// /// /// Operation Id - /// ResourceGroups_ExportTemplate + /// Resources_MoveResources /// /// /// Default Api Version @@ -368,21 +368,21 @@ public virtual Response Update(ResourceGroupPatch patch, /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// Parameters for exporting the template. + /// Parameters for moving resources. /// The cancellation token to use. - /// is null. - public virtual async Task> ExportTemplateAsync(WaitUntil waitUntil, ExportTemplate exportTemplate, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task MoveResourcesAsync(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(exportTemplate, nameof(exportTemplate)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.ExportTemplate"); + using var scope = _resourceGroupResourcesClientDiagnostics.CreateScope("ResourceGroupResource.MoveResources"); scope.Start(); try { - var response = await _resourceGroupRestClient.ExportTemplateAsync(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate, cancellationToken).ConfigureAwait(false); - var operation = new ResourcesArmOperation(new ResourceGroupExportResultOperationSource(), _resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateExportTemplateRequest(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate).Request, response, OperationFinalStateVia.Location); + var response = await _resourceGroupResourcesRestClient.MoveResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken).ConfigureAwait(false); + var operation = new ResourcesArmOperation(_resourceGroupResourcesClientDiagnostics, Pipeline, _resourceGroupResourcesRestClient.CreateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; } catch (Exception e) @@ -393,15 +393,15 @@ public virtual async Task> ExportTemplat } /// - /// Captures the specified resource group as a template. + /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. /// /// /// Request Path - /// /subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate + /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources /// /// /// Operation Id - /// ResourceGroups_ExportTemplate + /// Resources_MoveResources /// /// /// Default Api Version @@ -414,21 +414,21 @@ public virtual async Task> ExportTemplat /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// Parameters for exporting the template. + /// Parameters for moving resources. /// The cancellation token to use. - /// is null. - public virtual ArmOperation ExportTemplate(WaitUntil waitUntil, ExportTemplate exportTemplate, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation MoveResources(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(exportTemplate, nameof(exportTemplate)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.ExportTemplate"); + using var scope = _resourceGroupResourcesClientDiagnostics.CreateScope("ResourceGroupResource.MoveResources"); scope.Start(); try { - var response = _resourceGroupRestClient.ExportTemplate(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate, cancellationToken); - var operation = new ResourcesArmOperation(new ResourceGroupExportResultOperationSource(), _resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateExportTemplateRequest(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate).Request, response, OperationFinalStateVia.Location); + var response = _resourceGroupResourcesRestClient.MoveResources(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken); + var operation = new ResourcesArmOperation(_resourceGroupResourcesClientDiagnostics, Pipeline, _resourceGroupResourcesRestClient.CreateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); + operation.WaitForCompletionResponse(cancellationToken); return operation; } catch (Exception e) @@ -439,15 +439,15 @@ public virtual ArmOperation ExportTemplate(WaitUntil } /// - /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. /// /// /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources + /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources /// /// /// Operation Id - /// ResourceGroups_MoveResources + /// Resources_ValidateMoveResources /// /// /// Default Api Version @@ -463,16 +463,16 @@ public virtual ArmOperation ExportTemplate(WaitUntil /// Parameters for moving resources. /// The cancellation token to use. /// is null. - public virtual async Task MoveResourcesAsync(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) + public virtual async Task ValidateMoveResourcesAsync(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); - using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.MoveResources"); + using var scope = _resourceGroupResourcesClientDiagnostics.CreateScope("ResourceGroupResource.ValidateMoveResources"); scope.Start(); try { - var response = await _resourceGroupRestClient.MoveResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken).ConfigureAwait(false); - var operation = new ResourcesArmOperation(_resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); + var response = await _resourceGroupResourcesRestClient.ValidateMoveResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken).ConfigureAwait(false); + var operation = new ResourcesArmOperation(_resourceGroupResourcesClientDiagnostics, Pipeline, _resourceGroupResourcesRestClient.CreateValidateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -485,15 +485,15 @@ public virtual async Task MoveResourcesAsync(WaitUntil waitUntil, } /// - /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. /// /// /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources + /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources /// /// /// Operation Id - /// ResourceGroups_MoveResources + /// Resources_ValidateMoveResources /// /// /// Default Api Version @@ -509,16 +509,16 @@ public virtual async Task MoveResourcesAsync(WaitUntil waitUntil, /// Parameters for moving resources. /// The cancellation token to use. /// is null. - public virtual ArmOperation MoveResources(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) + public virtual ArmOperation ValidateMoveResources(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); - using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.MoveResources"); + using var scope = _resourceGroupResourcesClientDiagnostics.CreateScope("ResourceGroupResource.ValidateMoveResources"); scope.Start(); try { - var response = _resourceGroupRestClient.MoveResources(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken); - var operation = new ResourcesArmOperation(_resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); + var response = _resourceGroupResourcesRestClient.ValidateMoveResources(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken); + var operation = new ResourcesArmOperation(_resourceGroupResourcesClientDiagnostics, Pipeline, _resourceGroupResourcesRestClient.CreateValidateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; @@ -531,15 +531,15 @@ public virtual ArmOperation MoveResources(WaitUntil waitUntil, ResourcesMoveCont } /// - /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + /// Captures the specified resource group as a template. /// /// /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources + /// /subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate /// /// /// Operation Id - /// ResourceGroups_ValidateMoveResources + /// ResourceGroups_ExportTemplate /// /// /// Default Api Version @@ -552,21 +552,21 @@ public virtual ArmOperation MoveResources(WaitUntil waitUntil, ResourcesMoveCont /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// Parameters for moving resources. + /// Parameters for exporting the template. /// The cancellation token to use. - /// is null. - public virtual async Task ValidateMoveResourcesAsync(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> ExportTemplateAsync(WaitUntil waitUntil, ExportTemplate exportTemplate, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(exportTemplate, nameof(exportTemplate)); - using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.ValidateMoveResources"); + using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.ExportTemplate"); scope.Start(); try { - var response = await _resourceGroupRestClient.ValidateMoveResourcesAsync(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken).ConfigureAwait(false); - var operation = new ResourcesArmOperation(_resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateValidateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); + var response = await _resourceGroupRestClient.ExportTemplateAsync(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate, cancellationToken).ConfigureAwait(false); + var operation = new ResourcesArmOperation(new ResourceGroupExportResultOperationSource(), _resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateExportTemplateRequest(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; } catch (Exception e) @@ -577,15 +577,15 @@ public virtual async Task ValidateMoveResourcesAsync(WaitUntil wai } /// - /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + /// Captures the specified resource group as a template. /// /// /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources + /// /subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate /// /// /// Operation Id - /// ResourceGroups_ValidateMoveResources + /// ResourceGroups_ExportTemplate /// /// /// Default Api Version @@ -598,21 +598,21 @@ public virtual async Task ValidateMoveResourcesAsync(WaitUntil wai /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// Parameters for moving resources. + /// Parameters for exporting the template. /// The cancellation token to use. - /// is null. - public virtual ArmOperation ValidateMoveResources(WaitUntil waitUntil, ResourcesMoveContent content, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation ExportTemplate(WaitUntil waitUntil, ExportTemplate exportTemplate, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(exportTemplate, nameof(exportTemplate)); - using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.ValidateMoveResources"); + using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.ExportTemplate"); scope.Start(); try { - var response = _resourceGroupRestClient.ValidateMoveResources(Id.SubscriptionId, Id.ResourceGroupName, content, cancellationToken); - var operation = new ResourcesArmOperation(_resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateValidateMoveResourcesRequest(Id.SubscriptionId, Id.ResourceGroupName, content).Request, response, OperationFinalStateVia.Location); + var response = _resourceGroupRestClient.ExportTemplate(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate, cancellationToken); + var operation = new ResourcesArmOperation(new ResourceGroupExportResultOperationSource(), _resourceGroupClientDiagnostics, Pipeline, _resourceGroupRestClient.CreateExportTemplateRequest(Id.SubscriptionId, Id.ResourceGroupName, exportTemplate).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); + operation.WaitForCompletion(cancellationToken); return operation; } catch (Exception e) diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs index 676cc6d0732fb..196820b2d82af 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/ResourceManagerModelFactory.cs @@ -560,6 +560,16 @@ public static TenantData TenantData(string id = null, Guid? tenantId = null, Ten return new TenantData(id, tenantId, tenantCategory, country, countryCode, displayName, domains?.ToList(), defaultDomain, tenantType, tenantBrandingLogoUri, serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// Name of Resource. + /// Type of Resource. + /// Is the resource name Allowed or Reserved. + /// A new instance for mocking. + public static ResourceNameValidationResult ResourceNameValidationResult(string name = null, ResourceType? resourceType = null, ResourceNameValidationStatus? status = null) + { + return new ResourceNameValidationResult(name, resourceType, status, serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The id. /// The name. diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceGroupsRestOperations.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceGroupsRestOperations.cs index f7681ae4881c2..cb3e7af83850f 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceGroupsRestOperations.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceGroupsRestOperations.cs @@ -497,152 +497,6 @@ public Response List(string subscriptionId, string filt } } - internal HttpMessage CreateMoveResourcesRequest(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(sourceResourceGroupName, true); - uri.AppendPath("/moveResources", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - /// The ID of the target subscription. - /// The name of the resource group from the source subscription containing the resources to be moved. - /// Parameters for moving resources. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task MoveResourcesAsync(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. - /// The ID of the target subscription. - /// The name of the resource group from the source subscription containing the resources to be moved. - /// Parameters for moving resources. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response MoveResources(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal HttpMessage CreateValidateMoveResourcesRequest(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(sourceResourceGroupName, true); - uri.AppendPath("/validateMoveResources", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - /// The ID of the target subscription. - /// The name of the resource group from the source subscription containing the resources to be validated for move. - /// Parameters for moving resources. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task ValidateMoveResourcesAsync(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. - /// The ID of the target subscription. - /// The name of the resource group from the source subscription containing the resources to be validated for move. - /// Parameters for moving resources. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ValidateMoveResources(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateValidateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string filter, int? top) { var message = _pipeline.CreateMessage(); diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs new file mode 100644 index 0000000000000..261ba58b57df4 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourceManagementRestOperations.cs @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Resources +{ + internal partial class ResourceManagementRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ResourceManagementRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public ResourceManagementRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2022-12-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateCheckResourceNameRequest(ResourceNameValidationContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Resources/checkResourceName", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + if (content != null) + { + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + } + _userAgent.Apply(message); + return message; + } + + /// A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word. + /// Resource object with values for resource name and resource type. + /// The cancellation token to use. + public async Task> CheckResourceNameAsync(ResourceNameValidationContent content = null, CancellationToken cancellationToken = default) + { + using var message = CreateCheckResourceNameRequest(content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceNameValidationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ResourceNameValidationResult.DeserializeResourceNameValidationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word. + /// Resource object with values for resource name and resource type. + /// The cancellation token to use. + public Response CheckResourceName(ResourceNameValidationContent content = null, CancellationToken cancellationToken = default) + { + using var message = CreateCheckResourceNameRequest(content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceNameValidationResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ResourceNameValidationResult.DeserializeResourceNameValidationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourcesRestOperations.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourcesRestOperations.cs index 5a55aaefd6ca6..ec3ffae8210d7 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourcesRestOperations.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/RestOperations/ResourcesRestOperations.cs @@ -128,6 +128,152 @@ public Response ListByResourceGroup(string subscriptionId, s } } + internal HttpMessage CreateMoveResourcesRequest(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(sourceResourceGroupName, true); + uri.AppendPath("/moveResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + /// The ID of the target subscription. + /// The name of the resource group from the source subscription containing the resources to be moved. + /// Parameters for moving resources. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task MoveResourcesAsync(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + /// The ID of the target subscription. + /// The name of the resource group from the source subscription containing the resources to be moved. + /// Parameters for moving resources. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response MoveResources(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateValidateMoveResourcesRequest(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(sourceResourceGroupName, true); + uri.AppendPath("/validateMoveResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + /// The ID of the target subscription. + /// The name of the resource group from the source subscription containing the resources to be validated for move. + /// Parameters for moving resources. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task ValidateMoveResourcesAsync(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateValidateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// This operation checks whether the specified resources can be moved to the target. The resources to be moved must be in the same source resource group in the source subscription being used. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + /// The ID of the target subscription. + /// The name of the resource group from the source subscription containing the resources to be validated for move. + /// Parameters for moving resources. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ValidateMoveResources(string subscriptionId, string sourceResourceGroupName, ResourcesMoveContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(sourceResourceGroupName, nameof(sourceResourceGroupName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateValidateMoveResourcesRequest(subscriptionId, sourceResourceGroupName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + internal HttpMessage CreateListRequest(string subscriptionId, string filter, string expand, int? top) { var message = _pipeline.CreateMessage(); diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantCollection.cs index 4fd8d44e395cf..423cfde61eeb0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/src/Resources/Generated/TenantCollection.cs @@ -16,6 +16,7 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.Resources { @@ -24,6 +25,8 @@ public partial class TenantCollection : ArmCollection, IEnumerable Initializes a new instance of the class for mocking. protected TenantCollection() @@ -38,6 +41,8 @@ internal TenantCollection(ArmClient client, ResourceIdentifier id) : base(client _tenantClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", TenantResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(TenantResource.ResourceType, out string tenantApiVersion); _tenantRestClient = new TenantsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, tenantApiVersion); + _defaultClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _defaultRestClient = new ResourceManagementRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); #if DEBUG ValidateResourceId(Id); #endif @@ -109,6 +114,76 @@ public virtual Pageable GetAll(CancellationToken cancellationTok return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TenantResource(Client, TenantData.DeserializeTenantData(e)), _tenantClientDiagnostics, Pipeline, "TenantCollection.GetAll", "value", "nextLink", cancellationToken); } + /// + /// A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + /// + /// + /// Request Path + /// /providers/Microsoft.Resources/checkResourceName + /// + /// + /// Operation Id + /// checkResourceName + /// + /// + /// Default Api Version + /// 2022-12-01 + /// + /// + /// + /// Resource object with values for resource name and resource type. + /// The cancellation token to use. + public virtual async Task> CheckResourceNameAsync(ResourceNameValidationContent content = null, CancellationToken cancellationToken = default) + { + using var scope = _defaultClientDiagnostics.CreateScope("TenantCollection.CheckResourceName"); + scope.Start(); + try + { + var response = await _defaultRestClient.CheckResourceNameAsync(content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + /// + /// + /// Request Path + /// /providers/Microsoft.Resources/checkResourceName + /// + /// + /// Operation Id + /// checkResourceName + /// + /// + /// Default Api Version + /// 2022-12-01 + /// + /// + /// + /// Resource object with values for resource name and resource type. + /// The cancellation token to use. + public virtual Response CheckResourceName(ResourceNameValidationContent content = null, CancellationToken cancellationToken = default) + { + using var scope = _defaultClientDiagnostics.CreateScope("TenantCollection.CheckResourceName"); + scope.Start(); + try + { + var response = _defaultRestClient.CheckResourceName(content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + IEnumerator IEnumerable.GetEnumerator() { return GetAll().GetEnumerator(); diff --git a/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md b/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md index 4a51affd763b5..8462cbca76697 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md +++ b/sdk/resourcemanager/Azure.ResourceManager/src/autorest.md @@ -15,8 +15,8 @@ modelerfour: use-model-reader-writer: true deserialize-null-collection-as-null-value: true -# mgmt-debug: -# show-serialized-names: true +#mgmt-debug: +# show-serialized-names: true batch: - tag: package-common-type @@ -186,8 +186,10 @@ input-file: - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/resources.json - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/subscriptions.json - https://github.com/Azure/azure-rest-api-specs/blob/78eac0bd58633028293cb1ec1709baa200bed9e2/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/features.json + list-exception: - /{resourceId} + request-path-to-resource-data: # subscription does not have name and type /subscriptions/{subscriptionId}: Subscription @@ -195,14 +197,17 @@ request-path-to-resource-data: /: Tenant # provider does not have name and type /subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}: ResourceProvider + request-path-is-non-resource: - /subscriptions/{subscriptionId}/locations + request-path-to-parent: /subscriptions: /subscriptions/{subscriptionId} /tenants: / /subscriptions/{subscriptionId}/locations: /subscriptions/{subscriptionId} /subscriptions/{subscriptionId}/providers: /subscriptions/{subscriptionId}/providers/{resourceProviderNamespace} /subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}: /subscriptions/{subscriptionId}/providers/{resourceProviderNamespace} + request-path-to-resource-type: /subscriptions/{subscriptionId}/locations: Microsoft.Resources/locations /tenants: Microsoft.Resources/tenants @@ -212,16 +217,20 @@ request-path-to-resource-type: /subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}: Microsoft.Resources/features /subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}: Microsoft.Resources/providers /providers: Microsoft.Resources/providers + request-path-to-scope-resource-types: /{scope}/providers/Microsoft.Authorization/locks/{lockName}: - subscriptions - resourceGroups - "*" +operation-positions: + checkResourceName: collection + operation-groups-to-omit: - Deployments - DeploymentOperations - AuthorizationOperations - - ResourceCheck + override-operation-name: Tags_List: GetAllPredefinedTags Tags_DeleteValue: DeletePredefinedTagValue @@ -230,14 +239,12 @@ override-operation-name: Tags_Delete: DeletePredefinedTag Providers_ListAtTenantScope: GetTenantResourceProviders Providers_GetAtTenantScope: GetTenantResourceProvider - Resources_MoveResources: MoveResources - Resources_ValidateMoveResources: ValidateMoveResources Resources_List: GetGenericResources Resources_ListByResourceGroup: GetGenericResources - Providers_RegisterAtManagementGroupScope: RegisterResourceProvider - ResourceLinks_ListAtSubscription: GetResourceLinks + Resources_MoveResources: MoveResources + Resources_ValidateMoveResources: ValidateMoveResources -no-property-type-replacement: ResourceProviderData;ResourceProvider; +no-property-type-replacement: ResourceProviderData;ResourceProvider operations-to-skip-lro-api-version-override: - Tags_CreateOrUpdateAtScope @@ -289,6 +296,11 @@ rename-mapping: Location: LocationExpanded ResourcesMoveContent.targetResourceGroup: targetResourceGroupId|arm-id LocationMetadata.pairedRegion: PairedRegions + CheckResourceNameResult: ResourceNameValidationResult + CheckResourceNameResult.type: ResourceType|resource-type + ResourceName: ResourceNameValidationContent + ResourceName.type: ResourceType|resource-type + ResourceNameStatus: ResourceNameValidationStatus directive: # These methods can be replaced by using other methods in the same operation group, remove for Preview. @@ -339,13 +351,6 @@ directive: transform: > $["operationId"] = "Operations_ListFeaturesOperations"; reason: Add operation group so that we can omit related models by the operation group. - - from: locks.json - where: $.definitions - transform: > - $["OperationListResult"]["x-ms-client-name"] = "ManagementLockOperationListResult"; - $["Operation"]["x-ms-client-name"] = "ManagementLockOperation"; - $["Operation"]["properties"]["displayOfManagementLock"] = $["Operation"]["properties"]["display"]; - $["Operation"]["properties"]["display"] = undefined; - from: links.json where: $.definitions transform: > @@ -367,16 +372,6 @@ directive: where: $.definitions.ErrorResponse transform: > $["x-ms-client-name"] = "FeatureErrorResponse"; - - - rename-operation: - from: checkResourceName - to: ResourceCheck_CheckResourceName - - rename-operation: - from: Resources_MoveResources - to: ResourceGroups_MoveResources - - rename-operation: - from: Resources_ValidateMoveResources - to: ResourceGroups_ValidateMoveResources # remove the systemData property because we already included this property in its base class and the type replacement somehow does not work in resourcemanager - from: policyAssignments.json where: $.definitions.PolicyAssignment.properties.systemData @@ -702,12 +697,13 @@ input-file: - https://github.com/Azure/azure-rest-api-specs/blob/90a65cb3135d42438a381eb8bb5461a2b99b199f/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/management.json request-path-to-parent: /providers/Microsoft.Management/checkNameAvailability: /providers/Microsoft.Management/managementGroups/{groupId} + /providers/Microsoft.Management/getEntities: /providers/Microsoft.Management/managementGroups/{groupId} operation-positions: ManagementGroups_CheckNameAvailability: collection + Entities_List: collection operation-groups-to-omit: - HierarchySettings - ManagementGroupSubscriptions - - Entities - TenantBackfill no-property-type-replacement: DescendantParentGroupInfo @@ -718,6 +714,12 @@ format-by-name-rules: '*Uri': 'Uri' '*Uris': 'Uri' +rename-mapping: + EntityInfo: EntityData + Permissions: EntityPermission + Permissions.noaccess: NoAccess + SearchOptions: EntitySearchOption + acronym-mapping: CPU: Cpu CPUs: Cpus @@ -755,6 +757,10 @@ directive: - rename-operation: from: TenantBackfillStatus to: TenantBackfill_Status + - from: management.json + where: $.parameters.SkipTokenParameter + transform: > + $['x-ms-client-name'] = 'SkipToken' - from: management.json where: $.parameters.ExpandParameter transform: > diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/ModelReaderWriterImplementationValidation.Exceptions.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/ModelReaderWriterImplementationValidation.Exceptions.cs index fb0321809ae5f..f79fa43959d8c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/ModelReaderWriterImplementationValidation.Exceptions.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/ModelReaderWriterImplementationValidation.Exceptions.cs @@ -11,9 +11,9 @@ public ModelReaderWriterImplementationValidation() { "Azure.ResourceManager.Resources.Models.SubResource", "Azure.ResourceManager.Resources.Models.WritableSubResource", - "Azure.ResourceManager.Models.ManagedServiceIdentity", // TODO -- we should remove this when we support it "Azure.ResourceManager.Models.ResourceData", - "Azure.ResourceManager.Models.TrackedResourceData" + "Azure.ResourceManager.Models.TrackedResourceData", + "Azure.ResourceManager.ManagementGroups.Models.ManagementGroupCollectionGetEntitiesOptions" }; } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/ManagementGroupCollectionTests.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/ManagementGroupCollectionTests.cs index 3e4227d1fa1e5..247f486cc60cc 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/ManagementGroupCollectionTests.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/ManagementGroupCollectionTests.cs @@ -96,5 +96,18 @@ public async Task CheckNameAvailability() var rs = await Client.GetManagementGroups().CheckNameAvailabilityAsync(rq); Assert.IsTrue(rs.Value.NameAvailable); } + + [RecordedTest] + public async Task GetEntities() + { + var mgmtGroupCollection = Client.GetManagementGroups(); + var rq = new ManagementGroupCollectionGetEntitiesOptions(); + EntityData entity; + await foreach(var item in mgmtGroupCollection.GetEntitiesAsync(rq)) + { + entity = item; + break; + } + } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/TenantCollectionTests.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/TenantCollectionTests.cs index c289664756655..0d3ccaa85b75d 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/TenantCollectionTests.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Scenario/TenantCollectionTests.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources.Models; using NUnit.Framework; namespace Azure.ResourceManager.Tests @@ -11,7 +12,6 @@ public TenantCollectionTests(bool isAsync) { } - [TestCase] [RecordedTest] public async Task List() { @@ -22,5 +22,13 @@ public async Task List() } Assert.GreaterOrEqual(count, 1); } + + [RecordedTest] + public async Task CheckResourceName() + { + ResourceNameValidationContent content = new ResourceNameValidationContent("mysubs", "Microsoft.Resources/subscriptions"); + var result = await Client.GetTenants().CheckResourceNameAsync(content); + Assert.AreEqual(result.Value.Status, ResourceNameValidationStatus.Allowed); + } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs index 6db53c708a048..a7b74b718385a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/tests/Unit/GenericResourceDataTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Security.AccessControl; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -24,7 +25,6 @@ public void SerializationTestType1() ArmPlan plan = new ArmPlan("NameForPlan", "PublisherForPlan", "ProductForPlan", "PromotionCodeForPlan", "VersionForPlan"); ResourcesSku sku = new ResourcesSku("NameForSku", ArmSkuTier.Basic.ToString(), "SizeForSku", "FamilyForSku", "ModelForSku", 15464547, null); GenericResourceData data = new GenericResourceData(id, id.Name, id.ResourceType, null, new Dictionary(), AzureLocation.EastUS, null, null, plan, null, "KindForResource", "ManagedByForResource", sku, null, null, null, null); - var json = JsonHelper.SerializePropertiesToString(data, indented: true) + Environment.NewLine; Assert.AreEqual(expected, json); }