From 737ae344f6ccb8aac62bcb73a7d4ced2dda2caae Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 22 Apr 2025 06:43:41 +0000 Subject: [PATCH] CodeGen from PR 34119 in Azure/azure-rest-api-specs Merge 5ed2be45c2dcfd00dabdbb80b832aeadb6b7487e into 908f30f83295f8afe862310153344468510e3b88 --- ...esourceManager.ExtendedLocations.net8.0.cs | 129 ++++ ...anager.ExtendedLocations.netstandard2.0.cs | 129 ++++ .../Sample_CustomLocationCollection.cs | 10 +- .../Samples/Sample_CustomLocationResource.cs | 42 +- .../Sample_ResourceSyncRuleCollection.cs | 214 ++++++ .../Sample_ResourceSyncRuleResource.cs | 116 +++ .../Sample_SubscriptionResourceExtensions.cs | 2 +- .../ArmExtendedLocationsModelFactory.cs | 59 ++ .../src/Generated/CustomLocationCollection.cs | 20 +- .../src/Generated/CustomLocationResource.cs | 181 ++++- .../Extensions/ExtendedLocationsExtensions.cs | 27 +- .../MockableExtendedLocationsArmClient.cs | 12 + ...eExtendedLocationsResourceGroupResource.cs | 4 +- ...leExtendedLocationsSubscriptionResource.cs | 4 +- .../ResourceSyncRuleOperationSource.cs | 36 + ...etResourceGroupProperties.Serialization.cs | 144 ++++ ...ationFindTargetResourceGroupProperties.cs} | 26 +- ...TargetResourceGroupResult.Serialization.cs | 140 ++++ ...omLocationFindTargetResourceGroupResult.cs | 69 ++ .../CustomLocationListResult.Serialization.cs | 41 +- .../Models/CustomLocationListResult.cs | 30 +- ...edResourceTypeListResult.Serialization.cs} | 77 +- .../Models/EnabledResourceTypeListResult.cs | 80 ++ ...atchExpressionsProperties.Serialization.cs | 165 ++++ .../Models/MatchExpressionsProperties.cs | 74 ++ ...esourceSyncRuleListResult.Serialization.cs | 151 ++++ .../Models/ResourceSyncRuleListResult.cs | 80 ++ .../ResourceSyncRulePatch.Serialization.cs | 217 ++++++ .../Generated/Models/ResourceSyncRulePatch.cs | 82 ++ ...yncRulePropertiesSelector.Serialization.cs | 169 +++++ .../ResourceSyncRulePropertiesSelector.cs | 71 ++ .../Generated/ResourceSyncRuleCollection.cs | 493 ++++++++++++ .../ResourceSyncRuleData.Serialization.cs | 233 ++++++ .../src/Generated/ResourceSyncRuleData.cs | 95 +++ .../ResourceSyncRuleResource.Serialization.cs | 26 + .../src/Generated/ResourceSyncRuleResource.cs | 703 ++++++++++++++++++ .../CustomLocationsRestOperations.cs | 200 +++-- .../ResourceSyncRulesRestOperations.cs | 621 ++++++++++++++++ .../src/autorest.md | 2 +- sdk/storage/ci.yml | 2 + 40 files changed, 4799 insertions(+), 177 deletions(-) create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleCollection.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleResource.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/LongRunningOperation/ResourceSyncRuleOperationSource.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupProperties.Serialization.cs rename sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/{CustomLocationEnabledResourceTypesResult.cs => CustomLocationFindTargetResourceGroupProperties.cs} (63%) create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.Serialization.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.cs rename sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/{CustomLocationEnabledResourceTypesResult.Serialization.cs => EnabledResourceTypeListResult.Serialization.cs} (58%) create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/EnabledResourceTypeListResult.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.Serialization.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.Serialization.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.Serialization.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.Serialization.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleCollection.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.Serialization.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.Serialization.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/ResourceSyncRulesRestOperations.cs diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.net8.0.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.net8.0.cs index 4b79fecb74dc..60e07334d1b6 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.net8.0.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.net8.0.cs @@ -46,10 +46,15 @@ protected CustomLocationResource() { } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName) { throw null; } public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response FindTargetResourceGroup(Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> FindTargetResourceGroupAsync(Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetEnabledResourceTypes(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetEnabledResourceTypesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetResourceSyncRule(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetResourceSyncRuleAsync(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleCollection GetResourceSyncRules() { throw null; } public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -70,6 +75,63 @@ public static partial class ExtendedLocationsExtensions public static Azure.ResourceManager.ExtendedLocations.CustomLocationCollection GetCustomLocations(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetCustomLocations(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetCustomLocationsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleResource GetResourceSyncRuleResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class ResourceSyncRuleCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ResourceSyncRuleCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string childResourceName, Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string childResourceName, Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string childResourceName, 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; } + public virtual System.Threading.Tasks.Task> GetAsync(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string childResourceName, 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; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ResourceSyncRuleData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ResourceSyncRuleData(Azure.Core.AzureLocation location) { } + public int? Priority { get { throw null; } set { } } + public string ProvisioningState { get { throw null; } } + public Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector Selector { get { throw null; } set { } } + public string TargetResourceGroup { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData 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.ExtendedLocations.ResourceSyncRuleData 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 ResourceSyncRuleResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ResourceSyncRuleResource() { } + public virtual Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData 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.ExtendedLocations.ResourceSyncRuleData 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 virtual Azure.Response Update(Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.ExtendedLocations.Mocking @@ -78,6 +140,7 @@ public partial class MockableExtendedLocationsArmClient : Azure.ResourceManager. { protected MockableExtendedLocationsArmClient() { } public virtual Azure.ResourceManager.ExtendedLocations.CustomLocationResource GetCustomLocationResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleResource GetResourceSyncRuleResource(Azure.Core.ResourceIdentifier id) { throw null; } } public partial class MockableExtendedLocationsResourceGroupResource : Azure.ResourceManager.ArmResource { @@ -99,6 +162,9 @@ public static partial class ArmExtendedLocationsModelFactory { public static Azure.ResourceManager.ExtendedLocations.CustomLocationData CustomLocationData(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.Models.ManagedServiceIdentity identity = null, Azure.ResourceManager.ExtendedLocations.Models.CustomLocationAuthentication authentication = null, System.Collections.Generic.IEnumerable clusterExtensionIds = null, string displayName = null, Azure.Core.ResourceIdentifier hostResourceId = null, Azure.ResourceManager.ExtendedLocations.Models.CustomLocationHostType? hostType = default(Azure.ResourceManager.ExtendedLocations.Models.CustomLocationHostType?), string @namespace = null, string provisioningState = null) { throw null; } public static Azure.ResourceManager.ExtendedLocations.Models.CustomLocationEnabledResourceType CustomLocationEnabledResourceType(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.Core.ResourceIdentifier clusterExtensionId = null, string extensionType = null, System.Collections.Generic.IEnumerable typesMetadata = null) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupResult CustomLocationFindTargetResourceGroupResult(string matchedResourceSyncRule = null, string targetResourceGroup = null) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData ResourceSyncRuleData(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), int? priority = default(int?), string provisioningState = null, Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector selector = null, string targetResourceGroup = null) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch ResourceSyncRulePatch(System.Collections.Generic.IDictionary tags = null, int? priority = default(int?), string provisioningState = null, Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector selector = null, string targetResourceGroup = null) { throw null; } } public partial class CustomLocationAuthentication : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -138,6 +204,29 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer 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 CustomLocationFindTargetResourceGroupProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CustomLocationFindTargetResourceGroupProperties() { } + public System.Collections.Generic.IDictionary Labels { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties 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.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties 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 CustomLocationFindTargetResourceGroupResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal CustomLocationFindTargetResourceGroupResult() { } + public string MatchedResourceSyncRule { get { throw null; } } + public string TargetResourceGroup { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupResult 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.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupResult 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 CustomLocationHostType : System.IEquatable { @@ -174,4 +263,44 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer 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 MatchExpressionsProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MatchExpressionsProperties() { } + public string Key { get { throw null; } set { } } + public string Operator { get { throw null; } set { } } + public System.Collections.Generic.IList Values { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.MatchExpressionsProperties 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.ExtendedLocations.Models.MatchExpressionsProperties 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 ResourceSyncRulePatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ResourceSyncRulePatch() { } + public int? Priority { get { throw null; } set { } } + public string ProvisioningState { get { throw null; } } + public Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector Selector { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public string TargetResourceGroup { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch 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.ExtendedLocations.Models.ResourceSyncRulePatch 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 ResourceSyncRulePropertiesSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ResourceSyncRulePropertiesSelector() { } + public System.Collections.Generic.IList MatchExpressions { get { throw null; } } + public System.Collections.Generic.IDictionary MatchLabels { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector 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.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector 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; } + } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.netstandard2.0.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.netstandard2.0.cs index 4b79fecb74dc..60e07334d1b6 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.netstandard2.0.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/api/Azure.ResourceManager.ExtendedLocations.netstandard2.0.cs @@ -46,10 +46,15 @@ protected CustomLocationResource() { } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName) { throw null; } public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response FindTargetResourceGroup(Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> FindTargetResourceGroupAsync(Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetEnabledResourceTypes(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetEnabledResourceTypesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetResourceSyncRule(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetResourceSyncRuleAsync(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleCollection GetResourceSyncRules() { throw null; } public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -70,6 +75,63 @@ public static partial class ExtendedLocationsExtensions public static Azure.ResourceManager.ExtendedLocations.CustomLocationCollection GetCustomLocations(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetCustomLocations(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetCustomLocationsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleResource GetResourceSyncRuleResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class ResourceSyncRuleCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ResourceSyncRuleCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string childResourceName, Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string childResourceName, Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string childResourceName, 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; } + public virtual System.Threading.Tasks.Task> GetAsync(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string childResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string childResourceName, 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; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ResourceSyncRuleData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ResourceSyncRuleData(Azure.Core.AzureLocation location) { } + public int? Priority { get { throw null; } set { } } + public string ProvisioningState { get { throw null; } } + public Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector Selector { get { throw null; } set { } } + public string TargetResourceGroup { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData 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.ExtendedLocations.ResourceSyncRuleData 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 ResourceSyncRuleResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ResourceSyncRuleResource() { } + public virtual Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData 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.ExtendedLocations.ResourceSyncRuleData 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 virtual Azure.Response Update(Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.ExtendedLocations.Mocking @@ -78,6 +140,7 @@ public partial class MockableExtendedLocationsArmClient : Azure.ResourceManager. { protected MockableExtendedLocationsArmClient() { } public virtual Azure.ResourceManager.ExtendedLocations.CustomLocationResource GetCustomLocationResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleResource GetResourceSyncRuleResource(Azure.Core.ResourceIdentifier id) { throw null; } } public partial class MockableExtendedLocationsResourceGroupResource : Azure.ResourceManager.ArmResource { @@ -99,6 +162,9 @@ public static partial class ArmExtendedLocationsModelFactory { public static Azure.ResourceManager.ExtendedLocations.CustomLocationData CustomLocationData(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.Models.ManagedServiceIdentity identity = null, Azure.ResourceManager.ExtendedLocations.Models.CustomLocationAuthentication authentication = null, System.Collections.Generic.IEnumerable clusterExtensionIds = null, string displayName = null, Azure.Core.ResourceIdentifier hostResourceId = null, Azure.ResourceManager.ExtendedLocations.Models.CustomLocationHostType? hostType = default(Azure.ResourceManager.ExtendedLocations.Models.CustomLocationHostType?), string @namespace = null, string provisioningState = null) { throw null; } public static Azure.ResourceManager.ExtendedLocations.Models.CustomLocationEnabledResourceType CustomLocationEnabledResourceType(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.Core.ResourceIdentifier clusterExtensionId = null, string extensionType = null, System.Collections.Generic.IEnumerable typesMetadata = null) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupResult CustomLocationFindTargetResourceGroupResult(string matchedResourceSyncRule = null, string targetResourceGroup = null) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.ResourceSyncRuleData ResourceSyncRuleData(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), int? priority = default(int?), string provisioningState = null, Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector selector = null, string targetResourceGroup = null) { throw null; } + public static Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch ResourceSyncRulePatch(System.Collections.Generic.IDictionary tags = null, int? priority = default(int?), string provisioningState = null, Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector selector = null, string targetResourceGroup = null) { throw null; } } public partial class CustomLocationAuthentication : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -138,6 +204,29 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer 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 CustomLocationFindTargetResourceGroupProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CustomLocationFindTargetResourceGroupProperties() { } + public System.Collections.Generic.IDictionary Labels { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties 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.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupProperties 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 CustomLocationFindTargetResourceGroupResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal CustomLocationFindTargetResourceGroupResult() { } + public string MatchedResourceSyncRule { get { throw null; } } + public string TargetResourceGroup { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupResult 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.ExtendedLocations.Models.CustomLocationFindTargetResourceGroupResult 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 CustomLocationHostType : System.IEquatable { @@ -174,4 +263,44 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer 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 MatchExpressionsProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MatchExpressionsProperties() { } + public string Key { get { throw null; } set { } } + public string Operator { get { throw null; } set { } } + public System.Collections.Generic.IList Values { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.MatchExpressionsProperties 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.ExtendedLocations.Models.MatchExpressionsProperties 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 ResourceSyncRulePatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ResourceSyncRulePatch() { } + public int? Priority { get { throw null; } set { } } + public string ProvisioningState { get { throw null; } } + public Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector Selector { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public string TargetResourceGroup { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePatch 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.ExtendedLocations.Models.ResourceSyncRulePatch 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 ResourceSyncRulePropertiesSelector : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ResourceSyncRulePropertiesSelector() { } + public System.Collections.Generic.IList MatchExpressions { get { throw null; } } + public System.Collections.Generic.IDictionary MatchLabels { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector 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.ExtendedLocations.Models.ResourceSyncRulePropertiesSelector 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; } + } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs index 99748144a844..240ef9ea382a 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs @@ -22,7 +22,7 @@ public partial class Sample_CustomLocationCollection [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateUpdateCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsCreate_Update.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsCreate_Update.json // this example is just showing the usage of "CustomLocations_CreateOrUpdate" 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 @@ -69,7 +69,7 @@ public async Task CreateOrUpdate_CreateUpdateCustomLocation() [Ignore("Only validating compilation of examples")] public async Task Get_GetCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsGet.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsGet.json // this example is just showing the usage of "CustomLocations_Get" 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 @@ -102,7 +102,7 @@ public async Task Get_GetCustomLocation() [Ignore("Only validating compilation of examples")] public async Task GetAll_ListCustomLocationsByResourceGroup() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsListByResourceGroup.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListByResourceGroup.json // this example is just showing the usage of "CustomLocations_ListByResourceGroup" 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 @@ -137,7 +137,7 @@ public async Task GetAll_ListCustomLocationsByResourceGroup() [Ignore("Only validating compilation of examples")] public async Task Exists_GetCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsGet.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsGet.json // this example is just showing the usage of "CustomLocations_Get" 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 @@ -166,7 +166,7 @@ public async Task Exists_GetCustomLocation() [Ignore("Only validating compilation of examples")] public async Task GetIfExists_GetCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsGet.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsGet.json // this example is just showing the usage of "CustomLocations_Get" 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 diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs index c74e8ba2a4e4..e51b7e0bd4bd 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs @@ -21,7 +21,7 @@ public partial class Sample_CustomLocationResource [Ignore("Only validating compilation of examples")] public async Task Get_GetCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsGet.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsGet.json // this example is just showing the usage of "CustomLocations_Get" 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 @@ -51,7 +51,7 @@ public async Task Get_GetCustomLocation() [Ignore("Only validating compilation of examples")] public async Task Delete_DeleteCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsDelete.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsDelete.json // this example is just showing the usage of "CustomLocations_Delete" 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 @@ -77,7 +77,7 @@ public async Task Delete_DeleteCustomLocation() [Ignore("Only validating compilation of examples")] public async Task Update_UpdateCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsPatch.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsPatch.json // this example is just showing the usage of "CustomLocations_Update" 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 @@ -117,7 +117,7 @@ public async Task Update_UpdateCustomLocation() [Ignore("Only validating compilation of examples")] public async Task GetEnabledResourceTypes_GetCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsListEnabledResourceTypes.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListEnabledResourceTypes.json // this example is just showing the usage of "CustomLocations_ListEnabledResourceTypes" 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 @@ -141,5 +141,39 @@ public async Task GetEnabledResourceTypes_GetCustomLocation() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task FindTargetResourceGroup_PostCustomLocationFindTargetResourceGroup() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsFindTargetResourceGroup.json + // this example is just showing the usage of "CustomLocations_FindTargetResourceGroup" 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 CustomLocationResource created on azure + // for more information of creating CustomLocationResource, please refer to the document of CustomLocationResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + ResourceIdentifier customLocationResourceId = CustomLocationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + CustomLocationResource customLocation = client.GetCustomLocationResource(customLocationResourceId); + + // invoke the operation + CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties = new CustomLocationFindTargetResourceGroupProperties + { + Labels = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + CustomLocationFindTargetResourceGroupResult result = await customLocation.FindTargetResourceGroupAsync(customLocationFindTargetResourceGroupProperties); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleCollection.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleCollection.cs new file mode 100644 index 000000000000..e5918e8b3b86 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleCollection.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ExtendedLocations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.ExtendedLocations.Samples +{ + public partial class Sample_ResourceSyncRuleCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateUpdateResourceSyncRule() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesCreate_Update.json + // this example is just showing the usage of "ResourceSyncRules_CreateOrUpdate" 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 CustomLocationResource created on azure + // for more information of creating CustomLocationResource, please refer to the document of CustomLocationResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + ResourceIdentifier customLocationResourceId = CustomLocationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + CustomLocationResource customLocation = client.GetCustomLocationResource(customLocationResourceId); + + // get the collection of this ResourceSyncRuleResource + ResourceSyncRuleCollection collection = customLocation.GetResourceSyncRules(); + + // invoke the operation + string childResourceName = "resourceSyncRule01"; + ResourceSyncRuleData data = new ResourceSyncRuleData(new AzureLocation("West US")) + { + Priority = 999, + Selector = new ResourceSyncRulePropertiesSelector + { + MatchExpressions = {new MatchExpressionsProperties +{ +Key = "key4", +Operator = "In", +Values = {"value4"}, +}}, + MatchLabels = +{ +["key1"] = "value1" +}, + }, + TargetResourceGroup = "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, childResourceName, data); + ResourceSyncRuleResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceSyncRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetCustomLocation() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesGet.json + // this example is just showing the usage of "ResourceSyncRules_Get" 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 CustomLocationResource created on azure + // for more information of creating CustomLocationResource, please refer to the document of CustomLocationResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + ResourceIdentifier customLocationResourceId = CustomLocationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + CustomLocationResource customLocation = client.GetCustomLocationResource(customLocationResourceId); + + // get the collection of this ResourceSyncRuleResource + ResourceSyncRuleCollection collection = customLocation.GetResourceSyncRules(); + + // invoke the operation + string childResourceName = "resourceSyncRule01"; + ResourceSyncRuleResource result = await collection.GetAsync(childResourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceSyncRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListResourceSyncRulesBySubscription() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesListByCustomLocationID.json + // this example is just showing the usage of "ResourceSyncRules_ListByCustomLocationId" 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 CustomLocationResource created on azure + // for more information of creating CustomLocationResource, please refer to the document of CustomLocationResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + ResourceIdentifier customLocationResourceId = CustomLocationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + CustomLocationResource customLocation = client.GetCustomLocationResource(customLocationResourceId); + + // get the collection of this ResourceSyncRuleResource + ResourceSyncRuleCollection collection = customLocation.GetResourceSyncRules(); + + // invoke the operation and iterate over the result + await foreach (ResourceSyncRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceSyncRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetCustomLocation() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesGet.json + // this example is just showing the usage of "ResourceSyncRules_Get" 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 CustomLocationResource created on azure + // for more information of creating CustomLocationResource, please refer to the document of CustomLocationResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + ResourceIdentifier customLocationResourceId = CustomLocationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + CustomLocationResource customLocation = client.GetCustomLocationResource(customLocationResourceId); + + // get the collection of this ResourceSyncRuleResource + ResourceSyncRuleCollection collection = customLocation.GetResourceSyncRules(); + + // invoke the operation + string childResourceName = "resourceSyncRule01"; + bool result = await collection.ExistsAsync(childResourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetCustomLocation() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesGet.json + // this example is just showing the usage of "ResourceSyncRules_Get" 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 CustomLocationResource created on azure + // for more information of creating CustomLocationResource, please refer to the document of CustomLocationResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + ResourceIdentifier customLocationResourceId = CustomLocationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + CustomLocationResource customLocation = client.GetCustomLocationResource(customLocationResourceId); + + // get the collection of this ResourceSyncRuleResource + ResourceSyncRuleCollection collection = customLocation.GetResourceSyncRules(); + + // invoke the operation + string childResourceName = "resourceSyncRule01"; + NullableResponse response = await collection.GetIfExistsAsync(childResourceName); + ResourceSyncRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceSyncRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleResource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleResource.cs new file mode 100644 index 000000000000..40f7bc94a5cf --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_ResourceSyncRuleResource.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ExtendedLocations.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.ExtendedLocations.Samples +{ + public partial class Sample_ResourceSyncRuleResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetCustomLocation() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesGet.json + // this example is just showing the usage of "ResourceSyncRules_Get" 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 ResourceSyncRuleResource created on azure + // for more information of creating ResourceSyncRuleResource, please refer to the document of ResourceSyncRuleResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + string childResourceName = "resourceSyncRule01"; + ResourceIdentifier resourceSyncRuleResourceId = ResourceSyncRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, childResourceName); + ResourceSyncRuleResource resourceSyncRule = client.GetResourceSyncRuleResource(resourceSyncRuleResourceId); + + // invoke the operation + ResourceSyncRuleResource result = await resourceSyncRule.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceSyncRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteResourceSyncRule() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesDelete.json + // this example is just showing the usage of "ResourceSyncRules_Delete" 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 ResourceSyncRuleResource created on azure + // for more information of creating ResourceSyncRuleResource, please refer to the document of ResourceSyncRuleResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + string childResourceName = "resourceSyncRule01"; + ResourceIdentifier resourceSyncRuleResourceId = ResourceSyncRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, childResourceName); + ResourceSyncRuleResource resourceSyncRule = client.GetResourceSyncRuleResource(resourceSyncRuleResourceId); + + // invoke the operation + await resourceSyncRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_UpdateResourceSyncRule() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesPatch.json + // this example is just showing the usage of "ResourceSyncRules_Update" 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 ResourceSyncRuleResource created on azure + // for more information of creating ResourceSyncRuleResource, please refer to the document of ResourceSyncRuleResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "testresourcegroup"; + string resourceName = "customLocation01"; + string childResourceName = "resourceSyncRule01"; + ResourceIdentifier resourceSyncRuleResourceId = ResourceSyncRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, childResourceName); + ResourceSyncRuleResource resourceSyncRule = client.GetResourceSyncRuleResource(resourceSyncRuleResourceId); + + // invoke the operation + ResourceSyncRulePatch patch = new ResourceSyncRulePatch + { + Tags = +{ +["tier"] = "testing" +}, + TargetResourceGroup = "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/", + }; + ResourceSyncRuleResource result = await resourceSyncRule.UpdateAsync(patch); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceSyncRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 8326fe5dd005..3cfc03e6318b 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -20,7 +20,7 @@ public partial class Sample_SubscriptionResourceExtensions [Ignore("Only validating compilation of examples")] public async Task GetCustomLocations_ListCustomLocationsBySubscription() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsListBySubscription.json + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListBySubscription.json // this example is just showing the usage of "CustomLocations_ListBySubscription" 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 diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ArmExtendedLocationsModelFactory.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ArmExtendedLocationsModelFactory.cs index 9ebf4de4910b..f9fbd0f47a3c 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ArmExtendedLocationsModelFactory.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ArmExtendedLocationsModelFactory.cs @@ -78,5 +78,64 @@ public static CustomLocationEnabledResourceType CustomLocationEnabledResourceTyp typesMetadata?.ToList(), serializedAdditionalRawData: null); } + + /// Initializes a new instance of . + /// The matching resource sync rule is the particular resource sync rule that matched the match expressions and labels and had lowest priority. This is the rule responsible for mapping the target resource to the target resource group. + /// The target resource group of matching resource sync rule. The labels from the request will be used to find out matching resource sync rule against the selector property of the resource sync rule. The one with highest priority will be returned if there are multiple matching rules. + /// A new instance for mocking. + public static CustomLocationFindTargetResourceGroupResult CustomLocationFindTargetResourceGroupResult(string matchedResourceSyncRule = null, string targetResourceGroup = null) + { + return new CustomLocationFindTargetResourceGroupResult(matchedResourceSyncRule, targetResourceGroup, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Priority represents a priority of the Resource Sync Rule. + /// Provisioning State for the Resource Sync Rule. + /// A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. + /// For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. + /// A new instance for mocking. + public static ResourceSyncRuleData ResourceSyncRuleData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, int? priority = null, string provisioningState = null, ResourceSyncRulePropertiesSelector selector = null, string targetResourceGroup = null) + { + tags ??= new Dictionary(); + + return new ResourceSyncRuleData( + id, + name, + resourceType, + systemData, + tags, + location, + priority, + provisioningState, + selector, + targetResourceGroup, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Resource tags. + /// Priority represents a priority of the Resource Sync Rule. + /// Provisioning State for the Resource Sync Rule. + /// A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. + /// For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. + /// A new instance for mocking. + public static ResourceSyncRulePatch ResourceSyncRulePatch(IDictionary tags = null, int? priority = null, string provisioningState = null, ResourceSyncRulePropertiesSelector selector = null, string targetResourceGroup = null) + { + tags ??= new Dictionary(); + + return new ResourceSyncRulePatch( + tags, + priority, + provisioningState, + selector, + targetResourceGroup, + serializedAdditionalRawData: null); + } } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationCollection.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationCollection.cs index 1aa10cecacb2..82650d1a33a4 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationCollection.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationCollection.cs @@ -65,7 +65,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -114,7 +114,7 @@ public virtual async Task> CreateOrUpdateAs /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -163,7 +163,7 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil wai /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -208,7 +208,7 @@ public virtual async Task> GetAsync(string reso /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -253,7 +253,7 @@ public virtual Response Get(string resourceName, Cancell /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -283,7 +283,7 @@ public virtual AsyncPageable GetAllAsync(CancellationTok /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -313,7 +313,7 @@ public virtual Pageable GetAll(CancellationToken cancell /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -356,7 +356,7 @@ public virtual async Task> ExistsAsync(string resourceName, Cance /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -399,7 +399,7 @@ public virtual Response Exists(string resourceName, CancellationToken canc /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -444,7 +444,7 @@ public virtual async Task> GetIfExistsA /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationResource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationResource.cs index 7396d69568fa..93ded50929cd 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationResource.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/CustomLocationResource.cs @@ -91,6 +91,75 @@ internal static void ValidateResourceId(ResourceIdentifier id) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); } + /// Gets a collection of ResourceSyncRuleResources in the CustomLocation. + /// An object representing collection of ResourceSyncRuleResources and their operations over a ResourceSyncRuleResource. + public virtual ResourceSyncRuleCollection GetResourceSyncRules() + { + return GetCachedClient(client => new ResourceSyncRuleCollection(client, Id)); + } + + /// + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResourceSyncRuleAsync(string childResourceName, CancellationToken cancellationToken = default) + { + return await GetResourceSyncRules().GetAsync(childResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResourceSyncRule(string childResourceName, CancellationToken cancellationToken = default) + { + return GetResourceSyncRules().Get(childResourceName, cancellationToken); + } + /// /// Gets the details of the customLocation with a specified resource group and name. /// @@ -104,7 +173,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -144,7 +213,7 @@ public virtual async Task> GetAsync(Cancellatio /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -184,7 +253,7 @@ public virtual Response Get(CancellationToken cancellati /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -226,7 +295,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -268,7 +337,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -310,7 +379,7 @@ public virtual async Task> UpdateAsync(CustomLo /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -352,7 +421,7 @@ public virtual Response Update(CustomLocationPatch patch /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -382,7 +451,7 @@ public virtual AsyncPageable GetEnabledResour /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -399,6 +468,90 @@ public virtual Pageable GetEnabledResourceTyp return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => CustomLocationEnabledResourceType.DeserializeCustomLocationEnabledResourceType(e), _customLocationClientDiagnostics, Pipeline, "CustomLocationResource.GetEnabledResourceTypes", "value", "nextLink", cancellationToken); } + /// + /// Returns the target resource group associated with the resource sync rules of the Custom Location that match the rules passed in with the Find Target Resource Group Request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/findTargetResourceGroup + /// + /// + /// Operation Id + /// CustomLocations_FindTargetResourceGroup + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Parameters of the find target resource group request. + /// The cancellation token to use. + /// is null. + public virtual async Task> FindTargetResourceGroupAsync(CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(customLocationFindTargetResourceGroupProperties, nameof(customLocationFindTargetResourceGroupProperties)); + + using var scope = _customLocationClientDiagnostics.CreateScope("CustomLocationResource.FindTargetResourceGroup"); + scope.Start(); + try + { + var response = await _customLocationRestClient.FindTargetResourceGroupAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customLocationFindTargetResourceGroupProperties, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the target resource group associated with the resource sync rules of the Custom Location that match the rules passed in with the Find Target Resource Group Request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/findTargetResourceGroup + /// + /// + /// Operation Id + /// CustomLocations_FindTargetResourceGroup + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Parameters of the find target resource group request. + /// The cancellation token to use. + /// is null. + public virtual Response FindTargetResourceGroup(CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(customLocationFindTargetResourceGroupProperties, nameof(customLocationFindTargetResourceGroupProperties)); + + using var scope = _customLocationClientDiagnostics.CreateScope("CustomLocationResource.FindTargetResourceGroup"); + scope.Start(); + try + { + var response = _customLocationRestClient.FindTargetResourceGroup(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, customLocationFindTargetResourceGroupProperties, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// /// Add a tag to the current resource. /// @@ -412,7 +565,7 @@ public virtual Pageable GetEnabledResourceTyp /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -474,7 +627,7 @@ public virtual async Task> AddTagAsync(string k /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -536,7 +689,7 @@ public virtual Response AddTag(string key, string value, /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -593,7 +746,7 @@ public virtual async Task> SetTagsAsync(IDictio /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -650,7 +803,7 @@ public virtual Response SetTags(IDictionary /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -710,7 +863,7 @@ public virtual async Task> RemoveTagAsync(strin /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/ExtendedLocationsExtensions.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/ExtendedLocationsExtensions.cs index cf3a312bec51..27bcb00e522b 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/ExtendedLocationsExtensions.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/ExtendedLocationsExtensions.cs @@ -51,6 +51,25 @@ public static CustomLocationResource GetCustomLocationResource(this ArmClient cl return GetMockableExtendedLocationsArmClient(client).GetCustomLocationResource(id); } + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static ResourceSyncRuleResource GetResourceSyncRuleResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableExtendedLocationsArmClient(client).GetResourceSyncRuleResource(id); + } + /// /// Gets a collection of CustomLocationResources in the ResourceGroupResource. /// @@ -81,7 +100,7 @@ public static CustomLocationCollection GetCustomLocations(this ResourceGroupReso /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -119,7 +138,7 @@ public static async Task> GetCustomLocationAsyn /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -157,7 +176,7 @@ public static Response GetCustomLocation(this ResourceGr /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -193,7 +212,7 @@ public static AsyncPageable GetCustomLocationsAsync(this /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsArmClient.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsArmClient.cs index 7ad774cc9f9e..a8519202c00c 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsArmClient.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsArmClient.cs @@ -45,5 +45,17 @@ public virtual CustomLocationResource GetCustomLocationResource(ResourceIdentifi CustomLocationResource.ValidateResourceId(id); return new CustomLocationResource(Client, id); } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ResourceSyncRuleResource GetResourceSyncRuleResource(ResourceIdentifier id) + { + ResourceSyncRuleResource.ValidateResourceId(id); + return new ResourceSyncRuleResource(Client, id); + } } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsResourceGroupResource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsResourceGroupResource.cs index e19a0bb3accd..471a42239973 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsResourceGroupResource.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsResourceGroupResource.cs @@ -53,7 +53,7 @@ public virtual CustomLocationCollection GetCustomLocations() /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -84,7 +84,7 @@ public virtual async Task> GetCustomLocationAsy /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsSubscriptionResource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsSubscriptionResource.cs index 3eaea8318911..79ca1736a0bc 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsSubscriptionResource.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Extensions/MockableExtendedLocationsSubscriptionResource.cs @@ -52,7 +52,7 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource @@ -82,7 +82,7 @@ public virtual AsyncPageable GetCustomLocationsAsync(Can /// /// /// Default Api Version - /// 2021-08-15 + /// 2021-08-31-preview /// /// /// Resource diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/LongRunningOperation/ResourceSyncRuleOperationSource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/LongRunningOperation/ResourceSyncRuleOperationSource.cs new file mode 100644 index 000000000000..7b767b907aef --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/LongRunningOperation/ResourceSyncRuleOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.ExtendedLocations +{ + internal class ResourceSyncRuleOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ResourceSyncRuleOperationSource(ArmClient client) + { + _client = client; + } + + ResourceSyncRuleResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content); + return new ResourceSyncRuleResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content); + return await Task.FromResult(new ResourceSyncRuleResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupProperties.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupProperties.Serialization.cs new file mode 100644 index 000000000000..b73c964ad256 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupProperties.Serialization.cs @@ -0,0 +1,144 @@ +// 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.ExtendedLocations.Models +{ + public partial class CustomLocationFindTargetResourceGroupProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CustomLocationFindTargetResourceGroupProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Labels)) + { + writer.WritePropertyName("labels"u8); + writer.WriteStartObject(); + foreach (var item in Labels) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CustomLocationFindTargetResourceGroupProperties 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(CustomLocationFindTargetResourceGroupProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomLocationFindTargetResourceGroupProperties(document.RootElement, options); + } + + internal static CustomLocationFindTargetResourceGroupProperties DeserializeCustomLocationFindTargetResourceGroupProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary labels = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("labels"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + labels = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CustomLocationFindTargetResourceGroupProperties(labels ?? new ChangeTrackingDictionary(), 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(CustomLocationFindTargetResourceGroupProperties)} does not support writing '{options.Format}' format."); + } + } + + CustomLocationFindTargetResourceGroupProperties 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCustomLocationFindTargetResourceGroupProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomLocationFindTargetResourceGroupProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationEnabledResourceTypesResult.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupProperties.cs similarity index 63% rename from sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationEnabledResourceTypesResult.cs rename to sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupProperties.cs index a895d61f01d8..eb7f44201464 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationEnabledResourceTypesResult.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupProperties.cs @@ -10,8 +10,8 @@ namespace Azure.ResourceManager.ExtendedLocations.Models { - /// List of EnabledResourceTypes definition. - internal partial class CustomLocationEnabledResourceTypesResult + /// The Find Target Resource Group operation request. + public partial class CustomLocationFindTargetResourceGroupProperties { /// /// Keeps track of any properties unknown to the library. @@ -45,26 +45,22 @@ internal partial class CustomLocationEnabledResourceTypesResult /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - internal CustomLocationEnabledResourceTypesResult() + /// Initializes a new instance of . + public CustomLocationFindTargetResourceGroupProperties() { - Value = new ChangeTrackingList(); + Labels = new ChangeTrackingDictionary(); } - /// Initializes a new instance of . - /// The URL to use for getting the next set of results. - /// The list of EnabledResourceTypes available for a customLocation. + /// Initializes a new instance of . + /// Labels of the custom resource, this is a map of {key,value} pairs. /// Keeps track of any properties unknown to the library. - internal CustomLocationEnabledResourceTypesResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + internal CustomLocationFindTargetResourceGroupProperties(IDictionary labels, IDictionary serializedAdditionalRawData) { - NextLink = nextLink; - Value = value; + Labels = labels; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// The URL to use for getting the next set of results. - public string NextLink { get; } - /// The list of EnabledResourceTypes available for a customLocation. - public IReadOnlyList Value { get; } + /// Labels of the custom resource, this is a map of {key,value} pairs. + public IDictionary Labels { get; } } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.Serialization.cs new file mode 100644 index 000000000000..5c454dce7aac --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.Serialization.cs @@ -0,0 +1,140 @@ +// 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.ExtendedLocations.Models +{ + public partial class CustomLocationFindTargetResourceGroupResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CustomLocationFindTargetResourceGroupResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(MatchedResourceSyncRule)) + { + writer.WritePropertyName("matchedResourceSyncRule"u8); + writer.WriteStringValue(MatchedResourceSyncRule); + } + if (options.Format != "W" && Optional.IsDefined(TargetResourceGroup)) + { + writer.WritePropertyName("targetResourceGroup"u8); + writer.WriteStringValue(TargetResourceGroup); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CustomLocationFindTargetResourceGroupResult 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(CustomLocationFindTargetResourceGroupResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomLocationFindTargetResourceGroupResult(document.RootElement, options); + } + + internal static CustomLocationFindTargetResourceGroupResult DeserializeCustomLocationFindTargetResourceGroupResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string matchedResourceSyncRule = default; + string targetResourceGroup = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("matchedResourceSyncRule"u8)) + { + matchedResourceSyncRule = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetResourceGroup"u8)) + { + targetResourceGroup = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CustomLocationFindTargetResourceGroupResult(matchedResourceSyncRule, targetResourceGroup, 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(CustomLocationFindTargetResourceGroupResult)} does not support writing '{options.Format}' format."); + } + } + + CustomLocationFindTargetResourceGroupResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCustomLocationFindTargetResourceGroupResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomLocationFindTargetResourceGroupResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.cs new file mode 100644 index 000000000000..6adb22236929 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationFindTargetResourceGroupResult.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ExtendedLocations.Models +{ + /// The Find Target Resource Group operation response. + public partial class CustomLocationFindTargetResourceGroupResult + { + /// + /// 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 CustomLocationFindTargetResourceGroupResult() + { + } + + /// Initializes a new instance of . + /// The matching resource sync rule is the particular resource sync rule that matched the match expressions and labels and had lowest priority. This is the rule responsible for mapping the target resource to the target resource group. + /// The target resource group of matching resource sync rule. The labels from the request will be used to find out matching resource sync rule against the selector property of the resource sync rule. The one with highest priority will be returned if there are multiple matching rules. + /// Keeps track of any properties unknown to the library. + internal CustomLocationFindTargetResourceGroupResult(string matchedResourceSyncRule, string targetResourceGroup, IDictionary serializedAdditionalRawData) + { + MatchedResourceSyncRule = matchedResourceSyncRule; + TargetResourceGroup = targetResourceGroup; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The matching resource sync rule is the particular resource sync rule that matched the match expressions and labels and had lowest priority. This is the rule responsible for mapping the target resource to the target resource group. + public string MatchedResourceSyncRule { get; } + /// The target resource group of matching resource sync rule. The labels from the request will be used to find out matching resource sync rule against the selector property of the resource sync rule. The one with highest priority will be returned if there are multiple matching rules. + public string TargetResourceGroup { get; } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.Serialization.cs index 8518440a7814..30cf86ff78c3 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.Serialization.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.Serialization.cs @@ -34,20 +34,17 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(CustomLocationListResult)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(NextLink)) + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) { - writer.WritePropertyName("nextLink"u8); - writer.WriteStringValue(NextLink); + writer.WriteObjectValue(item, options); } - if (options.Format != "W" && Optional.IsCollectionDefined(Value)) + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) { - writer.WritePropertyName("value"u8); - writer.WriteStartArray(); - foreach (var item in Value) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -86,23 +83,14 @@ internal static CustomLocationListResult DeserializeCustomLocationListResult(Jso { return null; } - string nextLink = default; IReadOnlyList value = default; + Uri nextLink = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("nextLink"u8)) - { - nextLink = property.Value.GetString(); - continue; - } if (property.NameEquals("value"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -111,13 +99,22 @@ internal static CustomLocationListResult DeserializeCustomLocationListResult(Jso value = array; continue; } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new CustomLocationListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new CustomLocationListResult(value, nextLink, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.cs index f0326457c6df..38d92b4fe54e 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationListResult.cs @@ -7,10 +7,11 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Azure.ResourceManager.ExtendedLocations.Models { - /// The List Custom Locations operation response. + /// The response of a CustomLocation list operation. internal partial class CustomLocationListResult { /// @@ -46,25 +47,34 @@ internal partial class CustomLocationListResult private IDictionary _serializedAdditionalRawData; /// Initializes a new instance of . - internal CustomLocationListResult() + /// The CustomLocation items on this page. + /// is null. + internal CustomLocationListResult(IEnumerable value) { - Value = new ChangeTrackingList(); + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); } /// Initializes a new instance of . - /// The URL to use for getting the next set of results. - /// The list of Custom Locations. + /// The CustomLocation items on this page. + /// The link to the next page of items. /// Keeps track of any properties unknown to the library. - internal CustomLocationListResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + internal CustomLocationListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) { - NextLink = nextLink; Value = value; + NextLink = nextLink; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// The URL to use for getting the next set of results. - public string NextLink { get; } - /// The list of Custom Locations. + /// Initializes a new instance of for deserialization. + internal CustomLocationListResult() + { + } + + /// The CustomLocation items on this page. public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationEnabledResourceTypesResult.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/EnabledResourceTypeListResult.Serialization.cs similarity index 58% rename from sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationEnabledResourceTypesResult.Serialization.cs rename to sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/EnabledResourceTypeListResult.Serialization.cs index 03db70c24244..30c0d6e4450f 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/CustomLocationEnabledResourceTypesResult.Serialization.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/EnabledResourceTypeListResult.Serialization.cs @@ -13,11 +13,11 @@ namespace Azure.ResourceManager.ExtendedLocations.Models { - internal partial class CustomLocationEnabledResourceTypesResult : IUtf8JsonSerializable, IJsonModel + internal partial class EnabledResourceTypeListResult : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); JsonModelWriteCore(writer, options); @@ -28,26 +28,23 @@ void IJsonModel.Write(Utf8JsonWriter w /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CustomLocationEnabledResourceTypesResult)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(EnabledResourceTypeListResult)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(NextLink)) + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) { - writer.WritePropertyName("nextLink"u8); - writer.WriteStringValue(NextLink); + writer.WriteObjectValue(item, options); } - if (options.Format != "W" && Optional.IsCollectionDefined(Value)) + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) { - writer.WritePropertyName("value"u8); - writer.WriteStartArray(); - foreach (var item in Value) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -66,19 +63,19 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - CustomLocationEnabledResourceTypesResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + EnabledResourceTypeListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CustomLocationEnabledResourceTypesResult)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(EnabledResourceTypeListResult)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCustomLocationEnabledResourceTypesResult(document.RootElement, options); + return DeserializeEnabledResourceTypeListResult(document.RootElement, options); } - internal static CustomLocationEnabledResourceTypesResult DeserializeCustomLocationEnabledResourceTypesResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static EnabledResourceTypeListResult DeserializeEnabledResourceTypeListResult(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -86,23 +83,14 @@ internal static CustomLocationEnabledResourceTypesResult DeserializeCustomLocati { return null; } - string nextLink = default; IReadOnlyList value = default; + Uri nextLink = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("nextLink"u8)) - { - nextLink = property.Value.GetString(); - continue; - } if (property.NameEquals("value"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -111,44 +99,53 @@ internal static CustomLocationEnabledResourceTypesResult DeserializeCustomLocati value = array; continue; } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new CustomLocationEnabledResourceTypesResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new EnabledResourceTypeListResult(value, nextLink, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + 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(CustomLocationEnabledResourceTypesResult)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(EnabledResourceTypeListResult)} does not support writing '{options.Format}' format."); } } - CustomLocationEnabledResourceTypesResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + EnabledResourceTypeListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeCustomLocationEnabledResourceTypesResult(document.RootElement, options); + return DeserializeEnabledResourceTypeListResult(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(CustomLocationEnabledResourceTypesResult)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(EnabledResourceTypeListResult)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/EnabledResourceTypeListResult.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/EnabledResourceTypeListResult.cs new file mode 100644 index 000000000000..1c6566474f91 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/EnabledResourceTypeListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.ExtendedLocations.Models +{ + /// The response of a EnabledResourceType list operation. + internal partial class EnabledResourceTypeListResult + { + /// + /// 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 . + /// The EnabledResourceType items on this page. + /// is null. + internal EnabledResourceTypeListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The EnabledResourceType items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal EnabledResourceTypeListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal EnabledResourceTypeListResult() + { + } + + /// The EnabledResourceType items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.Serialization.cs new file mode 100644 index 000000000000..c1ebf1649c31 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.Serialization.cs @@ -0,0 +1,165 @@ +// 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.ExtendedLocations.Models +{ + public partial class MatchExpressionsProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MatchExpressionsProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Key)) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (Optional.IsDefined(Operator)) + { + writer.WritePropertyName("operator"u8); + writer.WriteStringValue(Operator); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MatchExpressionsProperties 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(MatchExpressionsProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMatchExpressionsProperties(document.RootElement, options); + } + + internal static MatchExpressionsProperties DeserializeMatchExpressionsProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string key = default; + string @operator = default; + IList values = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("key"u8)) + { + key = property.Value.GetString(); + continue; + } + if (property.NameEquals("operator"u8)) + { + @operator = property.Value.GetString(); + continue; + } + if (property.NameEquals("values"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + values = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MatchExpressionsProperties(key, @operator, values ?? new ChangeTrackingList(), 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(MatchExpressionsProperties)} does not support writing '{options.Format}' format."); + } + } + + MatchExpressionsProperties 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMatchExpressionsProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MatchExpressionsProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.cs new file mode 100644 index 000000000000..5ae1fa1218e8 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/MatchExpressionsProperties.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; + +namespace Azure.ResourceManager.ExtendedLocations.Models +{ + /// Resource Sync Rules matchExpression property definition. + public partial class MatchExpressionsProperties + { + /// + /// 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 . + public MatchExpressionsProperties() + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Key is the label key that the selector applies to. + /// The Operator field represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + /// The label value. + /// Keeps track of any properties unknown to the library. + internal MatchExpressionsProperties(string key, string @operator, IList values, IDictionary serializedAdditionalRawData) + { + Key = key; + Operator = @operator; + Values = values; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Key is the label key that the selector applies to. + public string Key { get; set; } + /// The Operator field represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + public string Operator { get; set; } + /// The label value. + public IList Values { get; } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.Serialization.cs new file mode 100644 index 000000000000..88d9786a1a78 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.Serialization.cs @@ -0,0 +1,151 @@ +// 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.ExtendedLocations.Models +{ + internal partial class ResourceSyncRuleListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceSyncRuleListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ResourceSyncRuleListResult 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(ResourceSyncRuleListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceSyncRuleListResult(document.RootElement, options); + } + + internal static ResourceSyncRuleListResult DeserializeResourceSyncRuleListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceSyncRuleData.DeserializeResourceSyncRuleData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceSyncRuleListResult(value, nextLink, 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(ResourceSyncRuleListResult)} does not support writing '{options.Format}' format."); + } + } + + ResourceSyncRuleListResult 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResourceSyncRuleListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceSyncRuleListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.cs new file mode 100644 index 000000000000..0faed2020520 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRuleListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.ExtendedLocations.Models +{ + /// The response of a ResourceSyncRule list operation. + internal partial class ResourceSyncRuleListResult + { + /// + /// 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 . + /// The ResourceSyncRule items on this page. + /// is null. + internal ResourceSyncRuleListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The ResourceSyncRule items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ResourceSyncRuleListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceSyncRuleListResult() + { + } + + /// The ResourceSyncRule items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.Serialization.cs new file mode 100644 index 000000000000..056f36facc75 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.Serialization.cs @@ -0,0 +1,217 @@ +// 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.ExtendedLocations.Models +{ + public partial class ResourceSyncRulePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceSyncRulePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Priority)) + { + writer.WritePropertyName("priority"u8); + writer.WriteNumberValue(Priority.Value); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + if (Optional.IsDefined(Selector)) + { + writer.WritePropertyName("selector"u8); + writer.WriteObjectValue(Selector, options); + } + if (Optional.IsDefined(TargetResourceGroup)) + { + writer.WritePropertyName("targetResourceGroup"u8); + writer.WriteStringValue(TargetResourceGroup); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ResourceSyncRulePatch 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(ResourceSyncRulePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceSyncRulePatch(document.RootElement, options); + } + + internal static ResourceSyncRulePatch DeserializeResourceSyncRulePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + int? priority = default; + string provisioningState = default; + ResourceSyncRulePropertiesSelector selector = default; + string targetResourceGroup = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + 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("priority"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + priority = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + provisioningState = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("selector"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selector = ResourceSyncRulePropertiesSelector.DeserializeResourceSyncRulePropertiesSelector(property0.Value, options); + continue; + } + if (property0.NameEquals("targetResourceGroup"u8)) + { + targetResourceGroup = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceSyncRulePatch( + tags ?? new ChangeTrackingDictionary(), + priority, + provisioningState, + selector, + targetResourceGroup, + 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(ResourceSyncRulePatch)} does not support writing '{options.Format}' format."); + } + } + + ResourceSyncRulePatch 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResourceSyncRulePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceSyncRulePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.cs new file mode 100644 index 000000000000..761becac4938 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePatch.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; + +namespace Azure.ResourceManager.ExtendedLocations.Models +{ + /// The Resource Sync Rules patchable resource definition. + public partial class ResourceSyncRulePatch + { + /// + /// 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 . + public ResourceSyncRulePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// Priority represents a priority of the Resource Sync Rule. + /// Provisioning State for the Resource Sync Rule. + /// A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. + /// For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. + /// Keeps track of any properties unknown to the library. + internal ResourceSyncRulePatch(IDictionary tags, int? priority, string provisioningState, ResourceSyncRulePropertiesSelector selector, string targetResourceGroup, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Priority = priority; + ProvisioningState = provisioningState; + Selector = selector; + TargetResourceGroup = targetResourceGroup; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource tags. + public IDictionary Tags { get; } + /// Priority represents a priority of the Resource Sync Rule. + public int? Priority { get; set; } + /// Provisioning State for the Resource Sync Rule. + public string ProvisioningState { get; } + /// A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. + public ResourceSyncRulePropertiesSelector Selector { get; set; } + /// For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. + public string TargetResourceGroup { get; set; } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.Serialization.cs new file mode 100644 index 000000000000..4b4e101f814f --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.Serialization.cs @@ -0,0 +1,169 @@ +// 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.ExtendedLocations.Models +{ + public partial class ResourceSyncRulePropertiesSelector : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceSyncRulePropertiesSelector)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(MatchExpressions)) + { + writer.WritePropertyName("matchExpressions"u8); + writer.WriteStartArray(); + foreach (var item in MatchExpressions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(MatchLabels)) + { + writer.WritePropertyName("matchLabels"u8); + writer.WriteStartObject(); + foreach (var item in MatchLabels) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ResourceSyncRulePropertiesSelector 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(ResourceSyncRulePropertiesSelector)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceSyncRulePropertiesSelector(document.RootElement, options); + } + + internal static ResourceSyncRulePropertiesSelector DeserializeResourceSyncRulePropertiesSelector(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList matchExpressions = default; + IDictionary matchLabels = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("matchExpressions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MatchExpressionsProperties.DeserializeMatchExpressionsProperties(item, options)); + } + matchExpressions = array; + continue; + } + if (property.NameEquals("matchLabels"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + matchLabels = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceSyncRulePropertiesSelector(matchExpressions ?? new ChangeTrackingList(), matchLabels ?? new ChangeTrackingDictionary(), 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(ResourceSyncRulePropertiesSelector)} does not support writing '{options.Format}' format."); + } + } + + ResourceSyncRulePropertiesSelector 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResourceSyncRulePropertiesSelector(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceSyncRulePropertiesSelector)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.cs new file mode 100644 index 000000000000..af828895a499 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/Models/ResourceSyncRulePropertiesSelector.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ExtendedLocations.Models +{ + /// A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. + public partial class ResourceSyncRulePropertiesSelector + { + /// + /// 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 . + public ResourceSyncRulePropertiesSelector() + { + MatchExpressions = new ChangeTrackingList(); + MatchLabels = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// MatchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. + /// MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. + /// Keeps track of any properties unknown to the library. + internal ResourceSyncRulePropertiesSelector(IList matchExpressions, IDictionary matchLabels, IDictionary serializedAdditionalRawData) + { + MatchExpressions = matchExpressions; + MatchLabels = matchLabels; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// MatchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. + public IList MatchExpressions { get; } + /// MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. + public IDictionary MatchLabels { get; } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleCollection.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleCollection.cs new file mode 100644 index 000000000000..6379e0be640b --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleCollection.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ExtendedLocations +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetResourceSyncRules method from an instance of . + /// + public partial class ResourceSyncRuleCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _resourceSyncRuleClientDiagnostics; + private readonly ResourceSyncRulesRestOperations _resourceSyncRuleRestClient; + + /// Initializes a new instance of the class for mocking. + protected ResourceSyncRuleCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal ResourceSyncRuleCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _resourceSyncRuleClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ExtendedLocations", ResourceSyncRuleResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceSyncRuleResource.ResourceType, out string resourceSyncRuleApiVersion); + _resourceSyncRuleRestClient = new ResourceSyncRulesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceSyncRuleApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CustomLocationResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CustomLocationResource.ResourceType), nameof(id)); + } + + /// + /// Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource Group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Resource Sync Rule name. + /// Parameters supplied to create or update a Resource Sync Rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string childResourceName, ResourceSyncRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _resourceSyncRuleRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, data, cancellationToken).ConfigureAwait(false); + var operation = new ExtendedLocationsArmOperation(new ResourceSyncRuleOperationSource(Client), _resourceSyncRuleClientDiagnostics, Pipeline, _resourceSyncRuleRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource Group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// Resource Sync Rule name. + /// Parameters supplied to create or update a Resource Sync Rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string childResourceName, ResourceSyncRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _resourceSyncRuleRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, data, cancellationToken); + var operation = new ExtendedLocationsArmOperation(new ResourceSyncRuleOperationSource(Client), _resourceSyncRuleClientDiagnostics, Pipeline, _resourceSyncRuleRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.Get"); + scope.Start(); + try + { + var response = await _resourceSyncRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.Get"); + scope.Start(); + try + { + var response = _resourceSyncRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties of each Resource Sync Rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules + /// + /// + /// Operation Id + /// ResourceSyncRules_ListByCustomLocationId + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceSyncRuleRestClient.CreateListByCustomLocationIdRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceSyncRuleRestClient.CreateListByCustomLocationIdNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceSyncRuleResource(Client, ResourceSyncRuleData.DeserializeResourceSyncRuleData(e)), _resourceSyncRuleClientDiagnostics, Pipeline, "ResourceSyncRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties of each Resource Sync Rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules + /// + /// + /// Operation Id + /// ResourceSyncRules_ListByCustomLocationId + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceSyncRuleRestClient.CreateListByCustomLocationIdRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceSyncRuleRestClient.CreateListByCustomLocationIdNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceSyncRuleResource(Client, ResourceSyncRuleData.DeserializeResourceSyncRuleData(e)), _resourceSyncRuleClientDiagnostics, Pipeline, "ResourceSyncRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.Exists"); + scope.Start(); + try + { + var response = await _resourceSyncRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.Exists"); + scope.Start(); + try + { + var response = _resourceSyncRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _resourceSyncRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource Sync Rule name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = _resourceSyncRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, childResourceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.Serialization.cs new file mode 100644 index 000000000000..aadbe3ef66e0 --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.Serialization.cs @@ -0,0 +1,233 @@ +// 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.ExtendedLocations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ExtendedLocations +{ + public partial class ResourceSyncRuleData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceSyncRuleData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Priority)) + { + writer.WritePropertyName("priority"u8); + writer.WriteNumberValue(Priority.Value); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + if (Optional.IsDefined(Selector)) + { + writer.WritePropertyName("selector"u8); + writer.WriteObjectValue(Selector, options); + } + if (Optional.IsDefined(TargetResourceGroup)) + { + writer.WritePropertyName("targetResourceGroup"u8); + writer.WriteStringValue(TargetResourceGroup); + } + writer.WriteEndObject(); + } + + ResourceSyncRuleData 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(ResourceSyncRuleData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceSyncRuleData(document.RootElement, options); + } + + internal static ResourceSyncRuleData DeserializeResourceSyncRuleData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + int? priority = default; + string provisioningState = default; + ResourceSyncRulePropertiesSelector selector = default; + string targetResourceGroup = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + 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("priority"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + priority = property0.Value.GetInt32(); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + provisioningState = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("selector"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selector = ResourceSyncRulePropertiesSelector.DeserializeResourceSyncRulePropertiesSelector(property0.Value, options); + continue; + } + if (property0.NameEquals("targetResourceGroup"u8)) + { + targetResourceGroup = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceSyncRuleData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + priority, + provisioningState, + selector, + targetResourceGroup, + 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(ResourceSyncRuleData)} does not support writing '{options.Format}' format."); + } + } + + ResourceSyncRuleData 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResourceSyncRuleData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceSyncRuleData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.cs new file mode 100644 index 000000000000..3bd9c22265aa --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleData.cs @@ -0,0 +1,95 @@ +// 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.ExtendedLocations.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ExtendedLocations +{ + /// + /// A class representing the ResourceSyncRule data model. + /// Resource Sync Rules definition. + /// + public partial class ResourceSyncRuleData : TrackedResourceData + { + /// + /// 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 . + /// The location. + public ResourceSyncRuleData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Priority represents a priority of the Resource Sync Rule. + /// Provisioning State for the Resource Sync Rule. + /// A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. + /// For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. + /// Keeps track of any properties unknown to the library. + internal ResourceSyncRuleData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, int? priority, string provisioningState, ResourceSyncRulePropertiesSelector selector, string targetResourceGroup, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Priority = priority; + ProvisioningState = provisioningState; + Selector = selector; + TargetResourceGroup = targetResourceGroup; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceSyncRuleData() + { + } + + /// Priority represents a priority of the Resource Sync Rule. + public int? Priority { get; set; } + /// Provisioning State for the Resource Sync Rule. + public string ProvisioningState { get; } + /// A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. + public ResourceSyncRulePropertiesSelector Selector { get; set; } + /// For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. + public string TargetResourceGroup { get; set; } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.Serialization.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.Serialization.cs new file mode 100644 index 000000000000..1d447b3997ae --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.ExtendedLocations +{ + public partial class ResourceSyncRuleResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + ResourceSyncRuleData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + ResourceSyncRuleData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.cs new file mode 100644 index 000000000000..1692d9b8207c --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/ResourceSyncRuleResource.cs @@ -0,0 +1,703 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ExtendedLocations.Models; + +namespace Azure.ResourceManager.ExtendedLocations +{ + /// + /// A Class representing a ResourceSyncRule along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetResourceSyncRuleResource method. + /// Otherwise you can get one from its parent resource using the GetResourceSyncRule method. + /// + public partial class ResourceSyncRuleResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The resourceName. + /// The childResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _resourceSyncRuleClientDiagnostics; + private readonly ResourceSyncRulesRestOperations _resourceSyncRuleRestClient; + private readonly ResourceSyncRuleData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.ExtendedLocation/customLocations/resourceSyncRules"; + + /// Initializes a new instance of the class for mocking. + protected ResourceSyncRuleResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ResourceSyncRuleResource(ArmClient client, ResourceSyncRuleData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal ResourceSyncRuleResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _resourceSyncRuleClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ExtendedLocations", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string resourceSyncRuleApiVersion); + _resourceSyncRuleRestClient = new ResourceSyncRulesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceSyncRuleApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual ResourceSyncRuleData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.Get"); + scope.Start(); + try + { + var response = await _resourceSyncRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.Get"); + scope.Start(); + try + { + var response = _resourceSyncRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location Resource Name, Resource Group, and Subscription Id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Delete + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.Delete"); + scope.Start(); + try + { + var response = await _resourceSyncRuleRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _resourceSyncRuleRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ExtendedLocationsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location Resource Name, Resource Group, and Subscription Id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Delete + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// 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. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.Delete"); + scope.Start(); + try + { + var response = _resourceSyncRuleRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _resourceSyncRuleRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new ExtendedLocationsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, Subscription and Custom Location name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Update + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The updatable fields of an existing Resource Sync Rule. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(ResourceSyncRulePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.Update"); + scope.Start(); + try + { + var response = await _resourceSyncRuleRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, Subscription and Custom Location name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Update + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The updatable fields of an existing Resource Sync Rule. + /// The cancellation token to use. + /// is null. + public virtual Response Update(ResourceSyncRulePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.Update"); + scope.Start(); + try + { + var response = _resourceSyncRuleRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + return Response.FromValue(new ResourceSyncRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _resourceSyncRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ResourceSyncRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new ResourceSyncRulePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _resourceSyncRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new ResourceSyncRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new ResourceSyncRulePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _resourceSyncRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ResourceSyncRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new ResourceSyncRulePatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _resourceSyncRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new ResourceSyncRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new ResourceSyncRulePatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _resourceSyncRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ResourceSyncRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new ResourceSyncRulePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName} + /// + /// + /// Operation Id + /// ResourceSyncRules_Get + /// + /// + /// Default Api Version + /// 2021-08-31-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _resourceSyncRuleClientDiagnostics.CreateScope("ResourceSyncRuleResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _resourceSyncRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new ResourceSyncRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new ResourceSyncRulePatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/CustomLocationsRestOperations.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/CustomLocationsRestOperations.cs index 322e17780353..a3a025bdee9f 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/CustomLocationsRestOperations.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/CustomLocationsRestOperations.cs @@ -32,7 +32,7 @@ public CustomLocationsRestOperations(HttpPipeline pipeline, string applicationId { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2021-08-15"; + _apiVersion = apiVersion ?? "2021-08-31-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } @@ -388,6 +388,106 @@ public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, } } + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Updates a Custom Location with the specified Resource Name in the specified Resource Group and Subscription. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// The updatable fields of an existing Custom Location. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, resourceName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CustomLocationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CustomLocationData.DeserializeCustomLocationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Updates a Custom Location with the specified Resource Name in the specified Resource Group and Subscription. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// The updatable fields of an existing Custom Location. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, resourceName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CustomLocationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CustomLocationData.DeserializeCustomLocationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string resourceName) { var uri = new RawRequestUriBuilder(); @@ -472,7 +572,7 @@ public Response Delete(string subscriptionId, string resourceGroupName, string r } } - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch) + internal RequestUriBuilder CreateListEnabledResourceTypesRequestUri(string subscriptionId, string resourceGroupName, string resourceName) { var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); @@ -482,15 +582,16 @@ internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); uri.AppendPath(resourceName, true); + uri.AppendPath("/enabledResourceTypes", false); uri.AppendQuery("api-version", _apiVersion, true); return uri; } - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch) + internal HttpMessage CreateListEnabledResourceTypesRequest(string subscriptionId, string resourceGroupName, string resourceName) { var message = _pipeline.CreateMessage(); var request = message.Request; - request.Method = RequestMethod.Patch; + request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); @@ -499,41 +600,36 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); uri.AppendPath(resourceName, true); + uri.AppendPath("/enabledResourceTypes", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); - request.Content = content; _userAgent.Apply(message); return message; } - /// Updates a Custom Location with the specified Resource Name in the specified Resource Group and Subscription. + /// Gets the list of the Enabled Resource Types. /// The ID of the target subscription. /// The name of the resource group. The name is case insensitive. /// Custom Locations name. - /// The updatable fields of an existing Custom Location. /// The cancellation token to use. - /// , , or is null. + /// , or is null. /// , or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch, CancellationToken cancellationToken = default) + public async Task> ListEnabledResourceTypesAsync(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNull(patch, nameof(patch)); - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, resourceName, patch); + using var message = CreateListEnabledResourceTypesRequest(subscriptionId, resourceGroupName, resourceName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - CustomLocationData value = default; + EnabledResourceTypeListResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = CustomLocationData.DeserializeCustomLocationData(document.RootElement); + value = EnabledResourceTypeListResult.DeserializeEnabledResourceTypeListResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -541,30 +637,28 @@ public async Task> UpdateAsync(string subscriptionI } } - /// Updates a Custom Location with the specified Resource Name in the specified Resource Group and Subscription. + /// Gets the list of the Enabled Resource Types. /// The ID of the target subscription. /// The name of the resource group. The name is case insensitive. /// Custom Locations name. - /// The updatable fields of an existing Custom Location. /// The cancellation token to use. - /// , , or is null. + /// , or is null. /// , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationPatch patch, CancellationToken cancellationToken = default) + public Response ListEnabledResourceTypes(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); - Argument.AssertNotNull(patch, nameof(patch)); - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, resourceName, patch); + using var message = CreateListEnabledResourceTypesRequest(subscriptionId, resourceGroupName, resourceName); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - CustomLocationData value = default; + EnabledResourceTypeListResult value = default; using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = CustomLocationData.DeserializeCustomLocationData(document.RootElement); + value = EnabledResourceTypeListResult.DeserializeEnabledResourceTypeListResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -572,7 +666,7 @@ public Response Update(string subscriptionId, string resourc } } - internal RequestUriBuilder CreateListEnabledResourceTypesRequestUri(string subscriptionId, string resourceGroupName, string resourceName) + internal RequestUriBuilder CreateFindTargetResourceGroupRequestUri(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties) { var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); @@ -582,16 +676,16 @@ internal RequestUriBuilder CreateListEnabledResourceTypesRequestUri(string subsc uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); uri.AppendPath(resourceName, true); - uri.AppendPath("/enabledResourceTypes", false); + uri.AppendPath("/findTargetResourceGroup", false); uri.AppendQuery("api-version", _apiVersion, true); return uri; } - internal HttpMessage CreateListEnabledResourceTypesRequest(string subscriptionId, string resourceGroupName, string resourceName) + internal HttpMessage CreateFindTargetResourceGroupRequest(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties) { var message = _pipeline.CreateMessage(); var request = message.Request; - request.Method = RequestMethod.Get; + request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); @@ -600,67 +694,79 @@ internal HttpMessage CreateListEnabledResourceTypesRequest(string subscriptionId uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); uri.AppendPath(resourceName, true); - uri.AppendPath("/enabledResourceTypes", false); + uri.AppendPath("/findTargetResourceGroup", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(customLocationFindTargetResourceGroupProperties, ModelSerializationExtensions.WireOptions); + request.Content = content; _userAgent.Apply(message); return message; } - /// Gets the list of the Enabled Resource Types. + /// Returns the target resource group associated with the resource sync rules of the Custom Location that match the rules passed in with the Find Target Resource Group Request. /// The ID of the target subscription. /// The name of the resource group. The name is case insensitive. /// Custom Locations name. + /// Parameters of the find target resource group request. /// The cancellation token to use. - /// , or is null. + /// , , or is null. /// , or is an empty string, and was expected to be non-empty. - public async Task> ListEnabledResourceTypesAsync(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + public async Task> FindTargetResourceGroupAsync(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(customLocationFindTargetResourceGroupProperties, nameof(customLocationFindTargetResourceGroupProperties)); - using var message = CreateListEnabledResourceTypesRequest(subscriptionId, resourceGroupName, resourceName); + using var message = CreateFindTargetResourceGroupRequest(subscriptionId, resourceGroupName, resourceName, customLocationFindTargetResourceGroupProperties); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { - CustomLocationEnabledResourceTypesResult value = default; + CustomLocationFindTargetResourceGroupResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = CustomLocationEnabledResourceTypesResult.DeserializeCustomLocationEnabledResourceTypesResult(document.RootElement); + value = CustomLocationFindTargetResourceGroupResult.DeserializeCustomLocationFindTargetResourceGroupResult(document.RootElement); return Response.FromValue(value, message.Response); } + case 204: + return Response.FromValue((CustomLocationFindTargetResourceGroupResult)null, message.Response); default: throw new RequestFailedException(message.Response); } } - /// Gets the list of the Enabled Resource Types. + /// Returns the target resource group associated with the resource sync rules of the Custom Location that match the rules passed in with the Find Target Resource Group Request. /// The ID of the target subscription. /// The name of the resource group. The name is case insensitive. /// Custom Locations name. + /// Parameters of the find target resource group request. /// The cancellation token to use. - /// , or is null. + /// , , or is null. /// , or is an empty string, and was expected to be non-empty. - public Response ListEnabledResourceTypes(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + public Response FindTargetResourceGroup(string subscriptionId, string resourceGroupName, string resourceName, CustomLocationFindTargetResourceGroupProperties customLocationFindTargetResourceGroupProperties, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNull(customLocationFindTargetResourceGroupProperties, nameof(customLocationFindTargetResourceGroupProperties)); - using var message = CreateListEnabledResourceTypesRequest(subscriptionId, resourceGroupName, resourceName); + using var message = CreateFindTargetResourceGroupRequest(subscriptionId, resourceGroupName, resourceName, customLocationFindTargetResourceGroupProperties); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: { - CustomLocationEnabledResourceTypesResult value = default; + CustomLocationFindTargetResourceGroupResult value = default; using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = CustomLocationEnabledResourceTypesResult.DeserializeCustomLocationEnabledResourceTypesResult(document.RootElement); + value = CustomLocationFindTargetResourceGroupResult.DeserializeCustomLocationFindTargetResourceGroupResult(document.RootElement); return Response.FromValue(value, message.Response); } + case 204: + return Response.FromValue((CustomLocationFindTargetResourceGroupResult)null, message.Response); default: throw new RequestFailedException(message.Response); } @@ -852,7 +958,7 @@ internal HttpMessage CreateListEnabledResourceTypesNextPageRequest(string nextLi /// The cancellation token to use. /// , , or is null. /// , or is an empty string, and was expected to be non-empty. - public async Task> ListEnabledResourceTypesNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + public async Task> ListEnabledResourceTypesNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(nextLink, nameof(nextLink)); Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); @@ -865,9 +971,9 @@ public async Task> ListEnable { case 200: { - CustomLocationEnabledResourceTypesResult value = default; + EnabledResourceTypeListResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = CustomLocationEnabledResourceTypesResult.DeserializeCustomLocationEnabledResourceTypesResult(document.RootElement); + value = EnabledResourceTypeListResult.DeserializeEnabledResourceTypeListResult(document.RootElement); return Response.FromValue(value, message.Response); } default: @@ -883,7 +989,7 @@ public async Task> ListEnable /// The cancellation token to use. /// , , or is null. /// , or is an empty string, and was expected to be non-empty. - public Response ListEnabledResourceTypesNextPage(string nextLink, string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + public Response ListEnabledResourceTypesNextPage(string nextLink, string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(nextLink, nameof(nextLink)); Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); @@ -896,9 +1002,9 @@ public Response ListEnabledResourceTyp { case 200: { - CustomLocationEnabledResourceTypesResult value = default; + EnabledResourceTypeListResult value = default; using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = CustomLocationEnabledResourceTypesResult.DeserializeCustomLocationEnabledResourceTypesResult(document.RootElement); + value = EnabledResourceTypeListResult.DeserializeEnabledResourceTypeListResult(document.RootElement); return Response.FromValue(value, message.Response); } default: diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/ResourceSyncRulesRestOperations.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/ResourceSyncRulesRestOperations.cs new file mode 100644 index 000000000000..d924dcd1543f --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/Generated/RestOperations/ResourceSyncRulesRestOperations.cs @@ -0,0 +1,621 @@ +// 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.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ExtendedLocations.Models; + +namespace Azure.ResourceManager.ExtendedLocations +{ + internal partial class ResourceSyncRulesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ResourceSyncRulesRestOperations. + /// 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 ResourceSyncRulesRestOperations(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-08-31-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListByCustomLocationIdRequestUri(string subscriptionId, string resourceGroupName, string resourceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByCustomLocationIdRequest(string subscriptionId, string resourceGroupName, string resourceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties of each Resource Sync Rule. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCustomLocationIdAsync(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateListByCustomLocationIdRequest(subscriptionId, resourceGroupName, resourceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceSyncRuleListResult.DeserializeResourceSyncRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties of each Resource Sync Rule. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCustomLocationId(string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateListByCustomLocationIdRequest(subscriptionId, resourceGroupName, resourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceSyncRuleListResult.DeserializeResourceSyncRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, resourceName, childResourceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceSyncRuleData.DeserializeResourceSyncRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ResourceSyncRuleData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource name and Resource Sync Rule name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, resourceName, childResourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceSyncRuleData.DeserializeResourceSyncRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ResourceSyncRuleData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRuleData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRuleData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource Group. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// Parameters supplied to create or update a Resource Sync Rule. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, resourceName, childResourceName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource Group. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// Parameters supplied to create or update a Resource Sync Rule. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, resourceName, childResourceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRulePatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRulePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, Subscription and Custom Location name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// The updatable fields of an existing Resource Sync Rule. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRulePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, resourceName, childResourceName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceSyncRuleData.DeserializeResourceSyncRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, Subscription and Custom Location name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// The updatable fields of an existing Resource Sync Rule. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, ResourceSyncRulePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, resourceName, childResourceName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceSyncRuleData.DeserializeResourceSyncRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.ExtendedLocation/customLocations/", false); + uri.AppendPath(resourceName, true); + uri.AppendPath("/resourceSyncRules/", false); + uri.AppendPath(childResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location Resource Name, Resource Group, and Subscription Id. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, resourceName, childResourceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location Resource Name, Resource Group, and Subscription Id. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// Resource Sync Rule name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string resourceName, string childResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + Argument.AssertNotNullOrEmpty(childResourceName, nameof(childResourceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, resourceName, childResourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByCustomLocationIdNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string resourceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByCustomLocationIdNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string resourceName) + { + 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; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties of each Resource Sync Rule. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCustomLocationIdNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateListByCustomLocationIdNextPageRequest(nextLink, subscriptionId, resourceGroupName, resourceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceSyncRuleListResult.DeserializeResourceSyncRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties of each Resource Sync Rule. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Custom Locations name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCustomLocationIdNextPage(string nextLink, string subscriptionId, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName)); + + using var message = CreateListByCustomLocationIdNextPageRequest(nextLink, subscriptionId, resourceGroupName, resourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceSyncRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceSyncRuleListResult.DeserializeResourceSyncRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/autorest.md b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/autorest.md index eb2f85754d75..aea1b6d6f5a8 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/autorest.md +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/src/autorest.md @@ -8,7 +8,7 @@ azure-arm: true csharp: true library-name: ExtendedLocations namespace: Azure.ResourceManager.ExtendedLocations -require: https://github.com/Azure/azure-rest-api-specs/blob/691920cda83cc0b89a8c821d0bb285100fad22b4/specification/extendedlocation/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/extendedlocation/resource-manager/readme.md output-folder: $(this-folder)/Generated clear-output-folder: true sample-gen: diff --git a/sdk/storage/ci.yml b/sdk/storage/ci.yml index 2ca0501b60bd..4e749e6b85b1 100644 --- a/sdk/storage/ci.yml +++ b/sdk/storage/ci.yml @@ -12,6 +12,8 @@ trigger: - sdk/storage/Azure.Storage.DataMovement/ - sdk/storage/Azure.Storage.DataMovement.Blobs/ - sdk/storage/Azure.Storage.DataMovement.Files/ + exclude: + - sdk/storage/Azure.ResourceManager.Storage/ - sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/ exclude: - sdk/storage/Azure.ResourceManager.Storage/