diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs index 5e1600391fc8d..c67f6ddd35a81 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs @@ -54,6 +54,7 @@ public CognitiveServicesAccountDeploymentData() { } public Azure.ETag? ETag { get { throw null; } } public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku Sku { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData 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.CognitiveServices.CognitiveServicesAccountDeploymentData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -66,18 +67,26 @@ public partial class CognitiveServicesAccountDeploymentResource : Azure.Resource protected CognitiveServicesAccountDeploymentResource() { } public virtual Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData 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 accountName, string deploymentName) { 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.Pageable GetSkus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetSkusAsync(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.CognitiveServices.CognitiveServicesAccountDeploymentData 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.CognitiveServices.CognitiveServicesAccountDeploymentData 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.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.Models.PatchResourceTagsAndSku deployment, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.Models.PatchResourceTagsAndSku deployment, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class CognitiveServicesAccountResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -101,12 +110,27 @@ protected CognitiveServicesAccountResource() { } public virtual Azure.Response GetCommitmentPlan(string commitmentPlanName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetCommitmentPlanAsync(string commitmentPlanName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.CognitiveServices.CommitmentPlanCollection GetCommitmentPlans() { throw null; } + public virtual Azure.Response GetDefenderForAISetting(string defenderForAISettingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetDefenderForAISettingAsync(string defenderForAISettingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.DefenderForAISettingCollection GetDefenderForAISettings() { throw null; } + public virtual Azure.Response GetEncryptionScope(string encryptionScopeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetEncryptionScopeAsync(string encryptionScopeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.EncryptionScopeCollection GetEncryptionScopes() { throw null; } public virtual Azure.Response GetKeys(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetKeysAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetModels(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetModelsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetNetworkSecurityPerimeterConfiguration(string nspConfigurationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetNetworkSecurityPerimeterConfigurationAsync(string nspConfigurationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.NetworkSecurityPerimeterConfigurationCollection GetNetworkSecurityPerimeterConfigurations() { throw null; } public virtual Azure.Pageable GetPrivateLinkResources(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetPrivateLinkResourcesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetRaiBlocklist(string raiBlocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetRaiBlocklistAsync(string raiBlocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiBlocklistCollection GetRaiBlocklists() { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiPolicyCollection GetRaiPolicies() { throw null; } + public virtual Azure.Response GetRaiPolicy(string raiPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetRaiPolicyAsync(string raiPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetSkus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetSkusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetUsages(string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -167,8 +191,8 @@ protected CognitiveServicesCommitmentPlanResource() { } Azure.ResourceManager.CognitiveServices.CommitmentPlanData 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.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCommitmentPlanPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCommitmentPlanPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.Models.PatchResourceTagsAndSku commitmentPlan, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.Models.PatchResourceTagsAndSku commitmentPlan, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class CognitiveServicesDeletedAccountCollection : Azure.ResourceManager.ArmCollection { @@ -217,6 +241,8 @@ protected CognitiveServicesDeletedAccountResource() { } } public static partial class CognitiveServicesExtensions { + public static Azure.Response CalculateModelCapacity(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityParameter calculateModelCapacityParameter, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CalculateModelCapacityAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityParameter calculateModelCapacityParameter, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Response CheckDomainAvailability(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesDomainAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> CheckDomainAvailabilityAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesDomainAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Pageable CheckSkuAvailability(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -243,10 +269,24 @@ public static partial class CognitiveServicesExtensions public static Azure.ResourceManager.CognitiveServices.CommitmentPlanResource GetCommitmentPlanResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Pageable GetCommitmentTiers(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetCommitmentTiersAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.CognitiveServices.DefenderForAISettingResource GetDefenderForAISettingResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Pageable GetDeletedAccounts(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetDeletedAccountsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.CognitiveServices.EncryptionScopeResource GetEncryptionScopeResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.Pageable GetLocationBasedModelCapacities(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetLocationBasedModelCapacitiesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetModelCapacities(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetModelCapacitiesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Pageable GetModels(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetModelsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.CognitiveServices.NetworkSecurityPerimeterConfigurationResource GetNetworkSecurityPerimeterConfigurationResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiBlocklistItemResource GetRaiBlocklistItemResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiBlocklistResource GetRaiBlocklistResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.Response GetRaiContentFilter(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, string filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetRaiContentFilterAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, string filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiContentFilterResource GetRaiContentFilterResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiContentFilterCollection GetRaiContentFilters(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiPolicyResource GetRaiPolicyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Pageable GetResourceSkus(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetResourceSkusAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.Pageable GetUsages(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.Core.AzureLocation location, string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -321,6 +361,7 @@ public partial class CommitmentPlanAccountAssociationData : Azure.ResourceManage public CommitmentPlanAccountAssociationData() { } public string AccountId { get { throw null; } set { } } public Azure.ETag? ETag { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } Azure.ResourceManager.CognitiveServices.CommitmentPlanAccountAssociationData 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.CognitiveServices.CommitmentPlanAccountAssociationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -333,11 +374,17 @@ public partial class CommitmentPlanAccountAssociationResource : Azure.ResourceMa protected CommitmentPlanAccountAssociationResource() { } public virtual Azure.ResourceManager.CognitiveServices.CommitmentPlanAccountAssociationData 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 commitmentPlanName, string commitmentPlanAssociationName) { 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.CognitiveServices.CommitmentPlanAccountAssociationData 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.CognitiveServices.CommitmentPlanAccountAssociationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -403,6 +450,363 @@ protected CommitmentPlanResource() { } public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.CommitmentPlanData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.CommitmentPlanData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + public partial class DefenderForAISettingCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected DefenderForAISettingCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string defenderForAISettingName, Azure.ResourceManager.CognitiveServices.DefenderForAISettingData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string defenderForAISettingName, Azure.ResourceManager.CognitiveServices.DefenderForAISettingData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string defenderForAISettingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string defenderForAISettingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string defenderForAISettingName, 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 defenderForAISettingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string defenderForAISettingName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string defenderForAISettingName, 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 DefenderForAISettingData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public DefenderForAISettingData() { } + public Azure.ETag? ETag { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState? State { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.CognitiveServices.DefenderForAISettingData 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.CognitiveServices.DefenderForAISettingData 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 DefenderForAISettingResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected DefenderForAISettingResource() { } + public virtual Azure.ResourceManager.CognitiveServices.DefenderForAISettingData 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 accountName, string defenderForAISettingName) { 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.CognitiveServices.DefenderForAISettingData 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.CognitiveServices.DefenderForAISettingData 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.CognitiveServices.DefenderForAISettingData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.CognitiveServices.DefenderForAISettingData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class EncryptionScopeCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected EncryptionScopeCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string encryptionScopeName, Azure.ResourceManager.CognitiveServices.EncryptionScopeData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string encryptionScopeName, Azure.ResourceManager.CognitiveServices.EncryptionScopeData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string encryptionScopeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string encryptionScopeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string encryptionScopeName, 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 encryptionScopeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string encryptionScopeName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string encryptionScopeName, 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 EncryptionScopeData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EncryptionScopeData() { } + public Azure.ETag? ETag { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProperties Properties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.CognitiveServices.EncryptionScopeData 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.CognitiveServices.EncryptionScopeData 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 EncryptionScopeResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected EncryptionScopeResource() { } + public virtual Azure.ResourceManager.CognitiveServices.EncryptionScopeData 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 accountName, string encryptionScopeName) { 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.CognitiveServices.EncryptionScopeData 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.CognitiveServices.EncryptionScopeData 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.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.EncryptionScopeData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.EncryptionScopeData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class NetworkSecurityPerimeterConfigurationCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected NetworkSecurityPerimeterConfigurationCollection() { } + public virtual Azure.Response Exists(string nspConfigurationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string nspConfigurationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string nspConfigurationName, 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 nspConfigurationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string nspConfigurationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string nspConfigurationName, 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 NetworkSecurityPerimeterConfigurationData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public NetworkSecurityPerimeterConfigurationData() { } + public Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationProperties Properties { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.NetworkSecurityPerimeterConfigurationData 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.CognitiveServices.NetworkSecurityPerimeterConfigurationData 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 NetworkSecurityPerimeterConfigurationResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected NetworkSecurityPerimeterConfigurationResource() { } + public virtual Azure.ResourceManager.CognitiveServices.NetworkSecurityPerimeterConfigurationData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName) { 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.ResourceManager.ArmOperation Reconcile(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ReconcileAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.CognitiveServices.NetworkSecurityPerimeterConfigurationData 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.CognitiveServices.NetworkSecurityPerimeterConfigurationData 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 RaiBlocklistCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected RaiBlocklistCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string raiBlocklistName, Azure.ResourceManager.CognitiveServices.RaiBlocklistData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string raiBlocklistName, Azure.ResourceManager.CognitiveServices.RaiBlocklistData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string raiBlocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string raiBlocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string raiBlocklistName, 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 raiBlocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string raiBlocklistName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string raiBlocklistName, 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 RaiBlocklistData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiBlocklistData() { } + public Azure.ETag? ETag { get { throw null; } } + public string RaiBlocklistDescription { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.CognitiveServices.RaiBlocklistData 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.CognitiveServices.RaiBlocklistData 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 RaiBlocklistItemCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected RaiBlocklistItemCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string raiBlocklistItemName, Azure.ResourceManager.CognitiveServices.RaiBlocklistItemData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string raiBlocklistItemName, Azure.ResourceManager.CognitiveServices.RaiBlocklistItemData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string raiBlocklistItemName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string raiBlocklistItemName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string raiBlocklistItemName, 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 raiBlocklistItemName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string raiBlocklistItemName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string raiBlocklistItemName, 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 RaiBlocklistItemData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiBlocklistItemData() { } + public Azure.ETag? ETag { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.RaiBlocklistItemProperties Properties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.CognitiveServices.RaiBlocklistItemData 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.CognitiveServices.RaiBlocklistItemData 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 RaiBlocklistItemResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected RaiBlocklistItemResource() { } + public virtual Azure.ResourceManager.CognitiveServices.RaiBlocklistItemData 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 accountName, string raiBlocklistName, string raiBlocklistItemName) { 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.CognitiveServices.RaiBlocklistItemData 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.CognitiveServices.RaiBlocklistItemData 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.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.RaiBlocklistItemData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.RaiBlocklistItemData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class RaiBlocklistResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected RaiBlocklistResource() { } + public virtual Azure.ResourceManager.CognitiveServices.RaiBlocklistData 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 virtual Azure.Response BatchAddRaiBlocklistItem(System.Collections.Generic.IEnumerable content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> BatchAddRaiBlocklistItemAsync(System.Collections.Generic.IEnumerable content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response BatchDeleteRaiBlocklistItem(System.BinaryData raiBlocklistItemsNames, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task BatchDeleteRaiBlocklistItemAsync(System.BinaryData raiBlocklistItemsNames, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) { 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 GetRaiBlocklistItem(string raiBlocklistItemName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetRaiBlocklistItemAsync(string raiBlocklistItemName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiBlocklistItemCollection GetRaiBlocklistItems() { 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.CognitiveServices.RaiBlocklistData 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.CognitiveServices.RaiBlocklistData 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.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.RaiBlocklistData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.RaiBlocklistData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class RaiContentFilterCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected RaiContentFilterCollection() { } + public virtual Azure.Response Exists(string filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string filterName, 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 filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string filterName, 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 RaiContentFilterData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiContentFilterData() { } + public Azure.ResourceManager.CognitiveServices.Models.RaiContentFilterProperties Properties { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.RaiContentFilterData 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.CognitiveServices.RaiContentFilterData 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 RaiContentFilterResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected RaiContentFilterResource() { } + public virtual Azure.ResourceManager.CognitiveServices.RaiContentFilterData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, Azure.Core.AzureLocation location, string filterName) { 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; } + Azure.ResourceManager.CognitiveServices.RaiContentFilterData 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.CognitiveServices.RaiContentFilterData 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 RaiPolicyCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected RaiPolicyCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string raiPolicyName, Azure.ResourceManager.CognitiveServices.RaiPolicyData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string raiPolicyName, Azure.ResourceManager.CognitiveServices.RaiPolicyData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string raiPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string raiPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string raiPolicyName, 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 raiPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string raiPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string raiPolicyName, 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 RaiPolicyData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiPolicyData() { } + public Azure.ETag? ETag { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.RaiPolicyProperties Properties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + Azure.ResourceManager.CognitiveServices.RaiPolicyData 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.CognitiveServices.RaiPolicyData 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 RaiPolicyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected RaiPolicyResource() { } + public virtual Azure.ResourceManager.CognitiveServices.RaiPolicyData 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 accountName, string raiPolicyName) { 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.CognitiveServices.RaiPolicyData 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.CognitiveServices.RaiPolicyData 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.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.RaiPolicyData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.CognitiveServices.RaiPolicyData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } } namespace Azure.ResourceManager.CognitiveServices.Mocking { @@ -416,6 +820,13 @@ protected MockableCognitiveServicesArmClient() { } public virtual Azure.ResourceManager.CognitiveServices.CognitiveServicesPrivateEndpointConnectionResource GetCognitiveServicesPrivateEndpointConnectionResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.CognitiveServices.CommitmentPlanAccountAssociationResource GetCommitmentPlanAccountAssociationResource(Azure.Core.ResourceIdentifier id) { throw null; } public virtual Azure.ResourceManager.CognitiveServices.CommitmentPlanResource GetCommitmentPlanResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.DefenderForAISettingResource GetDefenderForAISettingResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.EncryptionScopeResource GetEncryptionScopeResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.NetworkSecurityPerimeterConfigurationResource GetNetworkSecurityPerimeterConfigurationResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiBlocklistItemResource GetRaiBlocklistItemResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiBlocklistResource GetRaiBlocklistResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiContentFilterResource GetRaiContentFilterResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiPolicyResource GetRaiPolicyResource(Azure.Core.ResourceIdentifier id) { throw null; } } public partial class MockableCognitiveServicesResourceGroupResource : Azure.ResourceManager.ArmResource { @@ -430,6 +841,8 @@ protected MockableCognitiveServicesResourceGroupResource() { } public partial class MockableCognitiveServicesSubscriptionResource : Azure.ResourceManager.ArmResource { protected MockableCognitiveServicesSubscriptionResource() { } + public virtual Azure.Response CalculateModelCapacity(Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityParameter calculateModelCapacityParameter, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CalculateModelCapacityAsync(Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityParameter calculateModelCapacityParameter, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response CheckDomainAvailability(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesDomainAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CheckDomainAvailabilityAsync(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesDomainAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable CheckSkuAvailability(Azure.Core.AzureLocation location, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -445,8 +858,15 @@ protected MockableCognitiveServicesSubscriptionResource() { } public virtual Azure.AsyncPageable GetCommitmentTiersAsync(Azure.Core.AzureLocation location, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetDeletedAccounts(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetDeletedAccountsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetLocationBasedModelCapacities(Azure.Core.AzureLocation location, string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetLocationBasedModelCapacitiesAsync(Azure.Core.AzureLocation location, string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetModelCapacities(string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetModelCapacitiesAsync(string modelFormat, string modelName, string modelVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetModels(Azure.Core.AzureLocation location, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetModelsAsync(Azure.Core.AzureLocation location, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetRaiContentFilter(Azure.Core.AzureLocation location, string filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetRaiContentFilterAsync(Azure.Core.AzureLocation location, string filterName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.CognitiveServices.RaiContentFilterCollection GetRaiContentFilters(Azure.Core.AzureLocation location) { throw null; } public virtual Azure.Pageable GetResourceSkus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetResourceSkusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetUsages(Azure.Core.AzureLocation location, string filter = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -489,18 +909,30 @@ public static partial class ArmCognitiveServicesModelFactory { public static Azure.ResourceManager.CognitiveServices.Models.AbusePenalty AbusePenalty(Azure.ResourceManager.CognitiveServices.Models.AbusePenaltyAction? action = default(Azure.ResourceManager.CognitiveServices.Models.AbusePenaltyAction?), float? rateLimitPercentage = default(float?), System.DateTimeOffset? expiration = default(System.DateTimeOffset?)) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.AvailableCognitiveServicesSku AvailableCognitiveServicesSku(string resourceType = null, string name = null, string tier = null, string kind = null, System.Collections.Generic.IEnumerable locations = null, System.Collections.Generic.IEnumerable restrictions = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityResult CalculateModelCapacityResult(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel model = null, string skuName = null, Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityResultEstimatedCapacity estimatedCapacity = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityResultEstimatedCapacity CalculateModelCapacityResultEstimatedCapacity(int? value = default(int?), int? deployableValue = default(int?)) { throw null; } public static Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountData CognitiveServicesAccountData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), string kind = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku sku = null, Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountProperties properties = null, Azure.ETag? etag = default(Azure.ETag?)) { throw null; } - public static Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData CognitiveServicesAccountDeploymentData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku sku = null, Azure.ETag? etag = default(Azure.ETag?), Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProperties properties = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData CognitiveServicesAccountDeploymentData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku sku, Azure.ETag? etag, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProperties properties) { throw null; } + public static Azure.ResourceManager.CognitiveServices.CognitiveServicesAccountDeploymentData CognitiveServicesAccountDeploymentData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku sku = null, Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProperties properties = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel CognitiveServicesAccountDeploymentModel(string format = null, string name = null, string version = null, string source = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit = null) { throw null; } - public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProperties CognitiveServicesAccountDeploymentProperties(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProvisioningState? provisioningState = default(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProvisioningState?), Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel model = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentScaleSettings scaleSettings = null, System.Collections.Generic.IReadOnlyDictionary capabilities = null, string raiPolicyName = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit = null, System.Collections.Generic.IEnumerable rateLimits = null, Azure.ResourceManager.CognitiveServices.Models.DeploymentModelVersionUpgradeOption? versionUpgradeOption = default(Azure.ResourceManager.CognitiveServices.Models.DeploymentModelVersionUpgradeOption?)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProperties CognitiveServicesAccountDeploymentProperties(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProvisioningState? provisioningState, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel model, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentScaleSettings scaleSettings, System.Collections.Generic.IReadOnlyDictionary capabilities, string raiPolicyName, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit, System.Collections.Generic.IEnumerable rateLimits, Azure.ResourceManager.CognitiveServices.Models.DeploymentModelVersionUpgradeOption? versionUpgradeOption) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProperties CognitiveServicesAccountDeploymentProperties(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProvisioningState? provisioningState = default(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProvisioningState?), Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel model = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentScaleSettings scaleSettings = null, System.Collections.Generic.IReadOnlyDictionary capabilities = null, string raiPolicyName = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit = null, System.Collections.Generic.IEnumerable rateLimits = null, Azure.ResourceManager.CognitiveServices.Models.DeploymentModelVersionUpgradeOption? versionUpgradeOption = default(Azure.ResourceManager.CognitiveServices.Models.DeploymentModelVersionUpgradeOption?), bool? dynamicThrottlingEnabled = default(bool?), int? currentCapacity = default(int?), Azure.ResourceManager.CognitiveServices.Models.DeploymentCapacitySettings capacitySettings = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentScaleSettings CognitiveServicesAccountDeploymentScaleSettings(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentScaleType? scaleType = default(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentScaleType?), int? capacity = default(int?), int? activeCapacity = default(int?)) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountModel CognitiveServicesAccountModel(string format = null, string name = null, string version = null, string source = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel baseModel = null, bool? isDefaultVersion = default(bool?), System.Collections.Generic.IEnumerable skus = null, int? maxCapacity = default(int?), System.Collections.Generic.IDictionary capabilities = null, System.Collections.Generic.IDictionary finetuneCapabilities = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountModelDeprecationInfo deprecation = null, Azure.ResourceManager.CognitiveServices.Models.ModelLifecycleStatus? lifecycleStatus = default(Azure.ResourceManager.CognitiveServices.Models.ModelLifecycleStatus?), Azure.ResourceManager.Models.SystemData systemData = null) { throw null; } - public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountProperties CognitiveServicesAccountProperties(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountProvisioningState? provisioningState = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountProvisioningState?), string endpoint = null, System.Collections.Generic.IEnumerable capabilities = null, bool? isMigrated = default(bool?), string migrationToken = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuChangeInfo skuChangeInfo = null, string customSubDomainName = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesNetworkRuleSet networkAcls = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountEncryptionProperties encryption = null, System.Collections.Generic.IEnumerable userOwnedStorage = null, System.Collections.Generic.IEnumerable privateEndpointConnections = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountPublicNetworkAccess? publicNetworkAccess = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountPublicNetworkAccess?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountApiProperties apiProperties = null, System.DateTimeOffset? createdOn = default(System.DateTimeOffset?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit = null, bool? enableDynamicThrottling = default(bool?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountQuotaLimit quotaLimit = null, bool? restrictOutboundNetworkAccess = default(bool?), System.Collections.Generic.IEnumerable allowedFqdnList = null, bool? disableLocalAuth = default(bool?), System.Collections.Generic.IReadOnlyDictionary endpoints = null, bool? restore = default(bool?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), string scheduledPurgeDate = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesMultiRegionSettings locations = null, System.Collections.Generic.IEnumerable commitmentPlanAssociations = null, Azure.ResourceManager.CognitiveServices.Models.AbusePenalty abusePenalty = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountProperties CognitiveServicesAccountProperties(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountProvisioningState? provisioningState = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountProvisioningState?), string endpoint = null, System.Collections.Generic.IEnumerable capabilities = null, bool? isMigrated = default(bool?), string migrationToken = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuChangeInfo skuChangeInfo = null, string customSubDomainName = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesNetworkRuleSet networkAcls = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountEncryptionProperties encryption = null, System.Collections.Generic.IEnumerable userOwnedStorage = null, Azure.ResourceManager.CognitiveServices.Models.UserOwnedAmlWorkspace amlWorkspace = null, System.Collections.Generic.IEnumerable privateEndpointConnections = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountPublicNetworkAccess? publicNetworkAccess = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountPublicNetworkAccess?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountApiProperties apiProperties = null, System.DateTimeOffset? createdOn = default(System.DateTimeOffset?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit = null, bool? enableDynamicThrottling = default(bool?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountQuotaLimit quotaLimit = null, bool? restrictOutboundNetworkAccess = default(bool?), System.Collections.Generic.IEnumerable allowedFqdnList = null, bool? disableLocalAuth = default(bool?), System.Collections.Generic.IReadOnlyDictionary endpoints = null, bool? restore = default(bool?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), string scheduledPurgeDate = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesMultiRegionSettings locations = null, System.Collections.Generic.IEnumerable commitmentPlanAssociations = null, Azure.ResourceManager.CognitiveServices.Models.AbusePenalty abusePenalty = null, Azure.ResourceManager.CognitiveServices.Models.RaiMonitorConfig raiMonitorConfig = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountProperties CognitiveServicesAccountProperties(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountProvisioningState? provisioningState, string endpoint, System.Collections.Generic.IEnumerable capabilities, bool? isMigrated, string migrationToken, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuChangeInfo skuChangeInfo, string customSubDomainName, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesNetworkRuleSet networkAcls, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountEncryptionProperties encryption, System.Collections.Generic.IEnumerable userOwnedStorage, System.Collections.Generic.IEnumerable privateEndpointConnections, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountPublicNetworkAccess? publicNetworkAccess, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountApiProperties apiProperties, System.DateTimeOffset? createdOn, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit callRateLimit, bool? enableDynamicThrottling, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountQuotaLimit quotaLimit, bool? restrictOutboundNetworkAccess, System.Collections.Generic.IEnumerable allowedFqdnList, bool? disableLocalAuth, System.Collections.Generic.IReadOnlyDictionary endpoints, bool? restore, System.DateTimeOffset? deletedOn, string scheduledPurgeDate, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesMultiRegionSettings locations, System.Collections.Generic.IEnumerable commitmentPlanAssociations, Azure.ResourceManager.CognitiveServices.Models.AbusePenalty abusePenalty) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountSku CognitiveServicesAccountSku(Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku sku = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesDomainAvailabilityContent CognitiveServicesDomainAvailabilityContent(string subdomainName = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), string kind = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesDomainAvailabilityList CognitiveServicesDomainAvailabilityList(bool? isSubdomainAvailable = default(bool?), string reason = null, string subdomainName = null, string domainAvailabilityType = null, string kind = null) { throw null; } - public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesModel CognitiveServicesModel(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountModel model = null, string kind = null, string skuName = null) { throw null; } - public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesModelSku CognitiveServicesModelSku(string name = null, string usageName = null, System.DateTimeOffset? deprecationOn = default(System.DateTimeOffset?), Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCapacityConfig capacity = null, System.Collections.Generic.IEnumerable rateLimits = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesModel CognitiveServicesModel(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountModel model, string kind, string skuName) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesModel CognitiveServicesModel(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountModel model = null, string kind = null, string skuName = null, string description = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesModelSku CognitiveServicesModelSku(string name, string usageName, System.DateTimeOffset? deprecationOn, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCapacityConfig capacity, System.Collections.Generic.IEnumerable rateLimits) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesModelSku CognitiveServicesModelSku(string name = null, string usageName = null, System.DateTimeOffset? deprecationOn = default(System.DateTimeOffset?), Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCapacityConfig capacity = null, System.Collections.Generic.IEnumerable rateLimits = null, System.Collections.Generic.IEnumerable cost = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.CognitiveServicesPrivateEndpointConnectionData CognitiveServicesPrivateEndpointConnectionData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Core.ResourceIdentifier privateEndpointId = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPrivateLinkServiceConnectionState connectionState = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPrivateEndpointConnectionProvisioningState? provisioningState = default(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPrivateEndpointConnectionProvisioningState?), System.Collections.Generic.IEnumerable groupIds = null, Azure.ETag? etag = default(Azure.ETag?)) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPrivateLinkResource CognitiveServicesPrivateLinkResource(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPrivateLinkResourceProperties properties = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPrivateLinkResourceProperties CognitiveServicesPrivateLinkResourceProperties(string groupId = null, System.Collections.Generic.IEnumerable requiredMembers = null, System.Collections.Generic.IEnumerable requiredZoneNames = null, string displayName = null) { throw null; } @@ -511,12 +943,25 @@ public static partial class ArmCognitiveServicesModelFactory public static Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuRestrictions CognitiveServicesSkuRestrictions(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuRestrictionsType? restrictionsType = default(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuRestrictionsType?), System.Collections.Generic.IEnumerable values = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuRestrictionInfo restrictionInfo = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuRestrictionReasonCode? reasonCode = default(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSkuRestrictionReasonCode?)) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CommitmentCost CommitmentCost(string commitmentMeterId = null, string overageMeterId = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CommitmentPeriod CommitmentPeriod(string tier = null, int? count = default(int?), Azure.ResourceManager.CognitiveServices.Models.CommitmentQuota quota = null, System.DateTimeOffset? startOn = default(System.DateTimeOffset?), System.DateTimeOffset? endOn = default(System.DateTimeOffset?)) { throw null; } - public static Azure.ResourceManager.CognitiveServices.CommitmentPlanAccountAssociationData CommitmentPlanAccountAssociationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), string accountId = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.CommitmentPlanAccountAssociationData CommitmentPlanAccountAssociationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IDictionary tags = null, string accountId = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.CognitiveServices.CommitmentPlanAccountAssociationData CommitmentPlanAccountAssociationData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, Azure.ETag? etag, string accountId) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CommitmentPlanAssociation CommitmentPlanAssociation(Azure.Core.ResourceIdentifier commitmentPlanId = null, string commitmentPlanLocation = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.CommitmentPlanData CommitmentPlanData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), string kind = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku sku = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.ResourceManager.CognitiveServices.Models.CommitmentPlanProperties properties = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CommitmentPlanProperties CommitmentPlanProperties(Azure.ResourceManager.CognitiveServices.Models.CommitmentPlanProvisioningState? provisioningState = default(Azure.ResourceManager.CognitiveServices.Models.CommitmentPlanProvisioningState?), System.Guid? commitmentPlanGuid = default(System.Guid?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountHostingModel? hostingModel = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountHostingModel?), string planType = null, Azure.ResourceManager.CognitiveServices.Models.CommitmentPeriod current = null, bool? autoRenew = default(bool?), Azure.ResourceManager.CognitiveServices.Models.CommitmentPeriod next = null, Azure.ResourceManager.CognitiveServices.Models.CommitmentPeriod last = null, System.Collections.Generic.IEnumerable provisioningIssues = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CommitmentQuota CommitmentQuota(long? quantity = default(long?), string unit = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.CommitmentTier CommitmentTier(string kind = null, string skuName = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountHostingModel? hostingModel = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountHostingModel?), string planType = null, string tier = null, int? maxCount = default(int?), Azure.ResourceManager.CognitiveServices.Models.CommitmentQuota quota = null, Azure.ResourceManager.CognitiveServices.Models.CommitmentCost cost = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.DefenderForAISettingData DefenderForAISettingData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState? state = default(Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState?)) { throw null; } + public static Azure.ResourceManager.CognitiveServices.EncryptionScopeData EncryptionScopeData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProperties properties = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProperties EncryptionScopeProperties(Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesKeyVaultProperties keyVaultProperties = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountEncryptionKeySource? keySource = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountEncryptionKeySource?), Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState? provisioningState = default(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState?), Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState? state = default(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState?)) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.ModelCapacityListResultValueItem ModelCapacityListResultValueItem(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.ResourceManager.CognitiveServices.Models.ModelSkuCapacityProperties properties = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.NetworkSecurityPerimeterConfigurationData NetworkSecurityPerimeterConfigurationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationProperties properties = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationProperties NetworkSecurityPerimeterConfigurationProperties(string provisioningState = null, System.Collections.Generic.IEnumerable provisioningIssues = null, Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeter networkSecurityPerimeter = null, Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationAssociationInfo resourceAssociation = null, Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterProfileInfo profile = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiBlocklistData RaiBlocklistData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IDictionary tags = null, string raiBlocklistDescription = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiBlocklistItemData RaiBlocklistItemData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.CognitiveServices.Models.RaiBlocklistItemProperties properties = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiContentFilterData RaiContentFilterData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.CognitiveServices.Models.RaiContentFilterProperties properties = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.RaiPolicyData RaiPolicyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.CognitiveServices.Models.RaiPolicyProperties properties = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyProperties RaiPolicyProperties(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType? policyType = default(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType?), Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode? mode = default(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode?), string basePolicyName = null, System.Collections.Generic.IEnumerable contentFilters = null, System.Collections.Generic.IEnumerable customBlocklists = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.ServiceAccountApiKeys ServiceAccountApiKeys(string key1 = null, string key2 = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit ServiceAccountCallRateLimit(float? count = default(float?), float? renewalPeriod = default(float?), System.Collections.Generic.IEnumerable rules = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.ServiceAccountQuotaLimit ServiceAccountQuotaLimit(float? count = default(float?), float? renewalPeriod = default(float?), System.Collections.Generic.IEnumerable rules = null) { throw null; } @@ -524,6 +969,7 @@ public static partial class ArmCognitiveServicesModelFactory public static Azure.ResourceManager.CognitiveServices.Models.ServiceAccountThrottlingRule ServiceAccountThrottlingRule(string key = null, float? renewalPeriod = default(float?), float? count = default(float?), float? minCount = default(float?), bool? isDynamicThrottlingEnabled = default(bool?), System.Collections.Generic.IEnumerable matchPatterns = null) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.ServiceAccountUsage ServiceAccountUsage(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountUsageUnitType? unit = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountUsageUnitType?), Azure.ResourceManager.CognitiveServices.Models.ServiceAccountUsageMetricName name = null, string quotaPeriod = null, double? limit = default(double?), double? currentValue = default(double?), string nextResetTime = null, Azure.ResourceManager.CognitiveServices.Models.ServiceAccountQuotaUsageStatus? status = default(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountQuotaUsageStatus?)) { throw null; } public static Azure.ResourceManager.CognitiveServices.Models.ServiceAccountUsageMetricName ServiceAccountUsageMetricName(string value = null, string localizedValue = null) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.SkuResource SkuResource(string resourceType = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku sku = null, Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCapacityConfig capacity = null) { throw null; } } public partial class AvailableCognitiveServicesSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -540,6 +986,71 @@ internal AvailableCognitiveServicesSku() { } 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 BillingMeterInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BillingMeterInfo() { } + public string MeterId { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public string Unit { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.BillingMeterInfo 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.CognitiveServices.Models.BillingMeterInfo 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 ByPassSelection : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ByPassSelection(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.ByPassSelection AzureServices { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.ByPassSelection None { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.ByPassSelection other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.ByPassSelection left, Azure.ResourceManager.CognitiveServices.Models.ByPassSelection right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.ByPassSelection (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.ByPassSelection left, Azure.ResourceManager.CognitiveServices.Models.ByPassSelection right) { throw null; } + public override string ToString() { throw null; } + } + public partial class CalculateModelCapacityParameter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CalculateModelCapacityParameter() { } + public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel Model { get { throw null; } set { } } + public string SkuName { get { throw null; } set { } } + public System.Collections.Generic.IList Workloads { get { throw null; } } + Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityParameter 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.CognitiveServices.Models.CalculateModelCapacityParameter 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 CalculateModelCapacityResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal CalculateModelCapacityResult() { } + public Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityResultEstimatedCapacity EstimatedCapacity { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel Model { get { throw null; } } + public string SkuName { get { throw null; } } + Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityResult 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.CognitiveServices.Models.CalculateModelCapacityResult 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 CalculateModelCapacityResultEstimatedCapacity : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal CalculateModelCapacityResultEstimatedCapacity() { } + public int? DeployableValue { get { throw null; } } + public int? Value { get { throw null; } } + Azure.ResourceManager.CognitiveServices.Models.CalculateModelCapacityResultEstimatedCapacity 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.CognitiveServices.Models.CalculateModelCapacityResultEstimatedCapacity 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 CognitiveServicesAccountDeploymentModel : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CognitiveServicesAccountDeploymentModel() { } @@ -559,6 +1070,9 @@ public partial class CognitiveServicesAccountDeploymentProperties : System.Clien public CognitiveServicesAccountDeploymentProperties() { } public Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit CallRateLimit { get { throw null; } } public System.Collections.Generic.IReadOnlyDictionary Capabilities { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.DeploymentCapacitySettings CapacitySettings { get { throw null; } set { } } + public int? CurrentCapacity { get { throw null; } set { } } + public bool? DynamicThrottlingEnabled { get { throw null; } } public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel Model { get { throw null; } set { } } public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentProvisioningState? ProvisioningState { get { throw null; } } public string RaiPolicyName { get { throw null; } set { } } @@ -648,6 +1162,7 @@ public partial class CognitiveServicesAccountProperties : System.ClientModel.Pri public CognitiveServicesAccountProperties() { } public Azure.ResourceManager.CognitiveServices.Models.AbusePenalty AbusePenalty { get { throw null; } } public System.Collections.Generic.IList AllowedFqdnList { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.UserOwnedAmlWorkspace AmlWorkspace { get { throw null; } set { } } public Azure.ResourceManager.CognitiveServices.Models.ServiceAccountApiProperties ApiProperties { get { throw null; } set { } } public Azure.ResourceManager.CognitiveServices.Models.ServiceAccountCallRateLimit CallRateLimit { get { throw null; } } public System.Collections.Generic.IReadOnlyList Capabilities { get { throw null; } } @@ -668,6 +1183,7 @@ public CognitiveServicesAccountProperties() { } public Azure.ResourceManager.CognitiveServices.Models.ServiceAccountProvisioningState? ProvisioningState { get { throw null; } } public Azure.ResourceManager.CognitiveServices.Models.ServiceAccountPublicNetworkAccess? PublicNetworkAccess { get { throw null; } set { } } public Azure.ResourceManager.CognitiveServices.Models.ServiceAccountQuotaLimit QuotaLimit { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.RaiMonitorConfig RaiMonitorConfig { get { throw null; } set { } } public bool? Restore { get { throw null; } set { } } public bool? RestrictOutboundNetworkAccess { get { throw null; } set { } } public string ScheduledPurgeDate { get { throw null; } } @@ -693,6 +1209,7 @@ internal CognitiveServicesAccountSku() { } public partial class CognitiveServicesCapacityConfig : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CognitiveServicesCapacityConfig() { } + public System.Collections.Generic.IList AllowedValues { get { throw null; } } public int? Default { get { throw null; } set { } } public int? Maximum { get { throw null; } set { } } public int? Minimum { get { throw null; } set { } } @@ -703,16 +1220,6 @@ public CognitiveServicesCapacityConfig() { } 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 CognitiveServicesCommitmentPlanPatch : Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPatchResourceTags, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel - { - public CognitiveServicesCommitmentPlanPatch() { } - public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku Sku { get { throw null; } set { } } - Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCommitmentPlanPatch 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.CognitiveServices.Models.CognitiveServicesCommitmentPlanPatch 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 CognitiveServicesDomainAvailabilityContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CognitiveServicesDomainAvailabilityContent(string subdomainName, Azure.Core.ResourceType resourceType) { } @@ -765,6 +1272,7 @@ public CognitiveServicesKeyVaultProperties() { } public partial class CognitiveServicesModel : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal CognitiveServicesModel() { } + public string Description { get { throw null; } } public string Kind { get { throw null; } } public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountModel Model { get { throw null; } } public string SkuName { get { throw null; } } @@ -778,6 +1286,7 @@ public partial class CognitiveServicesModelSku : System.ClientModel.Primitives.I { public CognitiveServicesModelSku() { } public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCapacityConfig Capacity { get { throw null; } set { } } + public System.Collections.Generic.IList Cost { get { throw null; } } public System.DateTimeOffset? DeprecationOn { get { throw null; } set { } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyList RateLimits { get { throw null; } } @@ -820,6 +1329,7 @@ public CognitiveServicesMultiRegionSettings() { } public partial class CognitiveServicesNetworkRuleSet : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public CognitiveServicesNetworkRuleSet() { } + public Azure.ResourceManager.CognitiveServices.Models.ByPassSelection? Bypass { get { throw null; } set { } } public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesNetworkRuleAction? DefaultAction { get { throw null; } set { } } public System.Collections.Generic.IList IPRules { get { throw null; } } public System.Collections.Generic.IList VirtualNetworkRules { get { throw null; } } @@ -1194,6 +1704,64 @@ internal CommitmentTier() { } 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 ContentLevel : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ContentLevel(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.ContentLevel High { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.ContentLevel Low { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.ContentLevel Medium { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.ContentLevel other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.ContentLevel left, Azure.ResourceManager.CognitiveServices.Models.ContentLevel right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.ContentLevel (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.ContentLevel left, Azure.ResourceManager.CognitiveServices.Models.ContentLevel right) { throw null; } + public override string ToString() { throw null; } + } + public partial class CustomBlocklistConfig : Azure.ResourceManager.CognitiveServices.Models.RaiBlocklistConfig, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CustomBlocklistConfig() { } + public Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource? Source { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.CustomBlocklistConfig 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.CognitiveServices.Models.CustomBlocklistConfig 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 DefenderForAISettingState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public DefenderForAISettingState(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState Disabled { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState Enabled { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState left, Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState left, Azure.ResourceManager.CognitiveServices.Models.DefenderForAISettingState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class DeploymentCapacitySettings : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public DeploymentCapacitySettings() { } + public int? DesignatedCapacity { get { throw null; } set { } } + public int? Priority { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.DeploymentCapacitySettings 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.CognitiveServices.Models.DeploymentCapacitySettings 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 DeploymentModelVersionUpgradeOption : System.IEquatable { private readonly object _dummy; @@ -1212,6 +1780,91 @@ internal CommitmentTier() { } public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.DeploymentModelVersionUpgradeOption left, Azure.ResourceManager.CognitiveServices.Models.DeploymentModelVersionUpgradeOption right) { throw null; } public override string ToString() { throw null; } } + public partial class EncryptionScopeProperties : Azure.ResourceManager.CognitiveServices.Models.ServiceAccountEncryptionProperties, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EncryptionScopeProperties() { } + public Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState? State { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProperties 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.CognitiveServices.Models.EncryptionScopeProperties 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 EncryptionScopeProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EncryptionScopeProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState Accepted { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState Creating { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState Deleting { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState Moving { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState left, Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState left, Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EncryptionScopeState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EncryptionScopeState(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState Disabled { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState Enabled { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState left, Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState left, Azure.ResourceManager.CognitiveServices.Models.EncryptionScopeState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ModelCapacityCalculatorWorkload : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ModelCapacityCalculatorWorkload() { } + public Azure.ResourceManager.CognitiveServices.Models.ModelCapacityCalculatorWorkloadRequestParam RequestParameters { get { throw null; } set { } } + public long? RequestPerMinute { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.ModelCapacityCalculatorWorkload 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.CognitiveServices.Models.ModelCapacityCalculatorWorkload 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 ModelCapacityCalculatorWorkloadRequestParam : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ModelCapacityCalculatorWorkloadRequestParam() { } + public long? AvgGeneratedTokens { get { throw null; } set { } } + public long? AvgPromptTokens { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.ModelCapacityCalculatorWorkloadRequestParam 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.CognitiveServices.Models.ModelCapacityCalculatorWorkloadRequestParam 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 ModelCapacityListResultValueItem : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ModelCapacityListResultValueItem() { } + public Azure.Core.AzureLocation? Location { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.ModelSkuCapacityProperties Properties { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.ModelCapacityListResultValueItem 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.CognitiveServices.Models.ModelCapacityListResultValueItem 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 ModelLifecycleStatus : System.IEquatable { @@ -1230,6 +1883,288 @@ internal CommitmentTier() { } public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.ModelLifecycleStatus left, Azure.ResourceManager.CognitiveServices.Models.ModelLifecycleStatus right) { throw null; } public override string ToString() { throw null; } } + public partial class ModelSkuCapacityProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ModelSkuCapacityProperties() { } + public float? AvailableCapacity { get { throw null; } set { } } + public float? AvailableFinetuneCapacity { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesAccountDeploymentModel Model { get { throw null; } set { } } + public string SkuName { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.ModelSkuCapacityProperties 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.CognitiveServices.Models.ModelSkuCapacityProperties 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 NetworkSecurityPerimeter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public NetworkSecurityPerimeter() { } + public Azure.Core.ResourceIdentifier Id { get { throw null; } set { } } + public Azure.Core.AzureLocation? Location { get { throw null; } set { } } + public string PerimeterGuid { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeter 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.CognitiveServices.Models.NetworkSecurityPerimeter 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 NetworkSecurityPerimeterAccessRule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public NetworkSecurityPerimeterAccessRule() { } + public string Name { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterAccessRuleProperties Properties { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterAccessRule 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.CognitiveServices.Models.NetworkSecurityPerimeterAccessRule 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 NetworkSecurityPerimeterAccessRuleProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public NetworkSecurityPerimeterAccessRuleProperties() { } + public System.Collections.Generic.IList AddressPrefixes { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection? Direction { get { throw null; } set { } } + public System.Collections.Generic.IList FullyQualifiedDomainNames { get { throw null; } } + public System.Collections.Generic.IList NetworkSecurityPerimeters { get { throw null; } } + public System.Collections.Generic.IList Subscriptions { get { throw null; } } + Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterAccessRuleProperties 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.CognitiveServices.Models.NetworkSecurityPerimeterAccessRuleProperties 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 NetworkSecurityPerimeterConfigurationAssociationInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public NetworkSecurityPerimeterConfigurationAssociationInfo() { } + public string AccessMode { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationAssociationInfo 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.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationAssociationInfo 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 NetworkSecurityPerimeterConfigurationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public NetworkSecurityPerimeterConfigurationProperties() { } + public Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeter NetworkSecurityPerimeter { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterProfileInfo Profile { get { throw null; } set { } } + public System.Collections.Generic.IList ProvisioningIssues { get { throw null; } } + public string ProvisioningState { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationAssociationInfo ResourceAssociation { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationProperties 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.CognitiveServices.Models.NetworkSecurityPerimeterConfigurationProperties 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 NetworkSecurityPerimeterProfileInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public NetworkSecurityPerimeterProfileInfo() { } + public System.Collections.Generic.IList AccessRules { get { throw null; } } + public long? AccessRulesVersion { get { throw null; } set { } } + public long? DiagnosticSettingsVersion { get { throw null; } set { } } + public System.Collections.Generic.IList EnabledLogCategories { get { throw null; } } + public string Name { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.NetworkSecurityPerimeterProfileInfo 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.CognitiveServices.Models.NetworkSecurityPerimeterProfileInfo 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 NspAccessRuleDirection : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public NspAccessRuleDirection(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection Inbound { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection Outbound { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection left, Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection left, Azure.ResourceManager.CognitiveServices.Models.NspAccessRuleDirection right) { throw null; } + public override string ToString() { throw null; } + } + public partial class PatchResourceTagsAndSku : Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesPatchResourceTags, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public PatchResourceTagsAndSku() { } + public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku Sku { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.PatchResourceTagsAndSku 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.CognitiveServices.Models.PatchResourceTagsAndSku 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 ProvisioningIssue : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProvisioningIssue() { } + public string Name { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.ProvisioningIssueProperties Properties { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.ProvisioningIssue 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.CognitiveServices.Models.ProvisioningIssue 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 ProvisioningIssueProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProvisioningIssueProperties() { } + public string Description { get { throw null; } set { } } + public string IssueType { get { throw null; } set { } } + public string Severity { get { throw null; } set { } } + public System.Collections.Generic.IList SuggestedAccessRules { get { throw null; } } + public System.Collections.Generic.IList SuggestedResourceIds { get { throw null; } } + Azure.ResourceManager.CognitiveServices.Models.ProvisioningIssueProperties 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.CognitiveServices.Models.ProvisioningIssueProperties 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 RaiBlocklistConfig : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiBlocklistConfig() { } + public bool? Blocking { get { throw null; } set { } } + public string BlocklistName { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.RaiBlocklistConfig 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.CognitiveServices.Models.RaiBlocklistConfig 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 RaiBlocklistItemBulkRequest : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiBlocklistItemBulkRequest() { } + public string Name { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.RaiBlocklistItemProperties Properties { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.RaiBlocklistItemBulkRequest 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.CognitiveServices.Models.RaiBlocklistItemBulkRequest 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 RaiBlocklistItemProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiBlocklistItemProperties() { } + public bool? IsRegex { get { throw null; } set { } } + public string Pattern { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.RaiBlocklistItemProperties 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.CognitiveServices.Models.RaiBlocklistItemProperties 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 RaiContentFilterProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiContentFilterProperties() { } + public bool? IsMultiLevelFilter { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource? Source { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.RaiContentFilterProperties 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.CognitiveServices.Models.RaiContentFilterProperties 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 RaiMonitorConfig : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiMonitorConfig() { } + public string AdxStorageResourceId { get { throw null; } set { } } + public System.Guid? IdentityClientId { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.RaiMonitorConfig 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.CognitiveServices.Models.RaiMonitorConfig 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 RaiPolicyContentFilter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiPolicyContentFilter() { } + public bool? Blocking { get { throw null; } set { } } + public bool? Enabled { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.ContentLevel? SeverityThreshold { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource? Source { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentFilter 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.CognitiveServices.Models.RaiPolicyContentFilter 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 RaiPolicyContentSource : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RaiPolicyContentSource(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource Completion { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource Prompt { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource left, Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource left, Azure.ResourceManager.CognitiveServices.Models.RaiPolicyContentSource right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RaiPolicyMode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RaiPolicyMode(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode AsynchronousFilter { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode Blocking { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode Default { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode Deferred { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode left, Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode left, Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode right) { throw null; } + public override string ToString() { throw null; } + } + public partial class RaiPolicyProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RaiPolicyProperties() { } + public string BasePolicyName { get { throw null; } set { } } + public System.Collections.Generic.IList ContentFilters { get { throw null; } } + public System.Collections.Generic.IList CustomBlocklists { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.RaiPolicyMode? Mode { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType? PolicyType { get { throw null; } } + Azure.ResourceManager.CognitiveServices.Models.RaiPolicyProperties 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.CognitiveServices.Models.RaiPolicyProperties 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 RaiPolicyType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RaiPolicyType(string value) { throw null; } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType SystemManaged { get { throw null; } } + public static Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType UserManaged { get { throw null; } } + public bool Equals(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType left, Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType right) { throw null; } + public static implicit operator Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType left, Azure.ResourceManager.CognitiveServices.Models.RaiPolicyType right) { throw null; } + public override string ToString() { throw null; } + } public partial class RegenerateServiceAccountKeyContent : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public RegenerateServiceAccountKeyContent(Azure.ResourceManager.CognitiveServices.Models.ServiceAccountKeyName keyName) { } @@ -1520,4 +2455,27 @@ public ServiceAccountUserOwnedStorage() { } 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 SkuResource : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal SkuResource() { } + public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesCapacityConfig Capacity { get { throw null; } } + public string ResourceType { get { throw null; } } + public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesSku Sku { get { throw null; } } + Azure.ResourceManager.CognitiveServices.Models.SkuResource 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.CognitiveServices.Models.SkuResource 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 UserOwnedAmlWorkspace : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public UserOwnedAmlWorkspace() { } + public System.Guid? IdentityClientId { get { throw null; } set { } } + public string ResourceId { get { throw null; } set { } } + Azure.ResourceManager.CognitiveServices.Models.UserOwnedAmlWorkspace 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.CognitiveServices.Models.UserOwnedAmlWorkspace 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/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs index ae6a6dc979f5f..be0ccf67f68c7 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs @@ -22,7 +22,7 @@ public partial class Sample_CognitiveServicesAccountCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_CreateAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CreateAccount.json // this example is just showing the usage of "Accounts_Create" 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 @@ -83,7 +83,7 @@ public async Task CreateOrUpdate_CreateAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_CreateAccountMin() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateAccountMin.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CreateAccountMin.json // this example is just showing the usage of "Accounts_Create" 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 @@ -125,7 +125,7 @@ public async Task CreateOrUpdate_CreateAccountMin() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetAccount.json // this example is just showing the usage of "Accounts_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 @@ -159,7 +159,7 @@ public async Task Get_GetAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetAccount.json // this example is just showing the usage of "Accounts_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 @@ -189,7 +189,7 @@ public async Task Exists_GetAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetAccount.json // this example is just showing the usage of "Accounts_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 @@ -231,7 +231,7 @@ public async Task GetIfExists_GetAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListAccountsByResourceGroup() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListAccountsByResourceGroup.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListAccountsByResourceGroup.json // this example is just showing the usage of "Accounts_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 diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs index 04f9ce8700735..6ab9c0edff59e 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_CognitiveServicesAccountDeploymentCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListDeployments() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListDeployments.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListDeployments.json // this example is just showing the usage of "Deployments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -57,7 +57,7 @@ public async Task GetAll_ListDeployments() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeployment.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeployment.json // this example is just showing the usage of "Deployments_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 @@ -92,7 +92,7 @@ public async Task Get_GetDeployment() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeployment.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeployment.json // this example is just showing the usage of "Deployments_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 @@ -123,7 +123,7 @@ public async Task Exists_GetDeployment() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeployment.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeployment.json // this example is just showing the usage of "Deployments_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 GetIfExists_GetDeployment() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_PutDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PutDeployment.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutDeployment.json // this example is just showing the usage of "Deployments_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 @@ -189,6 +189,10 @@ public async Task CreateOrUpdate_PutDeployment() string deploymentName = "deploymentName"; CognitiveServicesAccountDeploymentData data = new CognitiveServicesAccountDeploymentData() { + Sku = new CognitiveServicesSku("Standard") + { + Capacity = 1, + }, Properties = new CognitiveServicesAccountDeploymentProperties() { Model = new CognitiveServicesAccountDeploymentModel() @@ -197,11 +201,6 @@ public async Task CreateOrUpdate_PutDeployment() Name = "ada", Version = "1", }, - ScaleSettings = new CognitiveServicesAccountDeploymentScaleSettings() - { - ScaleType = CognitiveServicesAccountDeploymentScaleType.Manual, - Capacity = 1, - }, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs index 57fbf82748fb2..5fa4453016706 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs @@ -20,7 +20,7 @@ public partial class Sample_CognitiveServicesAccountDeploymentResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeployment.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeployment.json // this example is just showing the usage of "Deployments_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 @@ -47,13 +47,13 @@ public async Task Get_GetDeployment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - // PutDeployment + // UpdateDeployment [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task Update_PutDeployment() + public async Task Update_UpdateDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PutDeployment.json - // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/UpdateDeployment.json + // this example is just showing the usage of "Deployments_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(); @@ -62,7 +62,7 @@ public async Task Update_PutDeployment() // this example assumes you already have this CognitiveServicesAccountDeploymentResource created on azure // for more information of creating CognitiveServicesAccountDeploymentResource, please refer to the document of CognitiveServicesAccountDeploymentResource - string subscriptionId = "subscriptionId"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "resourceGroupName"; string accountName = "accountName"; string deploymentName = "deploymentName"; @@ -70,24 +70,14 @@ public async Task Update_PutDeployment() CognitiveServicesAccountDeploymentResource cognitiveServicesAccountDeployment = client.GetCognitiveServicesAccountDeploymentResource(cognitiveServicesAccountDeploymentResourceId); // invoke the operation - CognitiveServicesAccountDeploymentData data = new CognitiveServicesAccountDeploymentData() + PatchResourceTagsAndSku deployment = new PatchResourceTagsAndSku() { - Properties = new CognitiveServicesAccountDeploymentProperties() + Sku = new CognitiveServicesSku("Standard") { - Model = new CognitiveServicesAccountDeploymentModel() - { - Format = "OpenAI", - Name = "ada", - Version = "1", - }, - ScaleSettings = new CognitiveServicesAccountDeploymentScaleSettings() - { - ScaleType = CognitiveServicesAccountDeploymentScaleType.Manual, - Capacity = 1, - }, + Capacity = 1, }, }; - ArmOperation lro = await cognitiveServicesAccountDeployment.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await cognitiveServicesAccountDeployment.UpdateAsync(WaitUntil.Completed, deployment); CognitiveServicesAccountDeploymentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -102,7 +92,7 @@ public async Task Update_PutDeployment() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteDeployment.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteDeployment.json // this example is just showing the usage of "Deployments_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 @@ -124,5 +114,36 @@ public async Task Delete_DeleteDeployment() Console.WriteLine($"Succeeded"); } + + // ListDeploymentSkus + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetSkus_ListDeploymentSkus() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListDeploymentSkus.json + // this example is just showing the usage of "Deployments_ListSkus" 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 CognitiveServicesAccountDeploymentResource created on azure + // for more information of creating CognitiveServicesAccountDeploymentResource, please refer to the document of CognitiveServicesAccountDeploymentResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string deploymentName = "deploymentName"; + ResourceIdentifier cognitiveServicesAccountDeploymentResourceId = CognitiveServicesAccountDeploymentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, deploymentName); + CognitiveServicesAccountDeploymentResource cognitiveServicesAccountDeployment = client.GetCognitiveServicesAccountDeploymentResource(cognitiveServicesAccountDeploymentResourceId); + + // invoke the operation and iterate over the result + await foreach (SkuResource item in cognitiveServicesAccountDeployment.GetSkusAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs index 01ff3fbc84670..22f74a2a218ee 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs @@ -21,7 +21,7 @@ public partial class Sample_CognitiveServicesAccountResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_UpdateAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/UpdateAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/UpdateAccount.json // this example is just showing the usage of "Accounts_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 @@ -57,7 +57,7 @@ public async Task Update_UpdateAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteAccount.json // this example is just showing the usage of "Accounts_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 @@ -84,7 +84,7 @@ public async Task Delete_DeleteAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetAccount.json // this example is just showing the usage of "Accounts_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 @@ -115,7 +115,7 @@ public async Task Get_GetAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetCognitiveServicesAccounts_ListAccountsBySubscription() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListAccountsBySubscription.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListAccountsBySubscription.json // this example is just showing the usage of "Accounts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -147,7 +147,7 @@ public async Task GetCognitiveServicesAccounts_ListAccountsBySubscription() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetKeys_ListKeys() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListKeys.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListKeys.json // this example is just showing the usage of "Accounts_ListKeys" 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 @@ -174,7 +174,7 @@ public async Task GetKeys_ListKeys() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task RegenerateKey_RegenerateKeys() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/RegenerateKey.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/RegenerateKey.json // this example is just showing the usage of "Accounts_RegenerateKey" 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 @@ -202,7 +202,7 @@ public async Task RegenerateKey_RegenerateKeys() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetSkus_ListSKUs() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSkus.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListSkus.json // this example is just showing the usage of "Accounts_ListSkus" 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 @@ -232,7 +232,7 @@ public async Task GetSkus_ListSKUs() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetUsages_GetUsages() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetUsages.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetUsages.json // this example is just showing the usage of "Accounts_ListUsages" 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 @@ -262,7 +262,7 @@ public async Task GetUsages_GetUsages() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetModels_ListAccountModels() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListAccountModels.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListAccountModels.json // this example is just showing the usage of "Accounts_ListModels" 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 @@ -292,7 +292,7 @@ public async Task GetModels_ListAccountModels() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetPrivateLinkResources_ListPrivateLinkResources() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListPrivateLinkResources.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListPrivateLinkResources.json // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs index e6ac7a25620d9..1dc4950e9be3e 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs @@ -21,7 +21,7 @@ public partial class Sample_CognitiveServicesCommitmentPlanCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_CreateCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateSharedCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CreateSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_CreateOrUpdatePlan" 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 @@ -72,7 +72,7 @@ public async Task CreateOrUpdate_CreateCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_GetPlan" 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 @@ -106,7 +106,7 @@ public async Task Get_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_GetPlan" 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 @@ -136,7 +136,7 @@ public async Task Exists_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_GetPlan" 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 @@ -178,7 +178,7 @@ public async Task GetIfExists_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListCommitmentPlansByResourceGroup() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSharedCommitmentPlansByResourceGroup.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListSharedCommitmentPlansByResourceGroup.json // this example is just showing the usage of "CommitmentPlans_ListPlansByResourceGroup" 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/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs index a5cf3a9f02bb6..9096ad84a6945 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs @@ -21,7 +21,7 @@ public partial class Sample_CognitiveServicesCommitmentPlanResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_CreateCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/UpdateSharedCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/UpdateSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_UpdatePlan" 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 @@ -38,14 +38,14 @@ public async Task Update_CreateCommitmentPlan() CognitiveServicesCommitmentPlanResource cognitiveServicesCommitmentPlan = client.GetCognitiveServicesCommitmentPlanResource(cognitiveServicesCommitmentPlanResourceId); // invoke the operation - CognitiveServicesCommitmentPlanPatch patch = new CognitiveServicesCommitmentPlanPatch() + PatchResourceTagsAndSku commitmentPlan = new PatchResourceTagsAndSku() { Tags = { ["name"] = "value", }, }; - ArmOperation lro = await cognitiveServicesCommitmentPlan.UpdateAsync(WaitUntil.Completed, patch); + ArmOperation lro = await cognitiveServicesCommitmentPlan.UpdateAsync(WaitUntil.Completed, commitmentPlan); CognitiveServicesCommitmentPlanResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -60,7 +60,7 @@ public async Task Update_CreateCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteSharedCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_DeletePlan" 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 @@ -87,7 +87,7 @@ public async Task Delete_DeleteCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_GetPlan" 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 @@ -118,7 +118,7 @@ public async Task Get_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetCognitiveServicesCommitmentPlans_ListAccountsBySubscription() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSharedCommitmentPlansBySubscription.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListSharedCommitmentPlansBySubscription.json // this example is just showing the usage of "CommitmentPlans_ListPlansBySubscription" 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/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountCollection.cs index 6db3e6b12e240..a345fc406218b 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_CognitiveServicesDeletedAccountCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeletedAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeletedAccount.json // this example is just showing the usage of "DeletedAccounts_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 @@ -55,7 +55,7 @@ public async Task Get_GetAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeletedAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeletedAccount.json // this example is just showing the usage of "DeletedAccounts_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 @@ -86,7 +86,7 @@ public async Task Exists_GetAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeletedAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeletedAccount.json // this example is just showing the usage of "DeletedAccounts_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/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs index 02e0acb3a5b25..e16b7d05a1621 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs @@ -20,7 +20,7 @@ public partial class Sample_CognitiveServicesDeletedAccountResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeletedAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDeletedAccount.json // this example is just showing the usage of "DeletedAccounts_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 @@ -52,7 +52,7 @@ public async Task Get_GetAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PurgeDeletedAccount.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PurgeDeletedAccount.json // this example is just showing the usage of "DeletedAccounts_Purge" 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 @@ -80,7 +80,7 @@ public async Task Delete_DeleteAccount() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetDeletedAccounts_ListDeletedAccountsBySubscription() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListDeletedAccountsBySubscription.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListDeletedAccountsBySubscription.json // this example is just showing the usage of "DeletedAccounts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs index dd2ed1a15f8c9..ffc0b4389903f 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs @@ -19,7 +19,7 @@ public partial class Sample_CognitiveServicesPrivateEndpointConnectionCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_GetPrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListPrivateEndpointConnections.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListPrivateEndpointConnections.json // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -56,7 +56,7 @@ public async Task GetAll_GetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetPrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetPrivateEndpointConnection.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_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 @@ -91,7 +91,7 @@ public async Task Get_GetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetPrivateEndpointConnection.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_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 @@ -122,7 +122,7 @@ public async Task Exists_GetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetPrivateEndpointConnection.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_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/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionResource.cs index ac1170ee8b3c8..645eb5ff348e8 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionResource.cs @@ -19,7 +19,7 @@ public partial class Sample_CognitiveServicesPrivateEndpointConnectionResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetPrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetPrivateEndpointConnection.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_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_GetPrivateEndpointConnection() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeletePrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeletePrivateEndpointConnection.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeletePrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_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 diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs index f22d1ead4ee63..3b437795e3718 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs @@ -19,7 +19,7 @@ public partial class Sample_CommitmentPlanAccountAssociationCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListCommitmentPlans() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSharedCommitmentPlanAssociations.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListSharedCommitmentPlanAssociations.json // this example is just showing the usage of "CommitmentPlans_ListAssociations" 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 @@ -56,7 +56,7 @@ public async Task GetAll_ListCommitmentPlans() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlanAssociation.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_GetAssociation" 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 @@ -91,7 +91,7 @@ public async Task Get_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlanAssociation.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_GetAssociation" 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 @@ -122,7 +122,7 @@ public async Task Exists_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlanAssociation.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_GetAssociation" 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 @@ -165,7 +165,7 @@ public async Task GetIfExists_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateSharedCommitmentPlanAssociation.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CreateSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_CreateOrUpdateAssociation" 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/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs index aef0f054ebdd3..b1f1ce1f5391c 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs @@ -19,7 +19,7 @@ public partial class Sample_CommitmentPlanAccountAssociationResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlanAssociation.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_GetAssociation" 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_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateSharedCommitmentPlanAssociation.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CreateSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_CreateOrUpdateAssociation" 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 @@ -88,7 +88,7 @@ public async Task Update_PutCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteSharedCommitmentPlanAssociation.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_DeleteAssociation" 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/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs index cf7f1095e934d..1d5b331ff0f37 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs @@ -20,7 +20,7 @@ public partial class Sample_CommitmentPlanCollection [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetAll_ListCommitmentPlans() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListCommitmentPlans.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListCommitmentPlans.json // this example is just showing the usage of "CommitmentPlans_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -57,7 +57,7 @@ public async Task GetAll_ListCommitmentPlans() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_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 @@ -92,7 +92,7 @@ public async Task Get_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Exists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_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 @@ -123,7 +123,7 @@ public async Task Exists_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetIfExists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_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 GetIfExists_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CreateOrUpdate_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PutCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_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 diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs index 7321d9172339d..81056c9cea64f 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs @@ -20,7 +20,7 @@ public partial class Sample_CommitmentPlanResource [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Get_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_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 @@ -52,7 +52,7 @@ public async Task Get_GetCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Update_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PutCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_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 @@ -98,7 +98,7 @@ public async Task Update_PutCommitmentPlan() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task Delete_DeleteCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteCommitmentPlan.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_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 diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingCollection.cs new file mode 100644 index 0000000000000..59fc63ebc7ab4 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingCollection.cs @@ -0,0 +1,204 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_DefenderForAISettingCollection + { + // ListDefenderForAISetting + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListDefenderForAISetting() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this DefenderForAISettingResource + DefenderForAISettingCollection collection = cognitiveServicesAccount.GetDefenderForAISettings(); + + // invoke the operation and iterate over the result + await foreach (DefenderForAISettingResource 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 + DefenderForAISettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetDefenderForAISetting + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetDefenderForAISetting() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this DefenderForAISettingResource + DefenderForAISettingCollection collection = cognitiveServicesAccount.GetDefenderForAISettings(); + + // invoke the operation + string defenderForAISettingName = "Default"; + DefenderForAISettingResource result = await collection.GetAsync(defenderForAISettingName); + + // 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 + DefenderForAISettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetDefenderForAISetting + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetDefenderForAISetting() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this DefenderForAISettingResource + DefenderForAISettingCollection collection = cognitiveServicesAccount.GetDefenderForAISettings(); + + // invoke the operation + string defenderForAISettingName = "Default"; + bool result = await collection.ExistsAsync(defenderForAISettingName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetDefenderForAISetting + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetDefenderForAISetting() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this DefenderForAISettingResource + DefenderForAISettingCollection collection = cognitiveServicesAccount.GetDefenderForAISettings(); + + // invoke the operation + string defenderForAISettingName = "Default"; + NullableResponse response = await collection.GetIfExistsAsync(defenderForAISettingName); + DefenderForAISettingResource 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 + DefenderForAISettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // PutDefenderForAISetting + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutDefenderForAISetting() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this DefenderForAISettingResource + DefenderForAISettingCollection collection = cognitiveServicesAccount.GetDefenderForAISettings(); + + // invoke the operation + string defenderForAISettingName = "Default"; + DefenderForAISettingData data = new DefenderForAISettingData() + { + State = DefenderForAISettingState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, defenderForAISettingName, data); + DefenderForAISettingResource 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 + DefenderForAISettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingResource.cs new file mode 100644 index 0000000000000..3dae9f49a487b --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingResource.cs @@ -0,0 +1,86 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_DefenderForAISettingResource + { + // GetDefenderForAISetting + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetDefenderForAISetting() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_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 DefenderForAISettingResource created on azure + // for more information of creating DefenderForAISettingResource, please refer to the document of DefenderForAISettingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string defenderForAISettingName = "Default"; + ResourceIdentifier defenderForAISettingResourceId = DefenderForAISettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, defenderForAISettingName); + DefenderForAISettingResource defenderForAISetting = client.GetDefenderForAISettingResource(defenderForAISettingResourceId); + + // invoke the operation + DefenderForAISettingResource result = await defenderForAISetting.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 + DefenderForAISettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // UpdateDefenderForAISetting + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_UpdateDefenderForAISetting() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/UpdateDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_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 DefenderForAISettingResource created on azure + // for more information of creating DefenderForAISettingResource, please refer to the document of DefenderForAISettingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string defenderForAISettingName = "Default"; + ResourceIdentifier defenderForAISettingResourceId = DefenderForAISettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, defenderForAISettingName); + DefenderForAISettingResource defenderForAISetting = client.GetDefenderForAISettingResource(defenderForAISettingResourceId); + + // invoke the operation + DefenderForAISettingData data = new DefenderForAISettingData() + { + State = DefenderForAISettingState.Enabled, + }; + DefenderForAISettingResource result = await defenderForAISetting.UpdateAsync(data); + + // 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 + DefenderForAISettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_EncryptionScopeCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_EncryptionScopeCollection.cs new file mode 100644 index 0000000000000..861da49c6d7d0 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_EncryptionScopeCollection.cs @@ -0,0 +1,215 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_EncryptionScopeCollection + { + // ListEncryptionScopes + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListEncryptionScopes() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListEncryptionScopes.json + // this example is just showing the usage of "EncryptionScopes_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this EncryptionScopeResource + EncryptionScopeCollection collection = cognitiveServicesAccount.GetEncryptionScopes(); + + // invoke the operation and iterate over the result + await foreach (EncryptionScopeResource 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 + EncryptionScopeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetEncryptionScope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetEncryptionScope() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this EncryptionScopeResource + EncryptionScopeCollection collection = cognitiveServicesAccount.GetEncryptionScopes(); + + // invoke the operation + string encryptionScopeName = "encryptionScopeName"; + EncryptionScopeResource result = await collection.GetAsync(encryptionScopeName); + + // 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 + EncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetEncryptionScope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetEncryptionScope() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this EncryptionScopeResource + EncryptionScopeCollection collection = cognitiveServicesAccount.GetEncryptionScopes(); + + // invoke the operation + string encryptionScopeName = "encryptionScopeName"; + bool result = await collection.ExistsAsync(encryptionScopeName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetEncryptionScope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetEncryptionScope() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this EncryptionScopeResource + EncryptionScopeCollection collection = cognitiveServicesAccount.GetEncryptionScopes(); + + // invoke the operation + string encryptionScopeName = "encryptionScopeName"; + NullableResponse response = await collection.GetIfExistsAsync(encryptionScopeName); + EncryptionScopeResource 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 + EncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // PutEncryptionScope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutEncryptionScope() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this EncryptionScopeResource + EncryptionScopeCollection collection = cognitiveServicesAccount.GetEncryptionScopes(); + + // invoke the operation + string encryptionScopeName = "encryptionScopeName"; + EncryptionScopeData data = new EncryptionScopeData() + { + Properties = new EncryptionScopeProperties() + { + State = EncryptionScopeState.Enabled, + KeyVaultProperties = new CognitiveServicesKeyVaultProperties() + { + KeyName = "DevKeyWestUS2", + KeyVersion = "9f85549d7bf14ff4bf178c10d3bdca95", + KeyVaultUri = new Uri("https://devkvwestus2.vault.azure.net/"), + IdentityClientId = Guid.Parse("00000000-0000-0000-0000-000000000000"), + }, + KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionScopeName, data); + EncryptionScopeResource 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 + EncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_EncryptionScopeResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_EncryptionScopeResource.cs new file mode 100644 index 0000000000000..5d62074c99b21 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_EncryptionScopeResource.cs @@ -0,0 +1,126 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_EncryptionScopeResource + { + // GetEncryptionScope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetEncryptionScope() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_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 EncryptionScopeResource created on azure + // for more information of creating EncryptionScopeResource, please refer to the document of EncryptionScopeResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string encryptionScopeName = "encryptionScopeName"; + ResourceIdentifier encryptionScopeResourceId = EncryptionScopeResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, encryptionScopeName); + EncryptionScopeResource encryptionScope = client.GetEncryptionScopeResource(encryptionScopeResourceId); + + // invoke the operation + EncryptionScopeResource result = await encryptionScope.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 + EncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // PutEncryptionScope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PutEncryptionScope() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_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 EncryptionScopeResource created on azure + // for more information of creating EncryptionScopeResource, please refer to the document of EncryptionScopeResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string encryptionScopeName = "encryptionScopeName"; + ResourceIdentifier encryptionScopeResourceId = EncryptionScopeResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, encryptionScopeName); + EncryptionScopeResource encryptionScope = client.GetEncryptionScopeResource(encryptionScopeResourceId); + + // invoke the operation + EncryptionScopeData data = new EncryptionScopeData() + { + Properties = new EncryptionScopeProperties() + { + State = EncryptionScopeState.Enabled, + KeyVaultProperties = new CognitiveServicesKeyVaultProperties() + { + KeyName = "DevKeyWestUS2", + KeyVersion = "9f85549d7bf14ff4bf178c10d3bdca95", + KeyVaultUri = new Uri("https://devkvwestus2.vault.azure.net/"), + IdentityClientId = Guid.Parse("00000000-0000-0000-0000-000000000000"), + }, + KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, + }, + }; + ArmOperation lro = await encryptionScope.UpdateAsync(WaitUntil.Completed, data); + EncryptionScopeResource 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 + EncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DeleteEncryptionScope + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteEncryptionScope() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_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 EncryptionScopeResource created on azure + // for more information of creating EncryptionScopeResource, please refer to the document of EncryptionScopeResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string encryptionScopeName = "encryptionScopeName"; + ResourceIdentifier encryptionScopeResourceId = EncryptionScopeResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, encryptionScopeName); + EncryptionScopeResource encryptionScope = client.GetEncryptionScopeResource(encryptionScopeResourceId); + + // invoke the operation + await encryptionScope.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs new file mode 100644 index 0000000000000..eb06114bee53b --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs @@ -0,0 +1,163 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_NetworkSecurityPerimeterConfigurationCollection + { + // ListNetworkSecurityPerimeterConfigurations + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListNetworkSecurityPerimeterConfigurations() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this NetworkSecurityPerimeterConfigurationResource + NetworkSecurityPerimeterConfigurationCollection collection = cognitiveServicesAccount.GetNetworkSecurityPerimeterConfigurations(); + + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationResource 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 + NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetNetworkSecurityPerimeterConfigurations + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetNetworkSecurityPerimeterConfigurations() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this NetworkSecurityPerimeterConfigurationResource + NetworkSecurityPerimeterConfigurationCollection collection = cognitiveServicesAccount.GetNetworkSecurityPerimeterConfigurations(); + + // invoke the operation + string nspConfigurationName = "NSPConfigurationName"; + NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(nspConfigurationName); + + // 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 + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetNetworkSecurityPerimeterConfigurations + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetNetworkSecurityPerimeterConfigurations() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this NetworkSecurityPerimeterConfigurationResource + NetworkSecurityPerimeterConfigurationCollection collection = cognitiveServicesAccount.GetNetworkSecurityPerimeterConfigurations(); + + // invoke the operation + string nspConfigurationName = "NSPConfigurationName"; + bool result = await collection.ExistsAsync(nspConfigurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetNetworkSecurityPerimeterConfigurations + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetNetworkSecurityPerimeterConfigurations() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this NetworkSecurityPerimeterConfigurationResource + NetworkSecurityPerimeterConfigurationCollection collection = cognitiveServicesAccount.GetNetworkSecurityPerimeterConfigurations(); + + // invoke the operation + string nspConfigurationName = "NSPConfigurationName"; + NullableResponse response = await collection.GetIfExistsAsync(nspConfigurationName); + NetworkSecurityPerimeterConfigurationResource 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 + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationResource.cs new file mode 100644 index 0000000000000..148a288508d63 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationResource.cs @@ -0,0 +1,82 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_NetworkSecurityPerimeterConfigurationResource + { + // GetNetworkSecurityPerimeterConfigurations + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetNetworkSecurityPerimeterConfigurations() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_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 NetworkSecurityPerimeterConfigurationResource created on azure + // for more information of creating NetworkSecurityPerimeterConfigurationResource, please refer to the document of NetworkSecurityPerimeterConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string nspConfigurationName = "NSPConfigurationName"; + ResourceIdentifier networkSecurityPerimeterConfigurationResourceId = NetworkSecurityPerimeterConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, nspConfigurationName); + NetworkSecurityPerimeterConfigurationResource networkSecurityPerimeterConfiguration = client.GetNetworkSecurityPerimeterConfigurationResource(networkSecurityPerimeterConfigurationResourceId); + + // invoke the operation + NetworkSecurityPerimeterConfigurationResource result = await networkSecurityPerimeterConfiguration.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 + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ReconcileNetworkSecurityPerimeterConfigurations + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Reconcile_ReconcileNetworkSecurityPerimeterConfigurations() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ReconcileNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Reconcile" 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 NetworkSecurityPerimeterConfigurationResource created on azure + // for more information of creating NetworkSecurityPerimeterConfigurationResource, please refer to the document of NetworkSecurityPerimeterConfigurationResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string nspConfigurationName = "NSPConfigurationName"; + ResourceIdentifier networkSecurityPerimeterConfigurationResourceId = NetworkSecurityPerimeterConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, nspConfigurationName); + NetworkSecurityPerimeterConfigurationResource networkSecurityPerimeterConfiguration = client.GetNetworkSecurityPerimeterConfigurationResource(networkSecurityPerimeterConfigurationResourceId); + + // invoke the operation + ArmOperation lro = await networkSecurityPerimeterConfiguration.ReconcileAsync(WaitUntil.Completed); + NetworkSecurityPerimeterConfigurationResource 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 + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistCollection.cs new file mode 100644 index 0000000000000..5a7442db9bebf --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistCollection.cs @@ -0,0 +1,203 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiBlocklistCollection + { + // ListBlocklists + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListBlocklists() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListBlocklists.json + // this example is just showing the usage of "RaiBlocklists_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiBlocklistResource + RaiBlocklistCollection collection = cognitiveServicesAccount.GetRaiBlocklists(); + + // invoke the operation and iterate over the result + await foreach (RaiBlocklistResource 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 + RaiBlocklistData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetRaiBlocklist + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRaiBlocklist() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiBlocklistResource + RaiBlocklistCollection collection = cognitiveServicesAccount.GetRaiBlocklists(); + + // invoke the operation + string raiBlocklistName = "raiBlocklistName"; + RaiBlocklistResource result = await collection.GetAsync(raiBlocklistName); + + // 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 + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetRaiBlocklist + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetRaiBlocklist() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiBlocklistResource + RaiBlocklistCollection collection = cognitiveServicesAccount.GetRaiBlocklists(); + + // invoke the operation + string raiBlocklistName = "raiBlocklistName"; + bool result = await collection.ExistsAsync(raiBlocklistName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetRaiBlocklist + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetRaiBlocklist() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiBlocklistResource + RaiBlocklistCollection collection = cognitiveServicesAccount.GetRaiBlocklists(); + + // invoke the operation + string raiBlocklistName = "raiBlocklistName"; + NullableResponse response = await collection.GetIfExistsAsync(raiBlocklistName); + RaiBlocklistResource 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 + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // PutRaiBlocklist + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutRaiBlocklist() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiBlocklistResource + RaiBlocklistCollection collection = cognitiveServicesAccount.GetRaiBlocklists(); + + // invoke the operation + string raiBlocklistName = "raiBlocklistName"; + RaiBlocklistData data = new RaiBlocklistData() + { + RaiBlocklistDescription = "Basic blocklist description", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiBlocklistName, data); + RaiBlocklistResource 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 + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemCollection.cs new file mode 100644 index 0000000000000..b0a1970f61e99 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemCollection.cs @@ -0,0 +1,213 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiBlocklistItemCollection + { + // ListBlocklistItems + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListBlocklistItems() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListBlocklistItems.json + // this example is just showing the usage of "RaiBlocklistItems_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // get the collection of this RaiBlocklistItemResource + RaiBlocklistItemCollection collection = raiBlocklist.GetRaiBlocklistItems(); + + // invoke the operation and iterate over the result + await foreach (RaiBlocklistItemResource 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 + RaiBlocklistItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetRaiBlocklistItem + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRaiBlocklistItem() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // get the collection of this RaiBlocklistItemResource + RaiBlocklistItemCollection collection = raiBlocklist.GetRaiBlocklistItems(); + + // invoke the operation + string raiBlocklistItemName = "raiBlocklistItemName"; + RaiBlocklistItemResource result = await collection.GetAsync(raiBlocklistItemName); + + // 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 + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetRaiBlocklistItem + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetRaiBlocklistItem() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // get the collection of this RaiBlocklistItemResource + RaiBlocklistItemCollection collection = raiBlocklist.GetRaiBlocklistItems(); + + // invoke the operation + string raiBlocklistItemName = "raiBlocklistItemName"; + bool result = await collection.ExistsAsync(raiBlocklistItemName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetRaiBlocklistItem + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetRaiBlocklistItem() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // get the collection of this RaiBlocklistItemResource + RaiBlocklistItemCollection collection = raiBlocklist.GetRaiBlocklistItems(); + + // invoke the operation + string raiBlocklistItemName = "raiBlocklistItemName"; + NullableResponse response = await collection.GetIfExistsAsync(raiBlocklistItemName); + RaiBlocklistItemResource 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 + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // PutRaiBlocklistItem + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutRaiBlocklistItem() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // get the collection of this RaiBlocklistItemResource + RaiBlocklistItemCollection collection = raiBlocklist.GetRaiBlocklistItems(); + + // invoke the operation + string raiBlocklistItemName = "raiBlocklistItemName"; + RaiBlocklistItemData data = new RaiBlocklistItemData() + { + Properties = new RaiBlocklistItemProperties() + { + Pattern = "Pattern To Block", + IsRegex = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiBlocklistItemName, data); + RaiBlocklistItemResource 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 + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemResource.cs new file mode 100644 index 0000000000000..dde682603a8e5 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemResource.cs @@ -0,0 +1,122 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiBlocklistItemResource + { + // GetRaiBlocklistItem + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRaiBlocklistItem() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_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 RaiBlocklistItemResource created on azure + // for more information of creating RaiBlocklistItemResource, please refer to the document of RaiBlocklistItemResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + string raiBlocklistItemName = "raiBlocklistItemName"; + ResourceIdentifier raiBlocklistItemResourceId = RaiBlocklistItemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName); + RaiBlocklistItemResource raiBlocklistItem = client.GetRaiBlocklistItemResource(raiBlocklistItemResourceId); + + // invoke the operation + RaiBlocklistItemResource result = await raiBlocklistItem.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 + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // PutRaiBlocklistItem + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PutRaiBlocklistItem() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_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 RaiBlocklistItemResource created on azure + // for more information of creating RaiBlocklistItemResource, please refer to the document of RaiBlocklistItemResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + string raiBlocklistItemName = "raiBlocklistItemName"; + ResourceIdentifier raiBlocklistItemResourceId = RaiBlocklistItemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName); + RaiBlocklistItemResource raiBlocklistItem = client.GetRaiBlocklistItemResource(raiBlocklistItemResourceId); + + // invoke the operation + RaiBlocklistItemData data = new RaiBlocklistItemData() + { + Properties = new RaiBlocklistItemProperties() + { + Pattern = "Pattern To Block", + IsRegex = false, + }, + }; + ArmOperation lro = await raiBlocklistItem.UpdateAsync(WaitUntil.Completed, data); + RaiBlocklistItemResource 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 + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DeleteRaiBlocklistItem + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteRaiBlocklistItem() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_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 RaiBlocklistItemResource created on azure + // for more information of creating RaiBlocklistItemResource, please refer to the document of RaiBlocklistItemResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + string raiBlocklistItemName = "raiBlocklistItemName"; + ResourceIdentifier raiBlocklistItemResourceId = RaiBlocklistItemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName); + RaiBlocklistItemResource raiBlocklistItem = client.GetRaiBlocklistItemResource(raiBlocklistItemResourceId); + + // invoke the operation + await raiBlocklistItem.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistResource.cs new file mode 100644 index 0000000000000..ccf70c74d1d18 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistResource.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiBlocklistResource + { + // GetRaiBlocklist + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRaiBlocklist() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // invoke the operation + RaiBlocklistResource result = await raiBlocklist.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 + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // PutRaiBlocklist + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PutRaiBlocklist() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // invoke the operation + RaiBlocklistData data = new RaiBlocklistData() + { + RaiBlocklistDescription = "Basic blocklist description", + }; + ArmOperation lro = await raiBlocklist.UpdateAsync(WaitUntil.Completed, data); + RaiBlocklistResource 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 + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DeleteRaiBlocklist + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteRaiBlocklist() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // invoke the operation + await raiBlocklist.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + + // AddRaiBlocklistItems + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task BatchAddRaiBlocklistItem_AddRaiBlocklistItems() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/AddRaiBlocklistItems.json + // this example is just showing the usage of "RaiBlocklistItems_BatchAdd" 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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "myblocklist"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // invoke the operation + IEnumerable content = new RaiBlocklistItemBulkRequest[] + { +new RaiBlocklistItemBulkRequest() +{ +Name = "myblocklistitem1", +Properties = new RaiBlocklistItemProperties() +{ +Pattern = "^[a-z0-9_-]{2,16}$", +IsRegex = true, +}, +},new RaiBlocklistItemBulkRequest() +{ +Name = "myblocklistitem2", +Properties = new RaiBlocklistItemProperties() +{ +Pattern = "blockwords", +IsRegex = false, +}, +} + }; + RaiBlocklistResource result = await raiBlocklist.BatchAddRaiBlocklistItemAsync(content); + + // 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 + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DeleteRaiBlocklistItems + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task BatchDeleteRaiBlocklistItem_DeleteRaiBlocklistItems() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteRaiBlocklistItems.json + // this example is just showing the usage of "RaiBlocklistItems_BatchDelete" 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 RaiBlocklistResource created on azure + // for more information of creating RaiBlocklistResource, please refer to the document of RaiBlocklistResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiBlocklistName = "raiBlocklistName"; + ResourceIdentifier raiBlocklistResourceId = RaiBlocklistResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); + + // invoke the operation + BinaryData raiBlocklistItemsNames = BinaryData.FromObjectAsJson(new object[] { "myblocklistitem1", "myblocklistitem2" }); + await raiBlocklist.BatchDeleteRaiBlocklistItemAsync(raiBlocklistItemsNames); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterCollection.cs new file mode 100644 index 0000000000000..4058b61f9c3bc --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterCollection.cs @@ -0,0 +1,160 @@ +// 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.Resources; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiContentFilterCollection + { + // ListRaiContentFilters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListRaiContentFilters() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListRaiContentFilters.json + // this example is just showing the usage of "RaiContentFilters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this RaiContentFilterResource + AzureLocation location = new AzureLocation("WestUS"); + RaiContentFilterCollection collection = subscriptionResource.GetRaiContentFilters(location); + + // invoke the operation and iterate over the result + await foreach (RaiContentFilterResource 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 + RaiContentFilterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ListRaiContentFilters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ListRaiContentFilters() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiContentFilter.json + // this example is just showing the usage of "RaiContentFilters_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 SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this RaiContentFilterResource + AzureLocation location = new AzureLocation("WestUS"); + RaiContentFilterCollection collection = subscriptionResource.GetRaiContentFilters(location); + + // invoke the operation + string filterName = "IndirectAttack"; + RaiContentFilterResource result = await collection.GetAsync(filterName); + + // 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 + RaiContentFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // ListRaiContentFilters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_ListRaiContentFilters() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiContentFilter.json + // this example is just showing the usage of "RaiContentFilters_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 SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this RaiContentFilterResource + AzureLocation location = new AzureLocation("WestUS"); + RaiContentFilterCollection collection = subscriptionResource.GetRaiContentFilters(location); + + // invoke the operation + string filterName = "IndirectAttack"; + bool result = await collection.ExistsAsync(filterName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // ListRaiContentFilters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_ListRaiContentFilters() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiContentFilter.json + // this example is just showing the usage of "RaiContentFilters_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 SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this RaiContentFilterResource + AzureLocation location = new AzureLocation("WestUS"); + RaiContentFilterCollection collection = subscriptionResource.GetRaiContentFilters(location); + + // invoke the operation + string filterName = "IndirectAttack"; + NullableResponse response = await collection.GetIfExistsAsync(filterName); + RaiContentFilterResource 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 + RaiContentFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterResource.cs new file mode 100644 index 0000000000000..60f6f53401f8a --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterResource.cs @@ -0,0 +1,48 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiContentFilterResource + { + // ListRaiContentFilters + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_ListRaiContentFilters() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiContentFilter.json + // this example is just showing the usage of "RaiContentFilters_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 RaiContentFilterResource created on azure + // for more information of creating RaiContentFilterResource, please refer to the document of RaiContentFilterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + AzureLocation location = new AzureLocation("WestUS"); + string filterName = "IndirectAttack"; + ResourceIdentifier raiContentFilterResourceId = RaiContentFilterResource.CreateResourceIdentifier(subscriptionId, location, filterName); + RaiContentFilterResource raiContentFilter = client.GetRaiContentFilterResource(raiContentFilterResourceId); + + // invoke the operation + RaiContentFilterResource result = await raiContentFilter.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 + RaiContentFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyCollection.cs new file mode 100644 index 0000000000000..0fb3c87b88de8 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyCollection.cs @@ -0,0 +1,292 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiPolicyCollection + { + // ListRaiPolicies + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetAll_ListRaiPolicies() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListRaiPolicies.json + // this example is just showing the usage of "RaiPolicies_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiPolicyResource + RaiPolicyCollection collection = cognitiveServicesAccount.GetRaiPolicies(); + + // invoke the operation and iterate over the result + await foreach (RaiPolicyResource 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 + RaiPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine($"Succeeded"); + } + + // GetRaiPolicy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiPolicyResource + RaiPolicyCollection collection = cognitiveServicesAccount.GetRaiPolicies(); + + // invoke the operation + string raiPolicyName = "raiPolicyName"; + RaiPolicyResource result = await collection.GetAsync(raiPolicyName); + + // 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 + RaiPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // GetRaiPolicy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Exists_GetRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiPolicyResource + RaiPolicyCollection collection = cognitiveServicesAccount.GetRaiPolicies(); + + // invoke the operation + string raiPolicyName = "raiPolicyName"; + bool result = await collection.ExistsAsync(raiPolicyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + // GetRaiPolicy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetIfExists_GetRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiPolicyResource + RaiPolicyCollection collection = cognitiveServicesAccount.GetRaiPolicies(); + + // invoke the operation + string raiPolicyName = "raiPolicyName"; + NullableResponse response = await collection.GetIfExistsAsync(raiPolicyName); + RaiPolicyResource 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 + RaiPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + // PutRaiPolicy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CreateOrUpdate_PutRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_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 CognitiveServicesAccountResource created on azure + // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); + + // get the collection of this RaiPolicyResource + RaiPolicyCollection collection = cognitiveServicesAccount.GetRaiPolicies(); + + // invoke the operation + string raiPolicyName = "raiPolicyName"; + RaiPolicyData data = new RaiPolicyData() + { + Properties = new RaiPolicyProperties() + { + Mode = RaiPolicyMode.AsynchronousFilter, + BasePolicyName = "Microsoft.Default", + ContentFilters = +{ +new RaiPolicyContentFilter() +{ +Name = "hate", +Enabled = false, +SeverityThreshold = ContentLevel.High, +Blocking = false, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "hate", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "sexual", +Enabled = true, +SeverityThreshold = ContentLevel.High, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "sexual", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "selfharm", +Enabled = true, +SeverityThreshold = ContentLevel.High, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "selfharm", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "violence", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "violence", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "jailbreak", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "protected_material_text", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "protected_material_code", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "profanity", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +} +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiPolicyName, data); + RaiPolicyResource 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 + RaiPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyResource.cs new file mode 100644 index 0000000000000..5d0175a61aa9d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyResource.cs @@ -0,0 +1,203 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices.Samples +{ + public partial class Sample_RaiPolicyResource + { + // GetRaiPolicy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Get_GetRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_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 RaiPolicyResource created on azure + // for more information of creating RaiPolicyResource, please refer to the document of RaiPolicyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiPolicyName = "raiPolicyName"; + ResourceIdentifier raiPolicyResourceId = RaiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiPolicyName); + RaiPolicyResource raiPolicy = client.GetRaiPolicyResource(raiPolicyResourceId); + + // invoke the operation + RaiPolicyResource result = await raiPolicy.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 + RaiPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // PutRaiPolicy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Update_PutRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/PutRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_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 RaiPolicyResource created on azure + // for more information of creating RaiPolicyResource, please refer to the document of RaiPolicyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiPolicyName = "raiPolicyName"; + ResourceIdentifier raiPolicyResourceId = RaiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiPolicyName); + RaiPolicyResource raiPolicy = client.GetRaiPolicyResource(raiPolicyResourceId); + + // invoke the operation + RaiPolicyData data = new RaiPolicyData() + { + Properties = new RaiPolicyProperties() + { + Mode = RaiPolicyMode.AsynchronousFilter, + BasePolicyName = "Microsoft.Default", + ContentFilters = +{ +new RaiPolicyContentFilter() +{ +Name = "hate", +Enabled = false, +SeverityThreshold = ContentLevel.High, +Blocking = false, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "hate", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "sexual", +Enabled = true, +SeverityThreshold = ContentLevel.High, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "sexual", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "selfharm", +Enabled = true, +SeverityThreshold = ContentLevel.High, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "selfharm", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "violence", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "violence", +Enabled = true, +SeverityThreshold = ContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "jailbreak", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +},new RaiPolicyContentFilter() +{ +Name = "protected_material_text", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "protected_material_code", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +},new RaiPolicyContentFilter() +{ +Name = "profanity", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +} +}, + }, + }; + ArmOperation lro = await raiPolicy.UpdateAsync(WaitUntil.Completed, data); + RaiPolicyResource 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 + RaiPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + // DeleteRaiPolicy + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task Delete_DeleteRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/DeleteRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_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 RaiPolicyResource created on azure + // for more information of creating RaiPolicyResource, please refer to the document of RaiPolicyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiPolicyName = "raiPolicyName"; + ResourceIdentifier raiPolicyResourceId = RaiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiPolicyName); + RaiPolicyResource raiPolicy = client.GetRaiPolicyResource(raiPolicyResourceId); + + // invoke the operation + await raiPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine($"Succeeded"); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 2c8ed3909c228..4f772d42c0193 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -21,7 +21,7 @@ public partial class Sample_SubscriptionResourceExtensions [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetResourceSkus_RegenerateKeys() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSkus.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/GetSkus.json // this example is just showing the usage of "ResourceSkus_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -49,7 +49,7 @@ public async Task GetResourceSkus_RegenerateKeys() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetUsages_GetUsages() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListUsages.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListUsages.json // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -78,7 +78,7 @@ public async Task GetUsages_GetUsages() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CheckSkuAvailability_CheckSKUAvailability() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CheckSkuAvailability.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CheckSkuAvailability.json // this example is just showing the usage of "CheckSkuAvailability" 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 @@ -111,7 +111,7 @@ public async Task CheckSkuAvailability_CheckSKUAvailability() [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task CheckDomainAvailability_CheckSKUAvailability() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CheckDomainAvailability.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CheckDomainAvailability.json // this example is just showing the usage of "CheckDomainAvailability" 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 @@ -132,12 +132,67 @@ public async Task CheckDomainAvailability_CheckSKUAvailability() Console.WriteLine($"Succeeded: {result}"); } + // Calculate Model Capacity + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task CalculateModelCapacity_CalculateModelCapacity() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/CalculateModelCapacity.json + // this example is just showing the usage of "CalculateModelCapacity" 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 SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + CalculateModelCapacityParameter calculateModelCapacityParameter = new CalculateModelCapacityParameter() + { + Model = new CognitiveServicesAccountDeploymentModel() + { + Format = "OpenAI", + Name = "gpt-4", + Version = "0613", + }, + SkuName = "ProvisinedManaged", + Workloads = +{ +new ModelCapacityCalculatorWorkload() +{ +RequestPerMinute = 10, +RequestParameters = new ModelCapacityCalculatorWorkloadRequestParam() +{ +AvgPromptTokens = 30, +AvgGeneratedTokens = 50, +}, +},new ModelCapacityCalculatorWorkload() +{ +RequestPerMinute = 20, +RequestParameters = new ModelCapacityCalculatorWorkloadRequestParam() +{ +AvgPromptTokens = 60, +AvgGeneratedTokens = 20, +}, +} +}, + }; + CalculateModelCapacityResult result = await subscriptionResource.CalculateModelCapacityAsync(calculateModelCapacityParameter); + + Console.WriteLine($"Succeeded: {result}"); + } + // ListCommitmentTiers [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] public async Task GetCommitmentTiers_ListCommitmentTiers() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListCommitmentTiers.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListCommitmentTiers.json // this example is just showing the usage of "CommitmentTiers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -161,12 +216,12 @@ public async Task GetCommitmentTiers_ListCommitmentTiers() Console.WriteLine($"Succeeded"); } - // ListModels + // ListLocationModels [NUnit.Framework.Test] [NUnit.Framework.Ignore("Only verifying that the sample builds")] - public async Task GetModels_ListModels() + public async Task GetModels_ListLocationModels() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListModels.json + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListLocationModels.json // this example is just showing the usage of "Models_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -189,5 +244,68 @@ public async Task GetModels_ListModels() Console.WriteLine($"Succeeded"); } + + // ListLocationBasedModelCapacities + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetLocationBasedModelCapacities_ListLocationBasedModelCapacities() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListLocationBasedModelCapacities.json + // this example is just showing the usage of "LocationBasedModelCapacities_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("WestUS"); + string modelFormat = "OpenAI"; + string modelName = "ada"; + string modelVersion = "1"; + await foreach (ModelCapacityListResultValueItem item in subscriptionResource.GetLocationBasedModelCapacitiesAsync(location, modelFormat, modelName, modelVersion)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } + + // ListModelCapacities + [NUnit.Framework.Test] + [NUnit.Framework.Ignore("Only verifying that the sample builds")] + public async Task GetModelCapacities_ListModelCapacities() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/preview/2024-06-01-preview/examples/ListModelCapacities.json + // this example is just showing the usage of "ModelCapacities_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string modelFormat = "OpenAI"; + string modelName = "ada"; + string modelVersion = "1"; + await foreach (ModelCapacityListResultValueItem item in subscriptionResource.GetModelCapacitiesAsync(modelFormat, modelName, modelVersion)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine($"Succeeded"); + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/ArmCognitiveServicesModelFactory.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/ArmCognitiveServicesModelFactory.cs index 694159ba6d6dd..4b99c5b3cd0d0 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/ArmCognitiveServicesModelFactory.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/ArmCognitiveServicesModelFactory.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using Azure.Core; using Azure.ResourceManager.Models; @@ -59,6 +60,7 @@ public static CognitiveServicesAccountData CognitiveServicesAccountData(Resource /// A collection of rules governing the accessibility from specific network locations. /// The encryption properties for this resource. /// The storage accounts for this resource. + /// The user owned AML workspace properties. /// The private endpoint connection associated with the Cognitive Services account. /// Whether or not public endpoint access is allowed for this account. /// The api properties for special APIs. @@ -76,8 +78,9 @@ public static CognitiveServicesAccountData CognitiveServicesAccountData(Resource /// The multiregion settings of Cognitive Services account. /// The commitment plan associations of Cognitive Services account. /// The abuse penalty. + /// Cognitive Services Rai Monitor Config. /// A new instance for mocking. - public static CognitiveServicesAccountProperties CognitiveServicesAccountProperties(ServiceAccountProvisioningState? provisioningState = null, string endpoint = null, IEnumerable capabilities = null, bool? isMigrated = null, string migrationToken = null, CognitiveServicesSkuChangeInfo skuChangeInfo = null, string customSubDomainName = null, CognitiveServicesNetworkRuleSet networkAcls = null, ServiceAccountEncryptionProperties encryption = null, IEnumerable userOwnedStorage = null, IEnumerable privateEndpointConnections = null, ServiceAccountPublicNetworkAccess? publicNetworkAccess = null, ServiceAccountApiProperties apiProperties = null, DateTimeOffset? createdOn = null, ServiceAccountCallRateLimit callRateLimit = null, bool? enableDynamicThrottling = null, ServiceAccountQuotaLimit quotaLimit = null, bool? restrictOutboundNetworkAccess = null, IEnumerable allowedFqdnList = null, bool? disableLocalAuth = null, IReadOnlyDictionary endpoints = null, bool? restore = null, DateTimeOffset? deletedOn = null, string scheduledPurgeDate = null, CognitiveServicesMultiRegionSettings locations = null, IEnumerable commitmentPlanAssociations = null, AbusePenalty abusePenalty = null) + public static CognitiveServicesAccountProperties CognitiveServicesAccountProperties(ServiceAccountProvisioningState? provisioningState = null, string endpoint = null, IEnumerable capabilities = null, bool? isMigrated = null, string migrationToken = null, CognitiveServicesSkuChangeInfo skuChangeInfo = null, string customSubDomainName = null, CognitiveServicesNetworkRuleSet networkAcls = null, ServiceAccountEncryptionProperties encryption = null, IEnumerable userOwnedStorage = null, UserOwnedAmlWorkspace amlWorkspace = null, IEnumerable privateEndpointConnections = null, ServiceAccountPublicNetworkAccess? publicNetworkAccess = null, ServiceAccountApiProperties apiProperties = null, DateTimeOffset? createdOn = null, ServiceAccountCallRateLimit callRateLimit = null, bool? enableDynamicThrottling = null, ServiceAccountQuotaLimit quotaLimit = null, bool? restrictOutboundNetworkAccess = null, IEnumerable allowedFqdnList = null, bool? disableLocalAuth = null, IReadOnlyDictionary endpoints = null, bool? restore = null, DateTimeOffset? deletedOn = null, string scheduledPurgeDate = null, CognitiveServicesMultiRegionSettings locations = null, IEnumerable commitmentPlanAssociations = null, AbusePenalty abusePenalty = null, RaiMonitorConfig raiMonitorConfig = null) { capabilities ??= new List(); userOwnedStorage ??= new List(); @@ -97,6 +100,7 @@ public static CognitiveServicesAccountProperties CognitiveServicesAccountPropert networkAcls, encryption, userOwnedStorage?.ToList(), + amlWorkspace, privateEndpointConnections?.ToList(), publicNetworkAccess, apiProperties, @@ -114,6 +118,7 @@ public static CognitiveServicesAccountProperties CognitiveServicesAccountPropert locations, commitmentPlanAssociations?.ToList(), abusePenalty, + raiMonitorConfig, serializedAdditionalRawData: null); } @@ -343,7 +348,7 @@ public static ServiceAccountUsageMetricName ServiceAccountUsageMetricName(string /// Optional. Deployment model version. If version is not specified, a default version will be assigned. The default version is different for different models and might change when there is new version available for a model. Default version for a model could be found from list models API. /// Optional. Deployment model source ARM resource ID. /// The call rate limit Cognitive Services account. - /// Base Model Identifier. + /// Properties of Cognitive Services account deployment model. /// If the model is default version. /// The list of Model Sku. /// The max capacity. @@ -401,10 +406,12 @@ public static CognitiveServicesAccountDeploymentModel CognitiveServicesAccountDe /// The datetime of deprecation of the model SKU. /// The capacity configuration. /// The list of rateLimit. + /// The list of billing meter info. /// A new instance for mocking. - public static CognitiveServicesModelSku CognitiveServicesModelSku(string name = null, string usageName = null, DateTimeOffset? deprecationOn = null, CognitiveServicesCapacityConfig capacity = null, IEnumerable rateLimits = null) + public static CognitiveServicesModelSku CognitiveServicesModelSku(string name = null, string usageName = null, DateTimeOffset? deprecationOn = null, CognitiveServicesCapacityConfig capacity = null, IEnumerable rateLimits = null, IEnumerable cost = null) { rateLimits ??= new List(); + cost ??= new List(); return new CognitiveServicesModelSku( name, @@ -412,6 +419,7 @@ public static CognitiveServicesModelSku CognitiveServicesModelSku(string name = deprecationOn, capacity, rateLimits?.ToList(), + cost?.ToList(), serializedAdditionalRawData: null); } @@ -478,13 +486,34 @@ public static CommitmentCost CommitmentCost(string commitmentMeterId = null, str } /// Initializes a new instance of . - /// Model Metadata. - /// The Kind of the Model. - /// The SKU of the Model. + /// Cognitive Services account Model. + /// The kind (type) of cognitive service account. + /// The name of SKU. + /// The description of the model. /// A new instance for mocking. - public static CognitiveServicesModel CognitiveServicesModel(CognitiveServicesAccountModel model = null, string kind = null, string skuName = null) + public static CognitiveServicesModel CognitiveServicesModel(CognitiveServicesAccountModel model = null, string kind = null, string skuName = null, string description = null) { - return new CognitiveServicesModel(model, kind, skuName, serializedAdditionalRawData: null); + return new CognitiveServicesModel(model, kind, skuName, description, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The location of the Model Sku Capacity. + /// Cognitive Services account ModelSkuCapacity. + /// A new instance for mocking. + public static ModelCapacityListResultValueItem ModelCapacityListResultValueItem(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, AzureLocation? location = null, ModelSkuCapacityProperties properties = null) + { + return new ModelCapacityListResultValueItem( + id, + name, + resourceType, + systemData, + location, + properties, + serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -515,6 +544,25 @@ public static CognitiveServicesDomainAvailabilityList CognitiveServicesDomainAva serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// Properties of Cognitive Services account deployment model. + /// + /// Model Estimated Capacity. + /// A new instance for mocking. + public static CalculateModelCapacityResult CalculateModelCapacityResult(CognitiveServicesAccountDeploymentModel model = null, string skuName = null, CalculateModelCapacityResultEstimatedCapacity estimatedCapacity = null) + { + return new CalculateModelCapacityResult(model, skuName, estimatedCapacity, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// + /// A new instance for mocking. + public static CalculateModelCapacityResultEstimatedCapacity CalculateModelCapacityResultEstimatedCapacity(int? value = null, int? deployableValue = null) + { + return new CalculateModelCapacityResultEstimatedCapacity(value, deployableValue, serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The id. /// The name. @@ -554,10 +602,13 @@ public static CognitiveServicesPrivateLinkResourceProperties CognitiveServicesPr /// The systemData. /// The resource model definition representing SKU. /// Resource Etag. + /// Resource tags. /// Properties of Cognitive Services account deployment. /// A new instance for mocking. - public static CognitiveServicesAccountDeploymentData CognitiveServicesAccountDeploymentData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, CognitiveServicesSku sku = null, ETag? etag = null, CognitiveServicesAccountDeploymentProperties properties = null) + public static CognitiveServicesAccountDeploymentData CognitiveServicesAccountDeploymentData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, CognitiveServicesSku sku = null, ETag? etag = null, IDictionary tags = null, CognitiveServicesAccountDeploymentProperties properties = null) { + tags ??= new Dictionary(); + return new CognitiveServicesAccountDeploymentData( id, name, @@ -565,6 +616,7 @@ public static CognitiveServicesAccountDeploymentData CognitiveServicesAccountDep systemData, sku, etag, + tags, properties, serializedAdditionalRawData: null); } @@ -572,14 +624,17 @@ public static CognitiveServicesAccountDeploymentData CognitiveServicesAccountDep /// Initializes a new instance of . /// Gets the status of the resource at the time the operation was called. /// Properties of Cognitive Services account deployment model. - /// Properties of Cognitive Services account deployment model. + /// Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku instead.). /// The capabilities. /// The name of RAI policy. /// The call rate limit Cognitive Services account. /// /// Deployment model version upgrade option. + /// If the dynamic throttling is enabled. + /// The current capacity. + /// Internal use only. /// A new instance for mocking. - public static CognitiveServicesAccountDeploymentProperties CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDeploymentProvisioningState? provisioningState = null, CognitiveServicesAccountDeploymentModel model = null, CognitiveServicesAccountDeploymentScaleSettings scaleSettings = null, IReadOnlyDictionary capabilities = null, string raiPolicyName = null, ServiceAccountCallRateLimit callRateLimit = null, IEnumerable rateLimits = null, DeploymentModelVersionUpgradeOption? versionUpgradeOption = null) + public static CognitiveServicesAccountDeploymentProperties CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDeploymentProvisioningState? provisioningState = null, CognitiveServicesAccountDeploymentModel model = null, CognitiveServicesAccountDeploymentScaleSettings scaleSettings = null, IReadOnlyDictionary capabilities = null, string raiPolicyName = null, ServiceAccountCallRateLimit callRateLimit = null, IEnumerable rateLimits = null, DeploymentModelVersionUpgradeOption? versionUpgradeOption = null, bool? dynamicThrottlingEnabled = null, int? currentCapacity = null, DeploymentCapacitySettings capacitySettings = null) { capabilities ??= new Dictionary(); rateLimits ??= new List(); @@ -593,6 +648,9 @@ public static CognitiveServicesAccountDeploymentProperties CognitiveServicesAcco callRateLimit, rateLimits?.ToList(), versionUpgradeOption, + dynamicThrottlingEnabled, + currentCapacity, + capacitySettings, serializedAdditionalRawData: null); } @@ -606,6 +664,16 @@ public static CognitiveServicesAccountDeploymentScaleSettings CognitiveServicesA return new CognitiveServicesAccountDeploymentScaleSettings(scaleType, capacity, activeCapacity, serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// The resource type name. + /// The resource model definition representing SKU. + /// The capacity configuration. + /// A new instance for mocking. + public static SkuResource SkuResource(string resourceType = null, CognitiveServicesSku sku = null, CognitiveServicesCapacityConfig capacity = null) + { + return new SkuResource(resourceType, sku, capacity, serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The id. /// The name. @@ -682,24 +750,340 @@ public static CommitmentPeriod CommitmentPeriod(string tier = null, int? count = serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services EncryptionScope. + /// A new instance for mocking. + public static EncryptionScopeData EncryptionScopeData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, IDictionary tags = null, EncryptionScopeProperties properties = null) + { + tags ??= new Dictionary(); + + return new EncryptionScopeData( + id, + name, + resourceType, + systemData, + etag, + tags, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Properties of KeyVault. + /// Enumerates the possible value of keySource for Encryption. + /// Gets the status of the resource at the time the operation was called. + /// The encryptionScope state. + /// A new instance for mocking. + public static EncryptionScopeProperties EncryptionScopeProperties(CognitiveServicesKeyVaultProperties keyVaultProperties = null, ServiceAccountEncryptionKeySource? keySource = null, EncryptionScopeProvisioningState? provisioningState = null, EncryptionScopeState? state = null) + { + return new EncryptionScopeProperties(keyVaultProperties, keySource, serializedAdditionalRawData: null, provisioningState, state); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services RaiPolicy. + /// A new instance for mocking. + public static RaiPolicyData RaiPolicyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, IDictionary tags = null, RaiPolicyProperties properties = null) + { + tags ??= new Dictionary(); + + return new RaiPolicyData( + id, + name, + resourceType, + systemData, + etag, + tags, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Content Filters policy type. + /// Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, Asynchronous_filter =3. Please use 'Asynchronous_filter' after 2024-06-01-preview. It is the same as 'Deferred' in previous version. + /// Name of Rai policy. + /// The list of Content Filters. + /// The list of custom Blocklist. + /// A new instance for mocking. + public static RaiPolicyProperties RaiPolicyProperties(RaiPolicyType? policyType = null, RaiPolicyMode? mode = null, string basePolicyName = null, IEnumerable contentFilters = null, IEnumerable customBlocklists = null) + { + contentFilters ??= new List(); + customBlocklists ??= new List(); + + return new RaiPolicyProperties( + policyType, + mode, + basePolicyName, + contentFilters?.ToList(), + customBlocklists?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services RaiBlocklist. + /// A new instance for mocking. + public static RaiBlocklistData RaiBlocklistData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, IDictionary tags = null, string raiBlocklistDescription = null) + { + tags ??= new Dictionary(); + + return new RaiBlocklistData( + id, + name, + resourceType, + systemData, + etag, + tags, + raiBlocklistDescription != null ? new RaiBlocklistProperties(raiBlocklistDescription, serializedAdditionalRawData: null) : null, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services RaiBlocklist Item. + /// A new instance for mocking. + public static RaiBlocklistItemData RaiBlocklistItemData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, IDictionary tags = null, RaiBlocklistItemProperties properties = null) + { + tags ??= new Dictionary(); + + return new RaiBlocklistItemData( + id, + name, + resourceType, + systemData, + etag, + tags, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Azure OpenAI Content Filter Properties. + /// A new instance for mocking. + public static RaiContentFilterData RaiContentFilterData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, RaiContentFilterProperties properties = null) + { + return new RaiContentFilterData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The id. /// The name. /// The resourceType. /// The systemData. /// Resource Etag. + /// Resource tags. /// The Azure resource id of the account. /// A new instance for mocking. - public static CommitmentPlanAccountAssociationData CommitmentPlanAccountAssociationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, string accountId = null) + public static CommitmentPlanAccountAssociationData CommitmentPlanAccountAssociationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, IDictionary tags = null, string accountId = null) { + tags ??= new Dictionary(); + return new CommitmentPlanAccountAssociationData( id, name, resourceType, systemData, etag, + tags, accountId, serializedAdditionalRawData: null); } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// NSP Configuration properties. + /// A new instance for mocking. + public static NetworkSecurityPerimeterConfigurationData NetworkSecurityPerimeterConfigurationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, NetworkSecurityPerimeterConfigurationProperties properties = null) + { + return new NetworkSecurityPerimeterConfigurationData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Provisioning state of NetworkSecurityPerimeter configuration. + /// List of Provisioning Issues. + /// Information about a linked Network Security Perimeter. + /// Network Security Perimeter Configuration Association Information. + /// Network Security Perimeter Profile Information. + /// A new instance for mocking. + public static NetworkSecurityPerimeterConfigurationProperties NetworkSecurityPerimeterConfigurationProperties(string provisioningState = null, IEnumerable provisioningIssues = null, NetworkSecurityPerimeter networkSecurityPerimeter = null, NetworkSecurityPerimeterConfigurationAssociationInfo resourceAssociation = null, NetworkSecurityPerimeterProfileInfo profile = null) + { + provisioningIssues ??= new List(); + + return new NetworkSecurityPerimeterConfigurationProperties( + provisioningState, + provisioningIssues?.ToList(), + networkSecurityPerimeter, + resourceAssociation, + profile, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Defender for AI state on the AI resource. + /// A new instance for mocking. + public static DefenderForAISettingData DefenderForAISettingData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, ETag? etag = null, IDictionary tags = null, DefenderForAISettingState? state = null) + { + tags ??= new Dictionary(); + + return new DefenderForAISettingData( + id, + name, + resourceType, + systemData, + etag, + tags, + state, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets the status of the cognitive services account at the time the operation was called. + /// Endpoint of the created account. + /// Gets the capabilities of the cognitive services account. Each item indicates the capability of a specific feature. The values are read-only and for reference only. + /// If the resource is migrated from an existing key. + /// Resource migration token. + /// Sku change info of account. + /// Optional subdomain name used for token-based authentication. + /// A collection of rules governing the accessibility from specific network locations. + /// The encryption properties for this resource. + /// The storage accounts for this resource. + /// The private endpoint connection associated with the Cognitive Services account. + /// Whether or not public endpoint access is allowed for this account. + /// The api properties for special APIs. + /// Gets the date of cognitive services account creation. + /// The call rate limit Cognitive Services account. + /// The flag to enable dynamic throttling. + /// + /// + /// + /// + /// Dictionary of <string>. + /// + /// The deletion date, only available for deleted account. + /// The scheduled purge date, only available for deleted account. + /// The multiregion settings of Cognitive Services account. + /// The commitment plan associations of Cognitive Services account. + /// The abuse penalty. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static CognitiveServicesAccountProperties CognitiveServicesAccountProperties(ServiceAccountProvisioningState? provisioningState, string endpoint, IEnumerable capabilities, bool? isMigrated, string migrationToken, CognitiveServicesSkuChangeInfo skuChangeInfo, string customSubDomainName, CognitiveServicesNetworkRuleSet networkAcls, ServiceAccountEncryptionProperties encryption, IEnumerable userOwnedStorage, IEnumerable privateEndpointConnections, ServiceAccountPublicNetworkAccess? publicNetworkAccess, ServiceAccountApiProperties apiProperties, DateTimeOffset? createdOn, ServiceAccountCallRateLimit callRateLimit, bool? enableDynamicThrottling, ServiceAccountQuotaLimit quotaLimit, bool? restrictOutboundNetworkAccess, IEnumerable allowedFqdnList, bool? disableLocalAuth, IReadOnlyDictionary endpoints, bool? restore, DateTimeOffset? deletedOn, string scheduledPurgeDate, CognitiveServicesMultiRegionSettings locations, IEnumerable commitmentPlanAssociations, AbusePenalty abusePenalty) + { + return CognitiveServicesAccountProperties(provisioningState: provisioningState, endpoint: endpoint, capabilities: capabilities, isMigrated: isMigrated, migrationToken: migrationToken, skuChangeInfo: skuChangeInfo, customSubDomainName: customSubDomainName, networkAcls: networkAcls, encryption: encryption, userOwnedStorage: userOwnedStorage, amlWorkspace: default, privateEndpointConnections: privateEndpointConnections, publicNetworkAccess: publicNetworkAccess, apiProperties: apiProperties, createdOn: createdOn, callRateLimit: callRateLimit, enableDynamicThrottling: enableDynamicThrottling, quotaLimit: quotaLimit, restrictOutboundNetworkAccess: restrictOutboundNetworkAccess, allowedFqdnList: allowedFqdnList, disableLocalAuth: disableLocalAuth, endpoints: endpoints, restore: restore, deletedOn: deletedOn, scheduledPurgeDate: scheduledPurgeDate, locations: locations, commitmentPlanAssociations: commitmentPlanAssociations, abusePenalty: abusePenalty, raiMonitorConfig: default); + } + + /// Initializes a new instance of . + /// The name of the model SKU. + /// The usage name of the model SKU. + /// The datetime of deprecation of the model SKU. + /// The capacity configuration. + /// The list of rateLimit. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static CognitiveServicesModelSku CognitiveServicesModelSku(string name, string usageName, DateTimeOffset? deprecationOn, CognitiveServicesCapacityConfig capacity, IEnumerable rateLimits) + { + return CognitiveServicesModelSku(name: name, usageName: usageName, deprecationOn: deprecationOn, capacity: capacity, rateLimits: rateLimits, cost: default); + } + + /// Initializes a new instance of . + /// Model Metadata. + /// The Kind of the Model. + /// The SKU of the Model. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static CognitiveServicesModel CognitiveServicesModel(CognitiveServicesAccountModel model, string kind, string skuName) + { + return CognitiveServicesModel(model: model, kind: kind, skuName: skuName, description: default); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource model definition representing SKU. + /// Resource Etag. + /// Properties of Cognitive Services account deployment. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static CognitiveServicesAccountDeploymentData CognitiveServicesAccountDeploymentData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, CognitiveServicesSku sku, ETag? etag, CognitiveServicesAccountDeploymentProperties properties) + { + return CognitiveServicesAccountDeploymentData(id: id, name: name, resourceType: resourceType, systemData: systemData, sku: sku, etag: etag, tags: default, properties: properties); + } + + /// Initializes a new instance of . + /// Gets the status of the resource at the time the operation was called. + /// Properties of Cognitive Services account deployment model. + /// Properties of Cognitive Services account deployment model. + /// The capabilities. + /// The name of RAI policy. + /// The call rate limit Cognitive Services account. + /// + /// Deployment model version upgrade option. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static CognitiveServicesAccountDeploymentProperties CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDeploymentProvisioningState? provisioningState, CognitiveServicesAccountDeploymentModel model, CognitiveServicesAccountDeploymentScaleSettings scaleSettings, IReadOnlyDictionary capabilities, string raiPolicyName, ServiceAccountCallRateLimit callRateLimit, IEnumerable rateLimits, DeploymentModelVersionUpgradeOption? versionUpgradeOption) + { + return CognitiveServicesAccountDeploymentProperties(provisioningState: provisioningState, model: model, scaleSettings: scaleSettings, capabilities: capabilities, raiPolicyName: raiPolicyName, callRateLimit: callRateLimit, rateLimits: rateLimits, versionUpgradeOption: versionUpgradeOption, dynamicThrottlingEnabled: default, currentCapacity: default, capacitySettings: default); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// The Azure resource id of the account. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static CommitmentPlanAccountAssociationData CommitmentPlanAccountAssociationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, string accountId) + { + return CommitmentPlanAccountAssociationData(id: id, name: name, resourceType: resourceType, systemData: systemData, etag: etag, tags: default, accountId: accountId); + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountCollection.cs index 09d8bda433d19..bdbf83698b2c9 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountCollection.cs @@ -65,7 +65,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -114,7 +114,7 @@ public virtual async Task> Create /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -163,7 +163,7 @@ public virtual ArmOperation CreateOrUpdate(Wai /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -208,7 +208,7 @@ public virtual async Task> GetAsync(s /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -253,7 +253,7 @@ public virtual Response Get(string accountName /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -283,7 +283,7 @@ public virtual AsyncPageable GetAllAsync(Cance /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -313,7 +313,7 @@ public virtual Pageable GetAll(CancellationTok /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -356,7 +356,7 @@ public virtual async Task> ExistsAsync(string accountName, Cancel /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -399,7 +399,7 @@ public virtual Response Exists(string accountName, CancellationToken cance /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -444,7 +444,7 @@ public virtual async Task> Ge /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentCollection.cs index e6890065c49e3..f6bba2b6b9f5b 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentCollection.cs @@ -64,7 +64,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -113,7 +113,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -162,7 +162,7 @@ public virtual ArmOperation CreateOr /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -207,7 +207,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -252,7 +252,7 @@ public virtual Response Get(string d /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -282,7 +282,7 @@ public virtual AsyncPageable GetAllA /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -312,7 +312,7 @@ public virtual Pageable GetAll(Cance /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -355,7 +355,7 @@ public virtual async Task> ExistsAsync(string deploymentName, Can /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -398,7 +398,7 @@ public virtual Response Exists(string deploymentName, CancellationToken ca /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -443,7 +443,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.Serialization.cs index d4653edae5da5..39530c964d6fd 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Text.Json; using Azure.Core; @@ -39,6 +40,17 @@ void IJsonModel.Write(Utf8JsonWriter wri writer.WritePropertyName("etag"u8); writer.WriteStringValue(ETag.Value.ToString()); } + 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(); + } if (Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); @@ -104,6 +116,7 @@ internal static CognitiveServicesAccountDeploymentData DeserializeCognitiveServi } CognitiveServicesSku sku = default; ETag? etag = default; + IDictionary tags = default; CognitiveServicesAccountDeploymentProperties properties = default; ResourceIdentifier id = default; string name = default; @@ -131,6 +144,20 @@ internal static CognitiveServicesAccountDeploymentData DeserializeCognitiveServi etag = new ETag(property.Value.GetString()); continue; } + 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) @@ -177,6 +204,7 @@ internal static CognitiveServicesAccountDeploymentData DeserializeCognitiveServi systemData, sku, etag, + tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); } @@ -215,6 +243,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); if (hasPropertyOverride) { diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.cs index 9f1c76d9d33c7..bdf7d73ae8c8d 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentData.cs @@ -54,6 +54,7 @@ public partial class CognitiveServicesAccountDeploymentData : ResourceData /// Initializes a new instance of . public CognitiveServicesAccountDeploymentData() { + Tags = new ChangeTrackingDictionary(); } /// Initializes a new instance of . @@ -63,12 +64,14 @@ public CognitiveServicesAccountDeploymentData() /// The systemData. /// The resource model definition representing SKU. /// Resource Etag. + /// Resource tags. /// Properties of Cognitive Services account deployment. /// Keeps track of any properties unknown to the library. - internal CognitiveServicesAccountDeploymentData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, CognitiveServicesSku sku, ETag? etag, CognitiveServicesAccountDeploymentProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal CognitiveServicesAccountDeploymentData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, CognitiveServicesSku sku, ETag? etag, IDictionary tags, CognitiveServicesAccountDeploymentProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { Sku = sku; ETag = etag; + Tags = tags; Properties = properties; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -79,6 +82,9 @@ internal CognitiveServicesAccountDeploymentData(ResourceIdentifier id, string na /// Resource Etag. [WirePath("etag")] public ETag? ETag { get; } + /// Resource tags. + [WirePath("tags")] + public IDictionary Tags { get; } /// Properties of Cognitive Services account deployment. [WirePath("properties")] public CognitiveServicesAccountDeploymentProperties Properties { get; set; } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentResource.cs index 5daa9aefcabd4..b28788871f3b3 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountDeploymentResource.cs @@ -6,11 +6,14 @@ #nullable disable using System; +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; +using Azure.ResourceManager.CognitiveServices.Models; namespace Azure.ResourceManager.CognitiveServices { @@ -101,7 +104,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -141,7 +144,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -181,7 +184,7 @@ public virtual Response Get(Cancella /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -223,7 +226,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -253,7 +256,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update the state of specified deployments associated with the Cognitive Services account. + /// Update specified deployments associated with the Cognitive Services account. /// /// /// Request Path @@ -261,11 +264,11 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Operation Id - /// Deployments_CreateOrUpdate + /// Deployments_Update /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -274,19 +277,19 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// 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 deployment properties. + /// The deployment properties. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, CognitiveServicesAccountDeploymentData data, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, PatchResourceTagsAndSku deployment, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(deployment, nameof(deployment)); using var scope = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.Update"); scope.Start(); try { - var response = await _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); - var operation = new CognitiveServicesArmOperation(new CognitiveServicesAccountDeploymentOperationSource(Client), _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics, Pipeline, _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + var response = await _cognitiveServicesAccountDeploymentDeploymentsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deployment, cancellationToken).ConfigureAwait(false); + var operation = new CognitiveServicesArmOperation(new CognitiveServicesAccountDeploymentOperationSource(Client), _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics, Pipeline, _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deployment).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -299,7 +302,7 @@ public virtual async Task - /// Update the state of specified deployments associated with the Cognitive Services account. + /// Update specified deployments associated with the Cognitive Services account. /// /// /// Request Path @@ -307,11 +310,11 @@ public virtual async Task /// /// Operation Id - /// Deployments_CreateOrUpdate + /// Deployments_Update /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -320,19 +323,19 @@ public virtual async Task /// /// 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 deployment properties. + /// The deployment properties. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, CognitiveServicesAccountDeploymentData data, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, PatchResourceTagsAndSku deployment, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(deployment, nameof(deployment)); using var scope = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.Update"); scope.Start(); try { - var response = _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); - var operation = new CognitiveServicesArmOperation(new CognitiveServicesAccountDeploymentOperationSource(Client), _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics, Pipeline, _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + var response = _cognitiveServicesAccountDeploymentDeploymentsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deployment, cancellationToken); + var operation = new CognitiveServicesArmOperation(new CognitiveServicesAccountDeploymentOperationSource(Client), _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics, Pipeline, _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deployment).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; @@ -343,5 +346,423 @@ public virtual ArmOperation Update(W throw; } } + + /// + /// Lists the specified deployments skus associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}/skus + /// + /// + /// Operation Id + /// Deployments_ListSkus + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetSkusAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateListSkusRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateListSkusNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => SkuResource.DeserializeSkuResource(e), _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics, Pipeline, "CognitiveServicesAccountDeploymentResource.GetSkus", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the specified deployments skus associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}/skus + /// + /// + /// Operation Id + /// Deployments_ListSkus + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetSkus(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateListSkusRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _cognitiveServicesAccountDeploymentDeploymentsRestClient.CreateListSkusNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => SkuResource.DeserializeSkuResource(e), _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics, Pipeline, "CognitiveServicesAccountDeploymentResource.GetSkus", "value", "nextLink", cancellationToken); + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.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 _cognitiveServicesAccountDeploymentDeploymentsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CognitiveServicesAccountDeploymentResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new PatchResourceTagsAndSku(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.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 = _cognitiveServicesAccountDeploymentDeploymentsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CognitiveServicesAccountDeploymentResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new PatchResourceTagsAndSku(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.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 _cognitiveServicesAccountDeploymentDeploymentsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CognitiveServicesAccountDeploymentResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new PatchResourceTagsAndSku(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.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 = _cognitiveServicesAccountDeploymentDeploymentsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CognitiveServicesAccountDeploymentResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new PatchResourceTagsAndSku(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.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 _cognitiveServicesAccountDeploymentDeploymentsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CognitiveServicesAccountDeploymentResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new PatchResourceTagsAndSku(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _cognitiveServicesAccountDeploymentDeploymentsClientDiagnostics.CreateScope("CognitiveServicesAccountDeploymentResource.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 = _cognitiveServicesAccountDeploymentDeploymentsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CognitiveServicesAccountDeploymentResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new PatchResourceTagsAndSku(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountResource.cs index 1424ae28761b8..3bcf10fb4e661 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesAccountResource.cs @@ -115,7 +115,7 @@ public virtual CognitiveServicesPrivateEndpointConnectionCollection GetCognitive /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -146,7 +146,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -184,7 +184,7 @@ public virtual CognitiveServicesAccountDeploymentCollection GetCognitiveServices /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -215,7 +215,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -253,7 +253,7 @@ public virtual CommitmentPlanCollection GetCommitmentPlans() /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -284,7 +284,7 @@ public virtual async Task> GetCommitmentPlanAsy /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -302,6 +302,351 @@ public virtual Response GetCommitmentPlan(string commitm return GetCommitmentPlans().Get(commitmentPlanName, cancellationToken); } + /// Gets a collection of EncryptionScopeResources in the CognitiveServicesAccount. + /// An object representing collection of EncryptionScopeResources and their operations over a EncryptionScopeResource. + public virtual EncryptionScopeCollection GetEncryptionScopes() + { + return GetCachedClient(client => new EncryptionScopeCollection(client, Id)); + } + + /// + /// Gets the specified EncryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetEncryptionScopeAsync(string encryptionScopeName, CancellationToken cancellationToken = default) + { + return await GetEncryptionScopes().GetAsync(encryptionScopeName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified EncryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetEncryptionScope(string encryptionScopeName, CancellationToken cancellationToken = default) + { + return GetEncryptionScopes().Get(encryptionScopeName, cancellationToken); + } + + /// Gets a collection of RaiPolicyResources in the CognitiveServicesAccount. + /// An object representing collection of RaiPolicyResources and their operations over a RaiPolicyResource. + public virtual RaiPolicyCollection GetRaiPolicies() + { + return GetCachedClient(client => new RaiPolicyCollection(client, Id)); + } + + /// + /// Gets the specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetRaiPolicyAsync(string raiPolicyName, CancellationToken cancellationToken = default) + { + return await GetRaiPolicies().GetAsync(raiPolicyName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetRaiPolicy(string raiPolicyName, CancellationToken cancellationToken = default) + { + return GetRaiPolicies().Get(raiPolicyName, cancellationToken); + } + + /// Gets a collection of RaiBlocklistResources in the CognitiveServicesAccount. + /// An object representing collection of RaiBlocklistResources and their operations over a RaiBlocklistResource. + public virtual RaiBlocklistCollection GetRaiBlocklists() + { + return GetCachedClient(client => new RaiBlocklistCollection(client, Id)); + } + + /// + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetRaiBlocklistAsync(string raiBlocklistName, CancellationToken cancellationToken = default) + { + return await GetRaiBlocklists().GetAsync(raiBlocklistName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetRaiBlocklist(string raiBlocklistName, CancellationToken cancellationToken = default) + { + return GetRaiBlocklists().Get(raiBlocklistName, cancellationToken); + } + + /// Gets a collection of NetworkSecurityPerimeterConfigurationResources in the CognitiveServicesAccount. + /// An object representing collection of NetworkSecurityPerimeterConfigurationResources and their operations over a NetworkSecurityPerimeterConfigurationResource. + public virtual NetworkSecurityPerimeterConfigurationCollection GetNetworkSecurityPerimeterConfigurations() + { + return GetCachedClient(client => new NetworkSecurityPerimeterConfigurationCollection(client, Id)); + } + + /// + /// Gets the specified NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNetworkSecurityPerimeterConfigurationAsync(string nspConfigurationName, CancellationToken cancellationToken = default) + { + return await GetNetworkSecurityPerimeterConfigurations().GetAsync(nspConfigurationName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNetworkSecurityPerimeterConfiguration(string nspConfigurationName, CancellationToken cancellationToken = default) + { + return GetNetworkSecurityPerimeterConfigurations().Get(nspConfigurationName, cancellationToken); + } + + /// Gets a collection of DefenderForAISettingResources in the CognitiveServicesAccount. + /// An object representing collection of DefenderForAISettingResources and their operations over a DefenderForAISettingResource. + public virtual DefenderForAISettingCollection GetDefenderForAISettings() + { + return GetCachedClient(client => new DefenderForAISettingCollection(client, Id)); + } + + /// + /// Gets the specified Defender for AI setting by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDefenderForAISettingAsync(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + return await GetDefenderForAISettings().GetAsync(defenderForAISettingName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Defender for AI setting by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDefenderForAISetting(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + return GetDefenderForAISettings().Get(defenderForAISettingName, cancellationToken); + } + /// /// Returns a Cognitive Services account specified by the parameters. /// @@ -315,7 +660,7 @@ public virtual Response GetCommitmentPlan(string commitm /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -355,7 +700,7 @@ public virtual async Task> GetAsync(C /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -395,7 +740,7 @@ public virtual Response Get(CancellationToken /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -437,7 +782,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -479,7 +824,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -525,7 +870,7 @@ public virtual async Task> Update /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -571,7 +916,7 @@ public virtual ArmOperation Update(WaitUntil w /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -609,7 +954,7 @@ public virtual async Task> GetKeysAsync(Cancella /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -647,7 +992,7 @@ public virtual Response GetKeys(CancellationToken cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -689,7 +1034,7 @@ public virtual async Task> RegenerateKeyAsync(Re /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -731,7 +1076,7 @@ public virtual Response RegenerateKey(RegenerateServiceAc /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -760,7 +1105,7 @@ public virtual AsyncPageable GetSkusAsync(Cancellat /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -789,7 +1134,7 @@ public virtual Pageable GetSkus(CancellationToken c /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -819,7 +1164,7 @@ public virtual AsyncPageable GetUsagesAsync(string filter = /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -849,7 +1194,7 @@ public virtual Pageable GetUsages(string filter = null, Can /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -879,7 +1224,7 @@ public virtual AsyncPageable GetModelsAsync(Cance /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -909,7 +1254,7 @@ public virtual Pageable GetModels(CancellationTok /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -934,7 +1279,7 @@ public virtual AsyncPageable GetPrivateLin /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -959,7 +1304,7 @@ public virtual Pageable GetPrivateLinkReso /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -1021,7 +1366,7 @@ public virtual async Task> AddTagAsyn /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -1083,7 +1428,7 @@ public virtual Response AddTag(string key, str /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -1140,7 +1485,7 @@ public virtual async Task> SetTagsAsy /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -1197,7 +1542,7 @@ public virtual Response SetTags(IDictionary /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -1257,7 +1602,7 @@ public virtual async Task> RemoveTagA /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanCollection.cs index 3b26950989a2e..8ff77dee83d53 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanCollection.cs @@ -65,7 +65,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -114,7 +114,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -163,7 +163,7 @@ public virtual ArmOperation CreateOrUpd /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -208,7 +208,7 @@ public virtual async Task> Get /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -253,7 +253,7 @@ public virtual Response Get(string comm /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -283,7 +283,7 @@ public virtual AsyncPageable GetAllAsyn /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -313,7 +313,7 @@ public virtual Pageable GetAll(Cancella /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -356,7 +356,7 @@ public virtual async Task> ExistsAsync(string commitmentPlanName, /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -399,7 +399,7 @@ public virtual Response Exists(string commitmentPlanName, CancellationToke /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -444,7 +444,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanResource.cs index f6ea735365ab2..87d23f466b6ce 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesCommitmentPlanResource.cs @@ -110,7 +110,7 @@ public virtual CommitmentPlanAccountAssociationCollection GetCommitmentPlanAccou /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -141,7 +141,7 @@ public virtual async Task> Ge /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -172,7 +172,7 @@ public virtual Response GetCommitmentP /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -212,7 +212,7 @@ public virtual async Task> Get /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -252,7 +252,7 @@ public virtual Response Get(Cancellatio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -294,7 +294,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -336,7 +336,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -345,19 +345,19 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// 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 parameters to provide for the created commitment plan. + /// The parameters to provide for the created commitment plan. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, CognitiveServicesCommitmentPlanPatch patch, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, PatchResourceTagsAndSku commitmentPlan, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); + Argument.AssertNotNull(commitmentPlan, nameof(commitmentPlan)); using var scope = _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics.CreateScope("CognitiveServicesCommitmentPlanResource.Update"); scope.Start(); try { - var response = await _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.UpdatePlanAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new CognitiveServicesArmOperation(new CognitiveServicesCommitmentPlanOperationSource(Client), _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics, Pipeline, _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.CreateUpdatePlanRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + var response = await _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.UpdatePlanAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, commitmentPlan, cancellationToken).ConfigureAwait(false); + var operation = new CognitiveServicesArmOperation(new CognitiveServicesCommitmentPlanOperationSource(Client), _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics, Pipeline, _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.CreateUpdatePlanRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, commitmentPlan).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -382,7 +382,7 @@ public virtual async Task> /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -391,19 +391,19 @@ public virtual async Task> /// /// /// 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 parameters to provide for the created commitment plan. + /// The parameters to provide for the created commitment plan. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, CognitiveServicesCommitmentPlanPatch patch, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, PatchResourceTagsAndSku commitmentPlan, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); + Argument.AssertNotNull(commitmentPlan, nameof(commitmentPlan)); using var scope = _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics.CreateScope("CognitiveServicesCommitmentPlanResource.Update"); scope.Start(); try { - var response = _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.UpdatePlan(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - var operation = new CognitiveServicesArmOperation(new CognitiveServicesCommitmentPlanOperationSource(Client), _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics, Pipeline, _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.CreateUpdatePlanRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + var response = _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.UpdatePlan(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, commitmentPlan, cancellationToken); + var operation = new CognitiveServicesArmOperation(new CognitiveServicesCommitmentPlanOperationSource(Client), _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics, Pipeline, _cognitiveServicesCommitmentPlanCommitmentPlansRestClient.CreateUpdatePlanRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, commitmentPlan).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; @@ -428,7 +428,7 @@ public virtual ArmOperation Update(Wait /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -460,7 +460,7 @@ public virtual async Task> Add else { var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new CognitiveServicesCommitmentPlanPatch(); + var patch = new PatchResourceTagsAndSku(); foreach (var tag in current.Tags) { patch.Tags.Add(tag); @@ -490,7 +490,7 @@ public virtual async Task> Add /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -522,7 +522,7 @@ public virtual Response AddTag(string k else { var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new CognitiveServicesCommitmentPlanPatch(); + var patch = new PatchResourceTagsAndSku(); foreach (var tag in current.Tags) { patch.Tags.Add(tag); @@ -552,7 +552,7 @@ public virtual Response AddTag(string k /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -583,7 +583,7 @@ public virtual async Task> Set else { var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new CognitiveServicesCommitmentPlanPatch(); + var patch = new PatchResourceTagsAndSku(); patch.Tags.ReplaceWith(tags); var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); @@ -609,7 +609,7 @@ public virtual async Task> Set /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -640,7 +640,7 @@ public virtual Response SetTags(IDictio else { var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new CognitiveServicesCommitmentPlanPatch(); + var patch = new PatchResourceTagsAndSku(); patch.Tags.ReplaceWith(tags); var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); @@ -666,7 +666,7 @@ public virtual Response SetTags(IDictio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -696,7 +696,7 @@ public virtual async Task> Rem else { var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new CognitiveServicesCommitmentPlanPatch(); + var patch = new PatchResourceTagsAndSku(); foreach (var tag in current.Tags) { patch.Tags.Add(tag); @@ -726,7 +726,7 @@ public virtual async Task> Rem /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -756,7 +756,7 @@ public virtual Response RemoveTag(strin else { var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new CognitiveServicesCommitmentPlanPatch(); + var patch = new PatchResourceTagsAndSku(); foreach (var tag in current.Tags) { patch.Tags.Add(tag); diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountCollection.cs index 99944912ebe60..aaa6d1b284366 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountCollection.cs @@ -62,7 +62,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -110,7 +110,7 @@ public virtual async Task> Get /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -158,7 +158,7 @@ public virtual Response Get(AzureLocati /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -204,7 +204,7 @@ public virtual async Task> ExistsAsync(AzureLocation location, st /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -250,7 +250,7 @@ public virtual Response Exists(AzureLocation location, string resourceGrou /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -298,7 +298,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountResource.cs index 887a48045d228..f8455d5e4ff8e 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesDeletedAccountResource.cs @@ -102,7 +102,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -142,7 +142,7 @@ public virtual async Task> Get /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -182,7 +182,7 @@ public virtual Response Get(Cancellatio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -224,7 +224,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionCollection.cs index 891828855443f..db0cb4de7b14d 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionCollection.cs @@ -64,7 +64,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -109,7 +109,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -154,7 +154,7 @@ public virtual Response Get( /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -183,7 +183,7 @@ public virtual AsyncPageable /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -212,7 +212,7 @@ public virtual Pageable GetA /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -255,7 +255,7 @@ public virtual async Task> ExistsAsync(string privateEndpointConn /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -298,7 +298,7 @@ public virtual Response Exists(string privateEndpointConnectionName, Cance /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -343,7 +343,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionResource.cs index cf0c4228fe816..7b783ee6b2181 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CognitiveServicesPrivateEndpointConnectionResource.cs @@ -101,7 +101,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -141,7 +141,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -181,7 +181,7 @@ public virtual Response Get( /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -223,7 +223,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationCollection.cs index e0949d1818925..7ce53d372b347 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationCollection.cs @@ -64,7 +64,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -113,7 +113,7 @@ public virtual async Task /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -162,7 +162,7 @@ public virtual ArmOperation CreateOrUp /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -207,7 +207,7 @@ public virtual async Task> Ge /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -252,7 +252,7 @@ public virtual Response Get(string com /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -282,7 +282,7 @@ public virtual AsyncPageable GetAllAsy /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -312,7 +312,7 @@ public virtual Pageable GetAll(Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -355,7 +355,7 @@ public virtual async Task> ExistsAsync(string commitmentPlanAssoc /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -398,7 +398,7 @@ public virtual Response Exists(string commitmentPlanAssociationName, Cance /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -443,7 +443,7 @@ public virtual async Task /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.Serialization.cs index 0e4c078e27c13..7fd4e7b308fb4 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Text.Json; using Azure.Core; @@ -33,6 +34,17 @@ void IJsonModel.Write(Utf8JsonWriter write writer.WritePropertyName("etag"u8); writer.WriteStringValue(ETag.Value.ToString()); } + 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(); + } if (options.Format != "W") { writer.WritePropertyName("id"u8); @@ -100,6 +112,7 @@ internal static CommitmentPlanAccountAssociationData DeserializeCommitmentPlanAc return null; } ETag? etag = default; + IDictionary tags = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; @@ -118,6 +131,20 @@ internal static CommitmentPlanAccountAssociationData DeserializeCommitmentPlanAc etag = new ETag(property.Value.GetString()); continue; } + 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("id"u8)) { id = new ResourceIdentifier(property.Value.GetString()); @@ -171,6 +198,7 @@ internal static CommitmentPlanAccountAssociationData DeserializeCommitmentPlanAc type, systemData, etag, + tags ?? new ChangeTrackingDictionary(), accountId, serializedAdditionalRawData); } @@ -209,6 +237,43 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); if (hasPropertyOverride) { diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.cs index b620e2672e0ca..07ff3894647f0 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationData.cs @@ -53,6 +53,7 @@ public partial class CommitmentPlanAccountAssociationData : ResourceData /// Initializes a new instance of . public CommitmentPlanAccountAssociationData() { + Tags = new ChangeTrackingDictionary(); } /// Initializes a new instance of . @@ -61,11 +62,13 @@ public CommitmentPlanAccountAssociationData() /// The resourceType. /// The systemData. /// Resource Etag. + /// Resource tags. /// The Azure resource id of the account. /// Keeps track of any properties unknown to the library. - internal CommitmentPlanAccountAssociationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, string accountId, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal CommitmentPlanAccountAssociationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, IDictionary tags, string accountId, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) { ETag = etag; + Tags = tags; AccountId = accountId; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -73,6 +76,9 @@ internal CommitmentPlanAccountAssociationData(ResourceIdentifier id, string name /// Resource Etag. [WirePath("etag")] public ETag? ETag { get; } + /// Resource tags. + [WirePath("tags")] + public IDictionary Tags { get; } /// The Azure resource id of the account. [WirePath("properties.accountId")] public string AccountId { get; set; } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationResource.cs index 5e23772c10c88..25864a8174483 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanAccountAssociationResource.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Collections.Generic; using System.Globalization; using System.Threading; using System.Threading.Tasks; @@ -101,7 +102,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -141,7 +142,7 @@ public virtual async Task> Ge /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -181,7 +182,7 @@ public virtual Response Get(Cancellati /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -223,7 +224,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -265,7 +266,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -311,7 +312,7 @@ public virtual async Task /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -343,5 +344,341 @@ public virtual ArmOperation Update(Wai throw; } } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName} + /// + /// + /// Operation Id + /// CommitmentPlans_GetAssociation + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _commitmentPlanAccountAssociationCommitmentPlansClientDiagnostics.CreateScope("CommitmentPlanAccountAssociationResource.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 _commitmentPlanAccountAssociationCommitmentPlansRestClient.GetAssociationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommitmentPlanAccountAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName} + /// + /// + /// Operation Id + /// CommitmentPlans_GetAssociation + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _commitmentPlanAccountAssociationCommitmentPlansClientDiagnostics.CreateScope("CommitmentPlanAccountAssociationResource.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 = _commitmentPlanAccountAssociationCommitmentPlansRestClient.GetAssociation(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CommitmentPlanAccountAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName} + /// + /// + /// Operation Id + /// CommitmentPlans_GetAssociation + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _commitmentPlanAccountAssociationCommitmentPlansClientDiagnostics.CreateScope("CommitmentPlanAccountAssociationResource.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 _commitmentPlanAccountAssociationCommitmentPlansRestClient.GetAssociationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommitmentPlanAccountAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName} + /// + /// + /// Operation Id + /// CommitmentPlans_GetAssociation + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _commitmentPlanAccountAssociationCommitmentPlansClientDiagnostics.CreateScope("CommitmentPlanAccountAssociationResource.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 = _commitmentPlanAccountAssociationCommitmentPlansRestClient.GetAssociation(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CommitmentPlanAccountAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName} + /// + /// + /// Operation Id + /// CommitmentPlans_GetAssociation + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _commitmentPlanAccountAssociationCommitmentPlansClientDiagnostics.CreateScope("CommitmentPlanAccountAssociationResource.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 _commitmentPlanAccountAssociationCommitmentPlansRestClient.GetAssociationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CommitmentPlanAccountAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName} + /// + /// + /// Operation Id + /// CommitmentPlans_GetAssociation + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _commitmentPlanAccountAssociationCommitmentPlansClientDiagnostics.CreateScope("CommitmentPlanAccountAssociationResource.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 = _commitmentPlanAccountAssociationCommitmentPlansRestClient.GetAssociation(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new CommitmentPlanAccountAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanCollection.cs index 58bde2e96d602..00147a6cad763 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanCollection.cs @@ -64,7 +64,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -115,7 +115,7 @@ public virtual async Task> CreateOrUpdateAs /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -166,7 +166,7 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil wai /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -211,7 +211,7 @@ public virtual async Task> GetAsync(string comm /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -256,7 +256,7 @@ public virtual Response Get(string commitmentPlanName, C /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -286,7 +286,7 @@ public virtual AsyncPageable GetAllAsync(CancellationTok /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -316,7 +316,7 @@ public virtual Pageable GetAll(CancellationToken cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -359,7 +359,7 @@ public virtual async Task> ExistsAsync(string commitmentPlanName, /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -402,7 +402,7 @@ public virtual Response Exists(string commitmentPlanName, CancellationToke /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -447,7 +447,7 @@ public virtual async Task> GetIfExistsA /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanResource.cs index abac906bee29f..ff31d6e9d3f4f 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/CommitmentPlanResource.cs @@ -102,7 +102,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -142,7 +142,7 @@ public virtual async Task> GetAsync(Cancellatio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -182,7 +182,7 @@ public virtual Response Get(CancellationToken cancellati /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -224,7 +224,7 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -266,7 +266,7 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -314,7 +314,7 @@ public virtual async Task> UpdateAsync(Wait /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -362,7 +362,7 @@ public virtual ArmOperation Update(WaitUntil waitUntil, /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -419,7 +419,7 @@ public virtual async Task> AddTagAsync(string k /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -476,7 +476,7 @@ public virtual Response AddTag(string key, string value, /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -532,7 +532,7 @@ public virtual async Task> SetTagsAsync(IDictio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -588,7 +588,7 @@ public virtual Response SetTags(IDictionary /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -643,7 +643,7 @@ public virtual async Task> RemoveTagAsync(strin /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingCollection.cs new file mode 100644 index 0000000000000..23ddc8e5edac2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingCollection.cs @@ -0,0 +1,497 @@ +// 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.CognitiveServices +{ + /// + /// 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 GetDefenderForAISettings method from an instance of . + /// + public partial class DefenderForAISettingCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _defenderForAISettingClientDiagnostics; + private readonly DefenderForAISettingsRestOperations _defenderForAISettingRestClient; + + /// Initializes a new instance of the class for mocking. + protected DefenderForAISettingCollection() + { + } + + /// 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 DefenderForAISettingCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _defenderForAISettingClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", DefenderForAISettingResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DefenderForAISettingResource.ResourceType, out string defenderForAISettingApiVersion); + _defenderForAISettingRestClient = new DefenderForAISettingsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, defenderForAISettingApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CognitiveServicesAccountResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CognitiveServicesAccountResource.ResourceType), nameof(id)); + } + + /// + /// Creates or Updates the specified Defender for AI setting. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the defender for AI setting. + /// Properties describing the Defender for AI setting. + /// 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 defenderForAISettingName, DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _defenderForAISettingRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, data, cancellationToken).ConfigureAwait(false); + var uri = _defenderForAISettingRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new DefenderForAISettingResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or Updates the specified Defender for AI setting. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the defender for AI setting. + /// Properties describing the Defender for AI setting. + /// 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 defenderForAISettingName, DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _defenderForAISettingRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, data, cancellationToken); + var uri = _defenderForAISettingRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new DefenderForAISettingResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Defender for AI setting by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.Get"); + scope.Start(); + try + { + var response = await _defenderForAISettingRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DefenderForAISettingResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Defender for AI setting by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.Get"); + scope.Start(); + try + { + var response = _defenderForAISettingRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DefenderForAISettingResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the Defender for AI settings. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings + /// + /// + /// Operation Id + /// DefenderForAISettings_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _defenderForAISettingRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _defenderForAISettingRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DefenderForAISettingResource(Client, DefenderForAISettingData.DeserializeDefenderForAISettingData(e)), _defenderForAISettingClientDiagnostics, Pipeline, "DefenderForAISettingCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the Defender for AI settings. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings + /// + /// + /// Operation Id + /// DefenderForAISettings_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _defenderForAISettingRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _defenderForAISettingRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DefenderForAISettingResource(Client, DefenderForAISettingData.DeserializeDefenderForAISettingData(e)), _defenderForAISettingClientDiagnostics, Pipeline, "DefenderForAISettingCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.Exists"); + scope.Start(); + try + { + var response = await _defenderForAISettingRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, 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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.Exists"); + scope.Start(); + try + { + var response = _defenderForAISettingRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, 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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _defenderForAISettingRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DefenderForAISettingResource(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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the defender for AI setting. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingCollection.GetIfExists"); + scope.Start(); + try + { + var response = _defenderForAISettingRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, defenderForAISettingName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new DefenderForAISettingResource(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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingData.Serialization.cs new file mode 100644 index 0000000000000..436337dc1e095 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingData.Serialization.cs @@ -0,0 +1,382 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + public partial class DefenderForAISettingData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DefenderForAISettingData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + 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(); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToString()); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DefenderForAISettingData 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(DefenderForAISettingData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDefenderForAISettingData(document.RootElement, options); + } + + internal static DefenderForAISettingData DeserializeDefenderForAISettingData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ETag? etag = default; + IDictionary tags = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + DefenderForAISettingState? state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + 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("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("state"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new DefenderForAISettingState(property0.Value.GetString()); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DefenderForAISettingData( + id, + name, + type, + systemData, + etag, + tags ?? new ChangeTrackingDictionary(), + state, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" etag: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ETag)) + { + builder.Append(" etag: "); + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.Append(" properties:"); + builder.AppendLine(" {"); + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" state: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(State)) + { + builder.Append(" state: "); + builder.AppendLine($"'{State.Value.ToString()}'"); + } + } + + builder.AppendLine(" }"); + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(DefenderForAISettingData)} does not support writing '{options.Format}' format."); + } + } + + DefenderForAISettingData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDefenderForAISettingData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DefenderForAISettingData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingData.cs new file mode 100644 index 0000000000000..8145638936d71 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingData.cs @@ -0,0 +1,87 @@ +// 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.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A class representing the DefenderForAISetting data model. + /// The Defender for AI resource. + /// + public partial class DefenderForAISettingData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public DefenderForAISettingData() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Defender for AI state on the AI resource. + /// Keeps track of any properties unknown to the library. + internal DefenderForAISettingData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, IDictionary tags, DefenderForAISettingState? state, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ETag = etag; + Tags = tags; + State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource Etag. + [WirePath("etag")] + public ETag? ETag { get; } + /// Resource tags. + [WirePath("tags")] + public IDictionary Tags { get; } + /// Defender for AI state on the AI resource. + [WirePath("properties.state")] + public DefenderForAISettingState? State { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingResource.Serialization.cs new file mode 100644 index 0000000000000..725672f07fdbc --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingResource.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.CognitiveServices +{ + public partial class DefenderForAISettingResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + DefenderForAISettingData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + DefenderForAISettingData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingResource.cs new file mode 100644 index 0000000000000..866371549842a --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/DefenderForAISettingResource.cs @@ -0,0 +1,614 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A Class representing a DefenderForAISetting 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 GetDefenderForAISettingResource method. + /// Otherwise you can get one from its parent resource using the GetDefenderForAISetting method. + /// + public partial class DefenderForAISettingResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + /// The defenderForAISettingName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string defenderForAISettingName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _defenderForAISettingClientDiagnostics; + private readonly DefenderForAISettingsRestOperations _defenderForAISettingRestClient; + private readonly DefenderForAISettingData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CognitiveServices/accounts/defenderForAISettings"; + + /// Initializes a new instance of the class for mocking. + protected DefenderForAISettingResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DefenderForAISettingResource(ArmClient client, DefenderForAISettingData 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 DefenderForAISettingResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _defenderForAISettingClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string defenderForAISettingApiVersion); + _defenderForAISettingRestClient = new DefenderForAISettingsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, defenderForAISettingApiVersion); +#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 DefenderForAISettingData 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 specified Defender for AI setting by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.Get"); + scope.Start(); + try + { + var response = await _defenderForAISettingRestClient.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 DefenderForAISettingResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Defender for AI setting by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.Get"); + scope.Start(); + try + { + var response = _defenderForAISettingRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DefenderForAISettingResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the specified Defender for AI setting. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Update + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Properties describing the Defender for AI setting. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.Update"); + scope.Start(); + try + { + var response = await _defenderForAISettingRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new DefenderForAISettingResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Updates the specified Defender for AI setting. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Update + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Properties describing the Defender for AI setting. + /// The cancellation token to use. + /// is null. + public virtual Response Update(DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.Update"); + scope.Start(); + try + { + var response = _defenderForAISettingRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + return Response.FromValue(new DefenderForAISettingResource(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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.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 _defenderForAISettingRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new DefenderForAISettingResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new DefenderForAISettingData(); + 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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.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 = _defenderForAISettingRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new DefenderForAISettingResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new DefenderForAISettingData(); + 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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.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 _defenderForAISettingRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new DefenderForAISettingResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new DefenderForAISettingData(); + 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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.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 = _defenderForAISettingRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new DefenderForAISettingResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new DefenderForAISettingData(); + 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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.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 _defenderForAISettingRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new DefenderForAISettingResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new DefenderForAISettingData(); + 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.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName} + /// + /// + /// Operation Id + /// DefenderForAISettings_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _defenderForAISettingClientDiagnostics.CreateScope("DefenderForAISettingResource.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 = _defenderForAISettingRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new DefenderForAISettingResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new DefenderForAISettingData(); + 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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeCollection.cs new file mode 100644 index 0000000000000..7275f798917b4 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeCollection.cs @@ -0,0 +1,497 @@ +// 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.CognitiveServices +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetEncryptionScopes method from an instance of . + /// + public partial class EncryptionScopeCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _encryptionScopeClientDiagnostics; + private readonly EncryptionScopesRestOperations _encryptionScopeRestClient; + + /// Initializes a new instance of the class for mocking. + protected EncryptionScopeCollection() + { + } + + /// 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 EncryptionScopeCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _encryptionScopeClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", EncryptionScopeResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(EncryptionScopeResource.ResourceType, out string encryptionScopeApiVersion); + _encryptionScopeRestClient = new EncryptionScopesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, encryptionScopeApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CognitiveServicesAccountResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CognitiveServicesAccountResource.ResourceType), nameof(id)); + } + + /// + /// Update the state of specified encryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the encryptionScope associated with the Cognitive Services Account. + /// The encryptionScope properties. + /// 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 encryptionScopeName, EncryptionScopeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _encryptionScopeRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, data, cancellationToken).ConfigureAwait(false); + var uri = _encryptionScopeRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new EncryptionScopeResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified encryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the encryptionScope associated with the Cognitive Services Account. + /// The encryptionScope properties. + /// 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 encryptionScopeName, EncryptionScopeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _encryptionScopeRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, data, cancellationToken); + var uri = _encryptionScopeRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new EncryptionScopeResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified EncryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.Get"); + scope.Start(); + try + { + var response = await _encryptionScopeRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EncryptionScopeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified EncryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.Get"); + scope.Start(); + try + { + var response = _encryptionScopeRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EncryptionScopeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the content filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes + /// + /// + /// Operation Id + /// EncryptionScopes_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _encryptionScopeRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _encryptionScopeRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new EncryptionScopeResource(Client, EncryptionScopeData.DeserializeEncryptionScopeData(e)), _encryptionScopeClientDiagnostics, Pipeline, "EncryptionScopeCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the content filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes + /// + /// + /// Operation Id + /// EncryptionScopes_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _encryptionScopeRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _encryptionScopeRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new EncryptionScopeResource(Client, EncryptionScopeData.DeserializeEncryptionScopeData(e)), _encryptionScopeClientDiagnostics, Pipeline, "EncryptionScopeCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.Exists"); + scope.Start(); + try + { + var response = await _encryptionScopeRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, 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.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.Exists"); + scope.Start(); + try + { + var response = _encryptionScopeRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, 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.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _encryptionScopeRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EncryptionScopeResource(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.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeCollection.GetIfExists"); + scope.Start(); + try + { + var response = _encryptionScopeRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, encryptionScopeName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new EncryptionScopeResource(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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeData.Serialization.cs new file mode 100644 index 0000000000000..e5fd0b2beeb75 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeData.Serialization.cs @@ -0,0 +1,364 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + public partial class EncryptionScopeData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncryptionScopeData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + 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(); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + EncryptionScopeData 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(EncryptionScopeData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncryptionScopeData(document.RootElement, options); + } + + internal static EncryptionScopeData DeserializeEncryptionScopeData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ETag? etag = default; + IDictionary tags = default; + EncryptionScopeProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + 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) + { + continue; + } + properties = EncryptionScopeProperties.DeserializeEncryptionScopeProperties(property.Value, options); + 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EncryptionScopeData( + id, + name, + type, + systemData, + etag, + tags ?? new ChangeTrackingDictionary(), + properties, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" etag: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ETag)) + { + builder.Append(" etag: "); + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(EncryptionScopeData)} does not support writing '{options.Format}' format."); + } + } + + EncryptionScopeData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEncryptionScopeData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncryptionScopeData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeData.cs new file mode 100644 index 0000000000000..44148d2045049 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeData.cs @@ -0,0 +1,87 @@ +// 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.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A class representing the EncryptionScope data model. + /// Cognitive Services EncryptionScope + /// + public partial class EncryptionScopeData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public EncryptionScopeData() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services EncryptionScope. + /// Keeps track of any properties unknown to the library. + internal EncryptionScopeData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, IDictionary tags, EncryptionScopeProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ETag = etag; + Tags = tags; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource Etag. + [WirePath("etag")] + public ETag? ETag { get; } + /// Resource tags. + [WirePath("tags")] + public IDictionary Tags { get; } + /// Properties of Cognitive Services EncryptionScope. + [WirePath("properties")] + public EncryptionScopeProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeResource.Serialization.cs new file mode 100644 index 0000000000000..d5077cd53caef --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeResource.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.CognitiveServices +{ + public partial class EncryptionScopeResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + EncryptionScopeData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + EncryptionScopeData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeResource.cs new file mode 100644 index 0000000000000..e7a56ad14312e --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/EncryptionScopeResource.cs @@ -0,0 +1,688 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A Class representing an EncryptionScope along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetEncryptionScopeResource method. + /// Otherwise you can get one from its parent resource using the GetEncryptionScope method. + /// + public partial class EncryptionScopeResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + /// The encryptionScopeName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string encryptionScopeName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _encryptionScopeClientDiagnostics; + private readonly EncryptionScopesRestOperations _encryptionScopeRestClient; + private readonly EncryptionScopeData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CognitiveServices/accounts/encryptionScopes"; + + /// Initializes a new instance of the class for mocking. + protected EncryptionScopeResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal EncryptionScopeResource(ArmClient client, EncryptionScopeData 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 EncryptionScopeResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _encryptionScopeClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string encryptionScopeApiVersion); + _encryptionScopeRestClient = new EncryptionScopesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, encryptionScopeApiVersion); +#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 EncryptionScopeData 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 specified EncryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.Get"); + scope.Start(); + try + { + var response = await _encryptionScopeRestClient.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 EncryptionScopeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified EncryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.Get"); + scope.Start(); + try + { + var response = _encryptionScopeRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new EncryptionScopeResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified encryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.Delete"); + scope.Start(); + try + { + var response = await _encryptionScopeRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new CognitiveServicesArmOperation(_encryptionScopeClientDiagnostics, Pipeline, _encryptionScopeRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified encryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.Delete"); + scope.Start(); + try + { + var response = _encryptionScopeRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new CognitiveServicesArmOperation(_encryptionScopeClientDiagnostics, Pipeline, _encryptionScopeRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified encryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 encryptionScope properties. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, EncryptionScopeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.Update"); + scope.Start(); + try + { + var response = await _encryptionScopeRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _encryptionScopeRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new EncryptionScopeResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified encryptionScope associated with the Cognitive Services account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 encryptionScope properties. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, EncryptionScopeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.Update"); + scope.Start(); + try + { + var response = _encryptionScopeRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _encryptionScopeRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new EncryptionScopeResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.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 _encryptionScopeRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EncryptionScopeResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.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 = _encryptionScopeRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new EncryptionScopeResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.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 _encryptionScopeRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EncryptionScopeResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.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 = _encryptionScopeRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new EncryptionScopeResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.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 _encryptionScopeRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new EncryptionScopeResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName} + /// + /// + /// Operation Id + /// EncryptionScopes_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _encryptionScopeClientDiagnostics.CreateScope("EncryptionScopeResource.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 = _encryptionScopeRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new EncryptionScopeResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/CognitiveServicesExtensions.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/CognitiveServicesExtensions.cs index 6778ed3f6bd79..cbf038bc20b2d 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/CognitiveServicesExtensions.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/CognitiveServicesExtensions.cs @@ -166,6 +166,139 @@ public static CommitmentPlanAccountAssociationResource GetCommitmentPlanAccountA return GetMockableCognitiveServicesArmClient(client).GetCommitmentPlanAccountAssociationResource(id); } + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an 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 EncryptionScopeResource GetEncryptionScopeResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCognitiveServicesArmClient(client).GetEncryptionScopeResource(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 RaiPolicyResource GetRaiPolicyResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCognitiveServicesArmClient(client).GetRaiPolicyResource(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 RaiBlocklistResource GetRaiBlocklistResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCognitiveServicesArmClient(client).GetRaiBlocklistResource(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 RaiBlocklistItemResource GetRaiBlocklistItemResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCognitiveServicesArmClient(client).GetRaiBlocklistItemResource(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 RaiContentFilterResource GetRaiContentFilterResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCognitiveServicesArmClient(client).GetRaiContentFilterResource(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 NetworkSecurityPerimeterConfigurationResource GetNetworkSecurityPerimeterConfigurationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCognitiveServicesArmClient(client).GetNetworkSecurityPerimeterConfigurationResource(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 DefenderForAISettingResource GetDefenderForAISettingResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableCognitiveServicesArmClient(client).GetDefenderForAISettingResource(id); + } + /// /// Gets a collection of CognitiveServicesAccountResources in the ResourceGroupResource. /// @@ -196,7 +329,7 @@ public static CognitiveServicesAccountCollection GetCognitiveServicesAccounts(th /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -234,7 +367,7 @@ public static async Task> GetCognitiv /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -289,7 +422,7 @@ public static CognitiveServicesCommitmentPlanCollection GetCognitiveServicesComm /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -327,7 +460,7 @@ public static async Task> GetC /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -382,7 +515,7 @@ public static CognitiveServicesDeletedAccountCollection GetCognitiveServicesDele /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -422,7 +555,7 @@ public static async Task> GetC /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -449,6 +582,102 @@ public static Response GetCognitiveServ return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetCognitiveServicesDeletedAccount(location, resourceGroupName, accountName, cancellationToken); } + /// + /// Gets a collection of RaiContentFilterResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Resource location. + /// is null. + /// An object representing collection of RaiContentFilterResources and their operations over a RaiContentFilterResource. + public static RaiContentFilterCollection GetRaiContentFilters(this SubscriptionResource subscriptionResource, AzureLocation location) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetRaiContentFilters(location); + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Resource location. + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetRaiContentFilterAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetRaiContentFilterAsync(location, filterName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Resource location. + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetRaiContentFilter(this SubscriptionResource subscriptionResource, AzureLocation location, string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetRaiContentFilter(location, filterName, cancellationToken); + } + /// /// Returns all the resources of a particular type belonging to a subscription. /// @@ -462,7 +691,7 @@ public static Response GetCognitiveServ /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -498,7 +727,7 @@ public static AsyncPageable GetCognitiveServic /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -534,7 +763,7 @@ public static Pageable GetCognitiveServicesAcc /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -570,7 +799,7 @@ public static AsyncPageable GetDeletedA /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -606,7 +835,7 @@ public static Pageable GetDeletedAccoun /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -638,7 +867,7 @@ public static AsyncPageable GetResourceSkusAsync( /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -670,7 +899,7 @@ public static Pageable GetResourceSkus(this Subsc /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -704,7 +933,7 @@ public static AsyncPageable GetUsagesAsync(this Subscriptio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -738,7 +967,7 @@ public static Pageable GetUsages(this SubscriptionResource /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -772,7 +1001,7 @@ public static AsyncPageable CheckSkuAvaila /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -806,7 +1035,7 @@ public static Pageable CheckSkuAvailabilit /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -838,7 +1067,7 @@ public static async Task> Chec /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -857,6 +1086,70 @@ public static Response CheckDomainAvail return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).CheckDomainAvailability(content, cancellationToken); } + /// + /// Model capacity calculator. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/calculateModelCapacity + /// + /// + /// Operation Id + /// CalculateModelCapacity + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Check Domain Availability parameter. + /// The cancellation token to use. + /// or is null. + public static async Task> CalculateModelCapacityAsync(this SubscriptionResource subscriptionResource, CalculateModelCapacityParameter calculateModelCapacityParameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).CalculateModelCapacityAsync(calculateModelCapacityParameter, cancellationToken).ConfigureAwait(false); + } + + /// + /// Model capacity calculator. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/calculateModelCapacity + /// + /// + /// Operation Id + /// CalculateModelCapacity + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Check Domain Availability parameter. + /// The cancellation token to use. + /// or is null. + public static Response CalculateModelCapacity(this SubscriptionResource subscriptionResource, CalculateModelCapacityParameter calculateModelCapacityParameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).CalculateModelCapacity(calculateModelCapacityParameter, cancellationToken); + } + /// /// List Commitment Tiers. /// @@ -870,7 +1163,7 @@ public static Response CheckDomainAvail /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -903,7 +1196,7 @@ public static AsyncPageable GetCommitmentTiersAsync(this Subscri /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -936,7 +1229,7 @@ public static Pageable GetCommitmentTiers(this SubscriptionResou /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -969,7 +1262,7 @@ public static AsyncPageable GetModelsAsync(this Subscrip /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -989,6 +1282,148 @@ public static Pageable GetModels(this SubscriptionResour return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetModels(location, cancellationToken); } + /// + /// List Location Based ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/modelCapacities + /// + /// + /// Operation Id + /// LocationBasedModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetLocationBasedModelCapacitiesAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetLocationBasedModelCapacitiesAsync(location, modelFormat, modelName, modelVersion, cancellationToken); + } + + /// + /// List Location Based ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/modelCapacities + /// + /// + /// Operation Id + /// LocationBasedModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetLocationBasedModelCapacities(this SubscriptionResource subscriptionResource, AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetLocationBasedModelCapacities(location, modelFormat, modelName, modelVersion, cancellationToken); + } + + /// + /// List ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/modelCapacities + /// + /// + /// Operation Id + /// ModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetModelCapacitiesAsync(this SubscriptionResource subscriptionResource, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetModelCapacitiesAsync(modelFormat, modelName, modelVersion, cancellationToken); + } + + /// + /// List ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/modelCapacities + /// + /// + /// Operation Id + /// ModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetModelCapacities(this SubscriptionResource subscriptionResource, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableCognitiveServicesSubscriptionResource(subscriptionResource).GetModelCapacities(modelFormat, modelName, modelVersion, cancellationToken); + } + /// /// Returns all the resources of a particular type belonging to a subscription. /// @@ -1002,7 +1437,7 @@ public static Pageable GetModels(this SubscriptionResour /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -1038,7 +1473,7 @@ public static AsyncPageable GetCognitiv /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesArmClient.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesArmClient.cs index 98960cf56995b..746195803c790 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesArmClient.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesArmClient.cs @@ -117,5 +117,89 @@ public virtual CommitmentPlanAccountAssociationResource GetCommitmentPlanAccount CommitmentPlanAccountAssociationResource.ValidateResourceId(id); return new CommitmentPlanAccountAssociationResource(Client, id); } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual EncryptionScopeResource GetEncryptionScopeResource(ResourceIdentifier id) + { + EncryptionScopeResource.ValidateResourceId(id); + return new EncryptionScopeResource(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 RaiPolicyResource GetRaiPolicyResource(ResourceIdentifier id) + { + RaiPolicyResource.ValidateResourceId(id); + return new RaiPolicyResource(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 RaiBlocklistResource GetRaiBlocklistResource(ResourceIdentifier id) + { + RaiBlocklistResource.ValidateResourceId(id); + return new RaiBlocklistResource(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 RaiBlocklistItemResource GetRaiBlocklistItemResource(ResourceIdentifier id) + { + RaiBlocklistItemResource.ValidateResourceId(id); + return new RaiBlocklistItemResource(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 RaiContentFilterResource GetRaiContentFilterResource(ResourceIdentifier id) + { + RaiContentFilterResource.ValidateResourceId(id); + return new RaiContentFilterResource(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 NetworkSecurityPerimeterConfigurationResource GetNetworkSecurityPerimeterConfigurationResource(ResourceIdentifier id) + { + NetworkSecurityPerimeterConfigurationResource.ValidateResourceId(id); + return new NetworkSecurityPerimeterConfigurationResource(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 DefenderForAISettingResource GetDefenderForAISettingResource(ResourceIdentifier id) + { + DefenderForAISettingResource.ValidateResourceId(id); + return new DefenderForAISettingResource(Client, id); + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesResourceGroupResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesResourceGroupResource.cs index 943dc56409a22..e0f8180f79c5a 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesResourceGroupResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesResourceGroupResource.cs @@ -53,7 +53,7 @@ public virtual CognitiveServicesAccountCollection GetCognitiveServicesAccounts() /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -84,7 +84,7 @@ public virtual async Task> GetCogniti /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -122,7 +122,7 @@ public virtual CognitiveServicesCommitmentPlanCollection GetCognitiveServicesCom /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -153,7 +153,7 @@ public virtual async Task> Get /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesSubscriptionResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesSubscriptionResource.cs index 844a7e700b336..e3dd73d6ee7c7 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesSubscriptionResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Extensions/MockableCognitiveServicesSubscriptionResource.cs @@ -32,6 +32,10 @@ public partial class MockableCognitiveServicesSubscriptionResource : ArmResource private CommitmentTiersRestOperations _commitmentTiersRestClient; private ClientDiagnostics _modelsClientDiagnostics; private ModelsRestOperations _modelsRestClient; + private ClientDiagnostics _locationBasedModelCapacitiesClientDiagnostics; + private LocationBasedModelCapacitiesRestOperations _locationBasedModelCapacitiesRestClient; + private ClientDiagnostics _modelCapacitiesClientDiagnostics; + private ModelCapacitiesRestOperations _modelCapacitiesRestClient; private ClientDiagnostics _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics; private CommitmentPlansRestOperations _cognitiveServicesCommitmentPlanCommitmentPlansRestClient; @@ -61,6 +65,10 @@ internal MockableCognitiveServicesSubscriptionResource(ArmClient client, Resourc private CommitmentTiersRestOperations CommitmentTiersRestClient => _commitmentTiersRestClient ??= new CommitmentTiersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private ClientDiagnostics ModelsClientDiagnostics => _modelsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ProviderConstants.DefaultProviderNamespace, Diagnostics); private ModelsRestOperations ModelsRestClient => _modelsRestClient ??= new ModelsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics LocationBasedModelCapacitiesClientDiagnostics => _locationBasedModelCapacitiesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private LocationBasedModelCapacitiesRestOperations LocationBasedModelCapacitiesRestClient => _locationBasedModelCapacitiesRestClient ??= new LocationBasedModelCapacitiesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics ModelCapacitiesClientDiagnostics => _modelCapacitiesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private ModelCapacitiesRestOperations ModelCapacitiesRestClient => _modelCapacitiesRestClient ??= new ModelCapacitiesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private ClientDiagnostics CognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics => _cognitiveServicesCommitmentPlanCommitmentPlansClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", CognitiveServicesCommitmentPlanResource.ResourceType.Namespace, Diagnostics); private CommitmentPlansRestOperations CognitiveServicesCommitmentPlanCommitmentPlansRestClient => _cognitiveServicesCommitmentPlanCommitmentPlansRestClient ??= new CommitmentPlansRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(CognitiveServicesCommitmentPlanResource.ResourceType)); @@ -90,7 +98,7 @@ public virtual CognitiveServicesDeletedAccountCollection GetCognitiveServicesDel /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -123,7 +131,7 @@ public virtual async Task> Get /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -143,6 +151,78 @@ public virtual Response GetCognitiveSer return GetCognitiveServicesDeletedAccounts().Get(location, resourceGroupName, accountName, cancellationToken); } + /// Gets a collection of RaiContentFilterResources in the SubscriptionResource. + /// Resource location. + /// An object representing collection of RaiContentFilterResources and their operations over a RaiContentFilterResource. + public virtual RaiContentFilterCollection GetRaiContentFilters(AzureLocation location) + { + return new RaiContentFilterCollection(Client, Id, location); + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource location. + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetRaiContentFilterAsync(AzureLocation location, string filterName, CancellationToken cancellationToken = default) + { + return await GetRaiContentFilters(location).GetAsync(filterName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Resource location. + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetRaiContentFilter(AzureLocation location, string filterName, CancellationToken cancellationToken = default) + { + return GetRaiContentFilters(location).Get(filterName, cancellationToken); + } + /// /// Returns all the resources of a particular type belonging to a subscription. /// @@ -156,7 +236,7 @@ public virtual Response GetCognitiveSer /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -186,7 +266,7 @@ public virtual AsyncPageable GetCognitiveServi /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -216,7 +296,7 @@ public virtual Pageable GetCognitiveServicesAc /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -246,7 +326,7 @@ public virtual AsyncPageable GetDeleted /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -276,7 +356,7 @@ public virtual Pageable GetDeletedAccou /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -302,7 +382,7 @@ public virtual AsyncPageable GetResourceSkusAsync /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -328,7 +408,7 @@ public virtual Pageable GetResourceSkus(Cancellat /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -356,7 +436,7 @@ public virtual AsyncPageable GetUsagesAsync(AzureLocation l /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -384,7 +464,7 @@ public virtual Pageable GetUsages(AzureLocation location, s /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -414,7 +494,7 @@ public virtual AsyncPageable CheckSkuAvail /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -444,7 +524,7 @@ public virtual Pageable CheckSkuAvailabili /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -482,7 +562,7 @@ public virtual async Task> Che /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -507,6 +587,82 @@ public virtual Response CheckDomainAvai } } + /// + /// Model capacity calculator. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/calculateModelCapacity + /// + /// + /// Operation Id + /// CalculateModelCapacity + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Check Domain Availability parameter. + /// The cancellation token to use. + /// is null. + public virtual async Task> CalculateModelCapacityAsync(CalculateModelCapacityParameter calculateModelCapacityParameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(calculateModelCapacityParameter, nameof(calculateModelCapacityParameter)); + + using var scope = DefaultClientDiagnostics.CreateScope("MockableCognitiveServicesSubscriptionResource.CalculateModelCapacity"); + scope.Start(); + try + { + var response = await DefaultRestClient.CalculateModelCapacityAsync(Id.SubscriptionId, calculateModelCapacityParameter, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Model capacity calculator. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/calculateModelCapacity + /// + /// + /// Operation Id + /// CalculateModelCapacity + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Check Domain Availability parameter. + /// The cancellation token to use. + /// is null. + public virtual Response CalculateModelCapacity(CalculateModelCapacityParameter calculateModelCapacityParameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(calculateModelCapacityParameter, nameof(calculateModelCapacityParameter)); + + using var scope = DefaultClientDiagnostics.CreateScope("MockableCognitiveServicesSubscriptionResource.CalculateModelCapacity"); + scope.Start(); + try + { + var response = DefaultRestClient.CalculateModelCapacity(Id.SubscriptionId, calculateModelCapacityParameter, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// /// List Commitment Tiers. /// @@ -520,7 +676,7 @@ public virtual Response CheckDomainAvai /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -547,7 +703,7 @@ public virtual AsyncPageable GetCommitmentTiersAsync(AzureLocati /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -574,7 +730,7 @@ public virtual Pageable GetCommitmentTiers(AzureLocation locatio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -601,7 +757,7 @@ public virtual AsyncPageable GetModelsAsync(AzureLocatio /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// @@ -615,6 +771,144 @@ public virtual Pageable GetModels(AzureLocation location return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => CognitiveServicesModel.DeserializeCognitiveServicesModel(e), ModelsClientDiagnostics, Pipeline, "MockableCognitiveServicesSubscriptionResource.GetModels", "value", "nextLink", cancellationToken); } + /// + /// List Location Based ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/modelCapacities + /// + /// + /// Operation Id + /// LocationBasedModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , or is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetLocationBasedModelCapacitiesAsync(AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => LocationBasedModelCapacitiesRestClient.CreateListRequest(Id.SubscriptionId, location, modelFormat, modelName, modelVersion); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => LocationBasedModelCapacitiesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, location, modelFormat, modelName, modelVersion); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => ModelCapacityListResultValueItem.DeserializeModelCapacityListResultValueItem(e), LocationBasedModelCapacitiesClientDiagnostics, Pipeline, "MockableCognitiveServicesSubscriptionResource.GetLocationBasedModelCapacities", "value", "nextLink", cancellationToken); + } + + /// + /// List Location Based ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/modelCapacities + /// + /// + /// Operation Id + /// LocationBasedModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , or is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetLocationBasedModelCapacities(AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => LocationBasedModelCapacitiesRestClient.CreateListRequest(Id.SubscriptionId, location, modelFormat, modelName, modelVersion); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => LocationBasedModelCapacitiesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, location, modelFormat, modelName, modelVersion); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => ModelCapacityListResultValueItem.DeserializeModelCapacityListResultValueItem(e), LocationBasedModelCapacitiesClientDiagnostics, Pipeline, "MockableCognitiveServicesSubscriptionResource.GetLocationBasedModelCapacities", "value", "nextLink", cancellationToken); + } + + /// + /// List ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/modelCapacities + /// + /// + /// Operation Id + /// ModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , or is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetModelCapacitiesAsync(string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ModelCapacitiesRestClient.CreateListRequest(Id.SubscriptionId, modelFormat, modelName, modelVersion); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ModelCapacitiesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, modelFormat, modelName, modelVersion); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => ModelCapacityListResultValueItem.DeserializeModelCapacityListResultValueItem(e), ModelCapacitiesClientDiagnostics, Pipeline, "MockableCognitiveServicesSubscriptionResource.GetModelCapacities", "value", "nextLink", cancellationToken); + } + + /// + /// List ModelCapacities. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/modelCapacities + /// + /// + /// Operation Id + /// ModelCapacities_List + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , or is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetModelCapacities(string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => ModelCapacitiesRestClient.CreateListRequest(Id.SubscriptionId, modelFormat, modelName, modelVersion); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ModelCapacitiesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, modelFormat, modelName, modelVersion); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => ModelCapacityListResultValueItem.DeserializeModelCapacityListResultValueItem(e), ModelCapacitiesClientDiagnostics, Pipeline, "MockableCognitiveServicesSubscriptionResource.GetModelCapacities", "value", "nextLink", cancellationToken); + } + /// /// Returns all the resources of a particular type belonging to a subscription. /// @@ -628,7 +922,7 @@ public virtual Pageable GetModels(AzureLocation location /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource @@ -658,7 +952,7 @@ public virtual AsyncPageable GetCogniti /// /// /// Default Api Version - /// 2023-05-01 + /// 2024-06-01-preview /// /// /// Resource diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/LongRunningOperation/NetworkSecurityPerimeterConfigurationOperationSource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/LongRunningOperation/NetworkSecurityPerimeterConfigurationOperationSource.cs new file mode 100644 index 0000000000000..9e25e097d3fa6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/LongRunningOperation/NetworkSecurityPerimeterConfigurationOperationSource.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal class NetworkSecurityPerimeterConfigurationOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal NetworkSecurityPerimeterConfigurationOperationSource(ArmClient client) + { + _client = client; + } + + NetworkSecurityPerimeterConfigurationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = NetworkSecurityPerimeterConfigurationData.DeserializeNetworkSecurityPerimeterConfigurationData(document.RootElement); + return new NetworkSecurityPerimeterConfigurationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = NetworkSecurityPerimeterConfigurationData.DeserializeNetworkSecurityPerimeterConfigurationData(document.RootElement); + return new NetworkSecurityPerimeterConfigurationResource(_client, data); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/BillingMeterInfo.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/BillingMeterInfo.Serialization.cs new file mode 100644 index 0000000000000..425da039e47e9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/BillingMeterInfo.Serialization.cs @@ -0,0 +1,231 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class BillingMeterInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingMeterInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(MeterId)) + { + writer.WritePropertyName("meterId"u8); + writer.WriteStringValue(MeterId); + } + if (Optional.IsDefined(Unit)) + { + writer.WritePropertyName("unit"u8); + writer.WriteStringValue(Unit); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BillingMeterInfo 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(BillingMeterInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingMeterInfo(document.RootElement, options); + } + + internal static BillingMeterInfo DeserializeBillingMeterInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string meterId = default; + string unit = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("meterId"u8)) + { + meterId = property.Value.GetString(); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BillingMeterInfo(name, meterId, unit, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(MeterId), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" meterId: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(MeterId)) + { + builder.Append(" meterId: "); + if (MeterId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{MeterId}'''"); + } + else + { + builder.AppendLine($"'{MeterId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Unit), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" unit: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Unit)) + { + builder.Append(" unit: "); + if (Unit.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Unit}'''"); + } + else + { + builder.AppendLine($"'{Unit}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(BillingMeterInfo)} does not support writing '{options.Format}' format."); + } + } + + BillingMeterInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBillingMeterInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingMeterInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/BillingMeterInfo.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/BillingMeterInfo.cs new file mode 100644 index 0000000000000..0f6ace2944e6b --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/BillingMeterInfo.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The BillingMeterInfo. + public partial class BillingMeterInfo + { + /// + /// 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 BillingMeterInfo() + { + } + + /// Initializes a new instance of . + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal BillingMeterInfo(string name, string meterId, string unit, IDictionary serializedAdditionalRawData) + { + Name = name; + MeterId = meterId; + Unit = unit; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the name. + [WirePath("name")] + public string Name { get; set; } + /// Gets or sets the meter id. + [WirePath("meterId")] + public string MeterId { get; set; } + /// Gets or sets the unit. + [WirePath("unit")] + public string Unit { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ByPassSelection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ByPassSelection.cs new file mode 100644 index 0000000000000..2f0407216da47 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ByPassSelection.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Setting for trusted services. + public readonly partial struct ByPassSelection : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ByPassSelection(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string AzureServicesValue = "AzureServices"; + + /// None. + public static ByPassSelection None { get; } = new ByPassSelection(NoneValue); + /// AzureServices. + public static ByPassSelection AzureServices { get; } = new ByPassSelection(AzureServicesValue); + /// Determines if two values are the same. + public static bool operator ==(ByPassSelection left, ByPassSelection right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ByPassSelection left, ByPassSelection right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ByPassSelection(string value) => new ByPassSelection(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ByPassSelection other && Equals(other); + /// + public bool Equals(ByPassSelection other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityParameter.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityParameter.Serialization.cs new file mode 100644 index 0000000000000..25cbad321b9e1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityParameter.Serialization.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class CalculateModelCapacityParameter : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CalculateModelCapacityParameter)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteObjectValue(Model, options); + } + if (Optional.IsDefined(SkuName)) + { + writer.WritePropertyName("skuName"u8); + writer.WriteStringValue(SkuName); + } + if (Optional.IsCollectionDefined(Workloads)) + { + writer.WritePropertyName("workloads"u8); + writer.WriteStartArray(); + foreach (var item in Workloads) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CalculateModelCapacityParameter 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(CalculateModelCapacityParameter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCalculateModelCapacityParameter(document.RootElement, options); + } + + internal static CalculateModelCapacityParameter DeserializeCalculateModelCapacityParameter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CognitiveServicesAccountDeploymentModel model = default; + string skuName = default; + IList workloads = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = CognitiveServicesAccountDeploymentModel.DeserializeCognitiveServicesAccountDeploymentModel(property.Value, options); + continue; + } + if (property.NameEquals("skuName"u8)) + { + skuName = property.Value.GetString(); + continue; + } + if (property.NameEquals("workloads"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ModelCapacityCalculatorWorkload.DeserializeModelCapacityCalculatorWorkload(item, options)); + } + workloads = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CalculateModelCapacityParameter(model, skuName, workloads ?? 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(CalculateModelCapacityParameter)} does not support writing '{options.Format}' format."); + } + } + + CalculateModelCapacityParameter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCalculateModelCapacityParameter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CalculateModelCapacityParameter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityParameter.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityParameter.cs new file mode 100644 index 0000000000000..5fa6193f071e6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityParameter.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Calculate Model Capacity parameter. + public partial class CalculateModelCapacityParameter + { + /// + /// 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 CalculateModelCapacityParameter() + { + Workloads = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Properties of Cognitive Services account deployment model. + /// The name of SKU. + /// List of Model Capacity Calculator Workload. + /// Keeps track of any properties unknown to the library. + internal CalculateModelCapacityParameter(CognitiveServicesAccountDeploymentModel model, string skuName, IList workloads, IDictionary serializedAdditionalRawData) + { + Model = model; + SkuName = skuName; + Workloads = workloads; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Properties of Cognitive Services account deployment model. + [WirePath("model")] + public CognitiveServicesAccountDeploymentModel Model { get; set; } + /// The name of SKU. + [WirePath("skuName")] + public string SkuName { get; set; } + /// List of Model Capacity Calculator Workload. + [WirePath("workloads")] + public IList Workloads { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResult.Serialization.cs new file mode 100644 index 0000000000000..f697dbae14030 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResult.Serialization.cs @@ -0,0 +1,223 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class CalculateModelCapacityResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CalculateModelCapacityResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteObjectValue(Model, options); + } + if (Optional.IsDefined(SkuName)) + { + writer.WritePropertyName("skuName"u8); + writer.WriteStringValue(SkuName); + } + if (Optional.IsDefined(EstimatedCapacity)) + { + writer.WritePropertyName("estimatedCapacity"u8); + writer.WriteObjectValue(EstimatedCapacity, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CalculateModelCapacityResult 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(CalculateModelCapacityResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCalculateModelCapacityResult(document.RootElement, options); + } + + internal static CalculateModelCapacityResult DeserializeCalculateModelCapacityResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CognitiveServicesAccountDeploymentModel model = default; + string skuName = default; + CalculateModelCapacityResultEstimatedCapacity estimatedCapacity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = CognitiveServicesAccountDeploymentModel.DeserializeCognitiveServicesAccountDeploymentModel(property.Value, options); + continue; + } + if (property.NameEquals("skuName"u8)) + { + skuName = property.Value.GetString(); + continue; + } + if (property.NameEquals("estimatedCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + estimatedCapacity = CalculateModelCapacityResultEstimatedCapacity.DeserializeCalculateModelCapacityResultEstimatedCapacity(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CalculateModelCapacityResult(model, skuName, estimatedCapacity, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Model), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" model: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Model)) + { + builder.Append(" model: "); + BicepSerializationHelpers.AppendChildObject(builder, Model, options, 2, false, " model: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SkuName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" skuName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SkuName)) + { + builder.Append(" skuName: "); + if (SkuName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SkuName}'''"); + } + else + { + builder.AppendLine($"'{SkuName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EstimatedCapacity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" estimatedCapacity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(EstimatedCapacity)) + { + builder.Append(" estimatedCapacity: "); + BicepSerializationHelpers.AppendChildObject(builder, EstimatedCapacity, options, 2, false, " estimatedCapacity: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(CalculateModelCapacityResult)} does not support writing '{options.Format}' format."); + } + } + + CalculateModelCapacityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCalculateModelCapacityResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CalculateModelCapacityResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResult.cs new file mode 100644 index 0000000000000..87fbf6e24a84f --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResult.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Calculate Model Capacity result. + public partial class CalculateModelCapacityResult + { + /// + /// 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 CalculateModelCapacityResult() + { + } + + /// Initializes a new instance of . + /// Properties of Cognitive Services account deployment model. + /// + /// Model Estimated Capacity. + /// Keeps track of any properties unknown to the library. + internal CalculateModelCapacityResult(CognitiveServicesAccountDeploymentModel model, string skuName, CalculateModelCapacityResultEstimatedCapacity estimatedCapacity, IDictionary serializedAdditionalRawData) + { + Model = model; + SkuName = skuName; + EstimatedCapacity = estimatedCapacity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Properties of Cognitive Services account deployment model. + [WirePath("model")] + public CognitiveServicesAccountDeploymentModel Model { get; } + /// Gets the sku name. + [WirePath("skuName")] + public string SkuName { get; } + /// Model Estimated Capacity. + [WirePath("estimatedCapacity")] + public CalculateModelCapacityResultEstimatedCapacity EstimatedCapacity { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResultEstimatedCapacity.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResultEstimatedCapacity.Serialization.cs new file mode 100644 index 0000000000000..3115c23431b97 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResultEstimatedCapacity.Serialization.cs @@ -0,0 +1,189 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class CalculateModelCapacityResultEstimatedCapacity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CalculateModelCapacityResultEstimatedCapacity)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (Optional.IsDefined(DeployableValue)) + { + writer.WritePropertyName("deployableValue"u8); + writer.WriteNumberValue(DeployableValue.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CalculateModelCapacityResultEstimatedCapacity 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(CalculateModelCapacityResultEstimatedCapacity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCalculateModelCapacityResultEstimatedCapacity(document.RootElement, options); + } + + internal static CalculateModelCapacityResultEstimatedCapacity DeserializeCalculateModelCapacityResultEstimatedCapacity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? value = default; + int? deployableValue = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("deployableValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deployableValue = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CalculateModelCapacityResultEstimatedCapacity(value, deployableValue, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Value)) + { + builder.Append(" value: "); + builder.AppendLine($"{Value.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DeployableValue), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" deployableValue: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(DeployableValue)) + { + builder.Append(" deployableValue: "); + builder.AppendLine($"{DeployableValue.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(CalculateModelCapacityResultEstimatedCapacity)} does not support writing '{options.Format}' format."); + } + } + + CalculateModelCapacityResultEstimatedCapacity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCalculateModelCapacityResultEstimatedCapacity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CalculateModelCapacityResultEstimatedCapacity)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResultEstimatedCapacity.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResultEstimatedCapacity.cs new file mode 100644 index 0000000000000..d0cfe54c69c38 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CalculateModelCapacityResultEstimatedCapacity.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.CognitiveServices.Models +{ + /// Model Estimated Capacity. + public partial class CalculateModelCapacityResultEstimatedCapacity + { + /// + /// 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 CalculateModelCapacityResultEstimatedCapacity() + { + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal CalculateModelCapacityResultEstimatedCapacity(int? value, int? deployableValue, IDictionary serializedAdditionalRawData) + { + Value = value; + DeployableValue = deployableValue; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets the value. + [WirePath("value")] + public int? Value { get; } + /// Gets the deployable value. + [WirePath("deployableValue")] + public int? DeployableValue { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.Serialization.cs index 1fa437b12614d..ad9dead1ac7de 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.Serialization.cs @@ -79,6 +79,21 @@ void IJsonModel.Write(Utf8JsonWrit writer.WritePropertyName("versionUpgradeOption"u8); writer.WriteStringValue(VersionUpgradeOption.Value.ToString()); } + if (options.Format != "W" && Optional.IsDefined(DynamicThrottlingEnabled)) + { + writer.WritePropertyName("dynamicThrottlingEnabled"u8); + writer.WriteBooleanValue(DynamicThrottlingEnabled.Value); + } + if (Optional.IsDefined(CurrentCapacity)) + { + writer.WritePropertyName("currentCapacity"u8); + writer.WriteNumberValue(CurrentCapacity.Value); + } + if (Optional.IsDefined(CapacitySettings)) + { + writer.WritePropertyName("capacitySettings"u8); + writer.WriteObjectValue(CapacitySettings, options); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -125,6 +140,9 @@ internal static CognitiveServicesAccountDeploymentProperties DeserializeCognitiv ServiceAccountCallRateLimit callRateLimit = default; IReadOnlyList rateLimits = default; DeploymentModelVersionUpgradeOption? versionUpgradeOption = default; + bool? dynamicThrottlingEnabled = default; + int? currentCapacity = default; + DeploymentCapacitySettings capacitySettings = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -207,6 +225,33 @@ internal static CognitiveServicesAccountDeploymentProperties DeserializeCognitiv versionUpgradeOption = new DeploymentModelVersionUpgradeOption(property.Value.GetString()); continue; } + if (property.NameEquals("dynamicThrottlingEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dynamicThrottlingEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("currentCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + currentCapacity = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("capacitySettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacitySettings = DeploymentCapacitySettings.DeserializeDeploymentCapacitySettings(property.Value, options); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -222,6 +267,9 @@ internal static CognitiveServicesAccountDeploymentProperties DeserializeCognitiv callRateLimit, rateLimits ?? new ChangeTrackingList(), versionUpgradeOption, + dynamicThrottlingEnabled, + currentCapacity, + capacitySettings, serializedAdditionalRawData); } @@ -394,6 +442,52 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DynamicThrottlingEnabled), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" dynamicThrottlingEnabled: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(DynamicThrottlingEnabled)) + { + builder.Append(" dynamicThrottlingEnabled: "); + var boolValue = DynamicThrottlingEnabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CurrentCapacity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" currentCapacity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(CurrentCapacity)) + { + builder.Append(" currentCapacity: "); + builder.AppendLine($"{CurrentCapacity.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CapacitySettings), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" capacitySettings: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(CapacitySettings)) + { + builder.Append(" capacitySettings: "); + BicepSerializationHelpers.AppendChildObject(builder, CapacitySettings, options, 2, false, " capacitySettings: "); + } + } + builder.AppendLine("}"); return BinaryData.FromString(builder.ToString()); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.cs index 3173288523e6d..447ef3177ece9 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentProperties.cs @@ -55,14 +55,17 @@ public CognitiveServicesAccountDeploymentProperties() /// Initializes a new instance of . /// Gets the status of the resource at the time the operation was called. /// Properties of Cognitive Services account deployment model. - /// Properties of Cognitive Services account deployment model. + /// Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku instead.). /// The capabilities. /// The name of RAI policy. /// The call rate limit Cognitive Services account. /// /// Deployment model version upgrade option. + /// If the dynamic throttling is enabled. + /// The current capacity. + /// Internal use only. /// Keeps track of any properties unknown to the library. - internal CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDeploymentProvisioningState? provisioningState, CognitiveServicesAccountDeploymentModel model, CognitiveServicesAccountDeploymentScaleSettings scaleSettings, IReadOnlyDictionary capabilities, string raiPolicyName, ServiceAccountCallRateLimit callRateLimit, IReadOnlyList rateLimits, DeploymentModelVersionUpgradeOption? versionUpgradeOption, IDictionary serializedAdditionalRawData) + internal CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDeploymentProvisioningState? provisioningState, CognitiveServicesAccountDeploymentModel model, CognitiveServicesAccountDeploymentScaleSettings scaleSettings, IReadOnlyDictionary capabilities, string raiPolicyName, ServiceAccountCallRateLimit callRateLimit, IReadOnlyList rateLimits, DeploymentModelVersionUpgradeOption? versionUpgradeOption, bool? dynamicThrottlingEnabled, int? currentCapacity, DeploymentCapacitySettings capacitySettings, IDictionary serializedAdditionalRawData) { ProvisioningState = provisioningState; Model = model; @@ -72,6 +75,9 @@ internal CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDe CallRateLimit = callRateLimit; RateLimits = rateLimits; VersionUpgradeOption = versionUpgradeOption; + DynamicThrottlingEnabled = dynamicThrottlingEnabled; + CurrentCapacity = currentCapacity; + CapacitySettings = capacitySettings; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -81,7 +87,7 @@ internal CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDe /// Properties of Cognitive Services account deployment model. [WirePath("model")] public CognitiveServicesAccountDeploymentModel Model { get; set; } - /// Properties of Cognitive Services account deployment model. + /// Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku instead.). [WirePath("scaleSettings")] public CognitiveServicesAccountDeploymentScaleSettings ScaleSettings { get; set; } /// The capabilities. @@ -99,5 +105,14 @@ internal CognitiveServicesAccountDeploymentProperties(CognitiveServicesAccountDe /// Deployment model version upgrade option. [WirePath("versionUpgradeOption")] public DeploymentModelVersionUpgradeOption? VersionUpgradeOption { get; set; } + /// If the dynamic throttling is enabled. + [WirePath("dynamicThrottlingEnabled")] + public bool? DynamicThrottlingEnabled { get; } + /// The current capacity. + [WirePath("currentCapacity")] + public int? CurrentCapacity { get; set; } + /// Internal use only. + [WirePath("capacitySettings")] + public DeploymentCapacitySettings CapacitySettings { get; set; } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentScaleSettings.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentScaleSettings.cs index 025cd8a5f8fd5..f7e5aa4475d8f 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentScaleSettings.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountDeploymentScaleSettings.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.CognitiveServices.Models { - /// Properties of Cognitive Services account deployment model. + /// Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku instead.). public partial class CognitiveServicesAccountDeploymentScaleSettings { /// diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountModel.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountModel.cs index a63303154ac6c..6b2c4fb4a7b87 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountModel.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountModel.cs @@ -29,7 +29,7 @@ public CognitiveServicesAccountModel() /// Optional. Deployment model source ARM resource ID. /// The call rate limit Cognitive Services account. /// Keeps track of any properties unknown to the library. - /// Base Model Identifier. + /// Properties of Cognitive Services account deployment model. /// If the model is default version. /// The list of Model Sku. /// The max capacity. @@ -51,7 +51,7 @@ internal CognitiveServicesAccountModel(string format, string name, string versio SystemData = systemData; } - /// Base Model Identifier. + /// Properties of Cognitive Services account deployment model. [WirePath("baseModel")] public CognitiveServicesAccountDeploymentModel BaseModel { get; set; } /// If the model is default version. diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.Serialization.cs index 78dc0dc6fa5dd..b43b6f6e21709 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.Serialization.cs @@ -88,6 +88,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, } writer.WriteEndArray(); } + if (Optional.IsDefined(AmlWorkspace)) + { + writer.WritePropertyName("amlWorkspace"u8); + writer.WriteObjectValue(AmlWorkspace, options); + } if (options.Format != "W" && Optional.IsCollectionDefined(PrivateEndpointConnections)) { writer.WritePropertyName("privateEndpointConnections"u8); @@ -194,6 +199,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, writer.WritePropertyName("abusePenalty"u8); writer.WriteObjectValue(AbusePenalty, options); } + if (Optional.IsDefined(RaiMonitorConfig)) + { + writer.WritePropertyName("raiMonitorConfig"u8); + writer.WriteObjectValue(RaiMonitorConfig, options); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -242,6 +252,7 @@ internal static CognitiveServicesAccountProperties DeserializeCognitiveServicesA CognitiveServicesNetworkRuleSet networkAcls = default; ServiceAccountEncryptionProperties encryption = default; IList userOwnedStorage = default; + UserOwnedAmlWorkspace amlWorkspace = default; IReadOnlyList privateEndpointConnections = default; ServiceAccountPublicNetworkAccess? publicNetworkAccess = default; ServiceAccountApiProperties apiProperties = default; @@ -259,6 +270,7 @@ internal static CognitiveServicesAccountProperties DeserializeCognitiveServicesA CognitiveServicesMultiRegionSettings locations = default; IReadOnlyList commitmentPlanAssociations = default; AbusePenalty abusePenalty = default; + RaiMonitorConfig raiMonitorConfig = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -351,6 +363,15 @@ internal static CognitiveServicesAccountProperties DeserializeCognitiveServicesA userOwnedStorage = array; continue; } + if (property.NameEquals("amlWorkspace"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + amlWorkspace = UserOwnedAmlWorkspace.DeserializeUserOwnedAmlWorkspace(property.Value, options); + continue; + } if (property.NameEquals("privateEndpointConnections"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -520,6 +541,15 @@ internal static CognitiveServicesAccountProperties DeserializeCognitiveServicesA abusePenalty = AbusePenalty.DeserializeAbusePenalty(property.Value, options); continue; } + if (property.NameEquals("raiMonitorConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + raiMonitorConfig = RaiMonitorConfig.DeserializeRaiMonitorConfig(property.Value, options); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -537,6 +567,7 @@ internal static CognitiveServicesAccountProperties DeserializeCognitiveServicesA networkAcls, encryption, userOwnedStorage ?? new ChangeTrackingList(), + amlWorkspace, privateEndpointConnections ?? new ChangeTrackingList(), publicNetworkAccess, apiProperties, @@ -554,6 +585,7 @@ internal static CognitiveServicesAccountProperties DeserializeCognitiveServicesA locations, commitmentPlanAssociations ?? new ChangeTrackingList(), abusePenalty, + raiMonitorConfig, serializedAdditionalRawData); } @@ -759,6 +791,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AmlWorkspace), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" amlWorkspace: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(AmlWorkspace)) + { + builder.Append(" amlWorkspace: "); + BicepSerializationHelpers.AppendChildObject(builder, AmlWorkspace, options, 2, false, " amlWorkspace: "); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PrivateEndpointConnections), out propertyOverride); if (hasPropertyOverride) { @@ -1087,6 +1134,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(RaiMonitorConfig), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" raiMonitorConfig: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(RaiMonitorConfig)) + { + builder.Append(" raiMonitorConfig: "); + BicepSerializationHelpers.AppendChildObject(builder, RaiMonitorConfig, options, 2, false, " raiMonitorConfig: "); + } + } + builder.AppendLine("}"); return BinaryData.FromString(builder.ToString()); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.cs index cddb00bf4cbcd..0ad2112d5bfac 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesAccountProperties.cs @@ -67,6 +67,7 @@ public CognitiveServicesAccountProperties() /// A collection of rules governing the accessibility from specific network locations. /// The encryption properties for this resource. /// The storage accounts for this resource. + /// The user owned AML workspace properties. /// The private endpoint connection associated with the Cognitive Services account. /// Whether or not public endpoint access is allowed for this account. /// The api properties for special APIs. @@ -84,8 +85,9 @@ public CognitiveServicesAccountProperties() /// The multiregion settings of Cognitive Services account. /// The commitment plan associations of Cognitive Services account. /// The abuse penalty. + /// Cognitive Services Rai Monitor Config. /// Keeps track of any properties unknown to the library. - internal CognitiveServicesAccountProperties(ServiceAccountProvisioningState? provisioningState, string endpoint, IReadOnlyList capabilities, bool? isMigrated, string migrationToken, CognitiveServicesSkuChangeInfo skuChangeInfo, string customSubDomainName, CognitiveServicesNetworkRuleSet networkAcls, ServiceAccountEncryptionProperties encryption, IList userOwnedStorage, IReadOnlyList privateEndpointConnections, ServiceAccountPublicNetworkAccess? publicNetworkAccess, ServiceAccountApiProperties apiProperties, DateTimeOffset? createdOn, ServiceAccountCallRateLimit callRateLimit, bool? enableDynamicThrottling, ServiceAccountQuotaLimit quotaLimit, bool? restrictOutboundNetworkAccess, IList allowedFqdnList, bool? disableLocalAuth, IReadOnlyDictionary endpoints, bool? restore, DateTimeOffset? deletedOn, string scheduledPurgeDate, CognitiveServicesMultiRegionSettings locations, IReadOnlyList commitmentPlanAssociations, AbusePenalty abusePenalty, IDictionary serializedAdditionalRawData) + internal CognitiveServicesAccountProperties(ServiceAccountProvisioningState? provisioningState, string endpoint, IReadOnlyList capabilities, bool? isMigrated, string migrationToken, CognitiveServicesSkuChangeInfo skuChangeInfo, string customSubDomainName, CognitiveServicesNetworkRuleSet networkAcls, ServiceAccountEncryptionProperties encryption, IList userOwnedStorage, UserOwnedAmlWorkspace amlWorkspace, IReadOnlyList privateEndpointConnections, ServiceAccountPublicNetworkAccess? publicNetworkAccess, ServiceAccountApiProperties apiProperties, DateTimeOffset? createdOn, ServiceAccountCallRateLimit callRateLimit, bool? enableDynamicThrottling, ServiceAccountQuotaLimit quotaLimit, bool? restrictOutboundNetworkAccess, IList allowedFqdnList, bool? disableLocalAuth, IReadOnlyDictionary endpoints, bool? restore, DateTimeOffset? deletedOn, string scheduledPurgeDate, CognitiveServicesMultiRegionSettings locations, IReadOnlyList commitmentPlanAssociations, AbusePenalty abusePenalty, RaiMonitorConfig raiMonitorConfig, IDictionary serializedAdditionalRawData) { ProvisioningState = provisioningState; Endpoint = endpoint; @@ -97,6 +99,7 @@ internal CognitiveServicesAccountProperties(ServiceAccountProvisioningState? pro NetworkAcls = networkAcls; Encryption = encryption; UserOwnedStorage = userOwnedStorage; + AmlWorkspace = amlWorkspace; PrivateEndpointConnections = privateEndpointConnections; PublicNetworkAccess = publicNetworkAccess; ApiProperties = apiProperties; @@ -114,6 +117,7 @@ internal CognitiveServicesAccountProperties(ServiceAccountProvisioningState? pro Locations = locations; CommitmentPlanAssociations = commitmentPlanAssociations; AbusePenalty = abusePenalty; + RaiMonitorConfig = raiMonitorConfig; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -147,6 +151,9 @@ internal CognitiveServicesAccountProperties(ServiceAccountProvisioningState? pro /// The storage accounts for this resource. [WirePath("userOwnedStorage")] public IList UserOwnedStorage { get; } + /// The user owned AML workspace properties. + [WirePath("amlWorkspace")] + public UserOwnedAmlWorkspace AmlWorkspace { get; set; } /// The private endpoint connection associated with the Cognitive Services account. [WirePath("privateEndpointConnections")] public IReadOnlyList PrivateEndpointConnections { get; } @@ -198,5 +205,8 @@ internal CognitiveServicesAccountProperties(ServiceAccountProvisioningState? pro /// The abuse penalty. [WirePath("abusePenalty")] public AbusePenalty AbusePenalty { get; } + /// Cognitive Services Rai Monitor Config. + [WirePath("raiMonitorConfig")] + public RaiMonitorConfig RaiMonitorConfig { get; set; } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.Serialization.cs index a05ae5166ab4b..dfc8ebbfde437 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Text.Json; using Azure.Core; @@ -47,6 +48,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo writer.WritePropertyName("default"u8); writer.WriteNumberValue(Default.Value); } + if (Optional.IsCollectionDefined(AllowedValues)) + { + writer.WritePropertyName("allowedValues"u8); + writer.WriteStartArray(); + foreach (var item in AllowedValues) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -89,6 +100,7 @@ internal static CognitiveServicesCapacityConfig DeserializeCognitiveServicesCapa int? maximum = default; int? step = default; int? @default = default; + IList allowedValues = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -129,13 +141,33 @@ internal static CognitiveServicesCapacityConfig DeserializeCognitiveServicesCapa @default = property.Value.GetInt32(); continue; } + if (property.NameEquals("allowedValues"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + allowedValues = array; + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new CognitiveServicesCapacityConfig(minimum, maximum, step, @default, serializedAdditionalRawData); + return new CognitiveServicesCapacityConfig( + minimum, + maximum, + step, + @default, + allowedValues ?? new ChangeTrackingList(), + serializedAdditionalRawData); } private BinaryData SerializeBicep(ModelReaderWriterOptions options) @@ -209,6 +241,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AllowedValues), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" allowedValues: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(AllowedValues)) + { + if (AllowedValues.Any()) + { + builder.Append(" allowedValues: "); + builder.AppendLine("["); + foreach (var item in AllowedValues) + { + builder.AppendLine($" {item}"); + } + builder.AppendLine(" ]"); + } + } + } + builder.AppendLine("}"); return BinaryData.FromString(builder.ToString()); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.cs index 3de946bc5d358..2a862822465e5 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCapacityConfig.cs @@ -48,6 +48,7 @@ public partial class CognitiveServicesCapacityConfig /// Initializes a new instance of . public CognitiveServicesCapacityConfig() { + AllowedValues = new ChangeTrackingList(); } /// Initializes a new instance of . @@ -55,13 +56,15 @@ public CognitiveServicesCapacityConfig() /// The maximum capacity. /// The minimal incremental between allowed values for capacity. /// The default capacity. + /// The array of allowed values for capacity. /// Keeps track of any properties unknown to the library. - internal CognitiveServicesCapacityConfig(int? minimum, int? maximum, int? step, int? @default, IDictionary serializedAdditionalRawData) + internal CognitiveServicesCapacityConfig(int? minimum, int? maximum, int? step, int? @default, IList allowedValues, IDictionary serializedAdditionalRawData) { Minimum = minimum; Maximum = maximum; Step = step; Default = @default; + AllowedValues = allowedValues; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -77,5 +80,8 @@ internal CognitiveServicesCapacityConfig(int? minimum, int? maximum, int? step, /// The default capacity. [WirePath("default")] public int? Default { get; set; } + /// The array of allowed values for capacity. + [WirePath("allowedValues")] + public IList AllowedValues { get; } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.Serialization.cs index 65995fcf58a1a..a51e7ad2a2174 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.Serialization.cs @@ -42,6 +42,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader writer.WritePropertyName("skuName"u8); writer.WriteStringValue(SkuName); } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -83,6 +88,7 @@ internal static CognitiveServicesModel DeserializeCognitiveServicesModel(JsonEle CognitiveServicesAccountModel model = default; string kind = default; string skuName = default; + string description = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -106,13 +112,18 @@ internal static CognitiveServicesModel DeserializeCognitiveServicesModel(JsonEle skuName = property.Value.GetString(); continue; } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new CognitiveServicesModel(model, kind, skuName, serializedAdditionalRawData); + return new CognitiveServicesModel(model, kind, skuName, description, serializedAdditionalRawData); } private BinaryData SerializeBicep(ModelReaderWriterOptions options) @@ -187,6 +198,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" description: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Description)) + { + builder.Append(" description: "); + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + builder.AppendLine("}"); return BinaryData.FromString(builder.ToString()); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.cs index ba6c1cca28815..db79501573456 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModel.cs @@ -51,26 +51,31 @@ internal CognitiveServicesModel() } /// Initializes a new instance of . - /// Model Metadata. - /// The Kind of the Model. - /// The SKU of the Model. + /// Cognitive Services account Model. + /// The kind (type) of cognitive service account. + /// The name of SKU. + /// The description of the model. /// Keeps track of any properties unknown to the library. - internal CognitiveServicesModel(CognitiveServicesAccountModel model, string kind, string skuName, IDictionary serializedAdditionalRawData) + internal CognitiveServicesModel(CognitiveServicesAccountModel model, string kind, string skuName, string description, IDictionary serializedAdditionalRawData) { Model = model; Kind = kind; SkuName = skuName; + Description = description; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Model Metadata. + /// Cognitive Services account Model. [WirePath("model")] public CognitiveServicesAccountModel Model { get; } - /// The Kind of the Model. + /// The kind (type) of cognitive service account. [WirePath("kind")] public string Kind { get; } - /// The SKU of the Model. + /// The name of SKU. [WirePath("skuName")] public string SkuName { get; } + /// The description of the model. + [WirePath("description")] + public string Description { get; } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.Serialization.cs index 5c57b71fe47d6..32615b87ea621 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.Serialization.cs @@ -58,6 +58,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea } writer.WriteEndArray(); } + if (Optional.IsCollectionDefined(Cost)) + { + writer.WritePropertyName("cost"u8); + writer.WriteStartArray(); + foreach (var item in Cost) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -101,6 +111,7 @@ internal static CognitiveServicesModelSku DeserializeCognitiveServicesModelSku(J DateTimeOffset? deprecationDate = default; CognitiveServicesCapacityConfig capacity = default; IReadOnlyList rateLimits = default; + IList cost = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -147,6 +158,20 @@ internal static CognitiveServicesModelSku DeserializeCognitiveServicesModelSku(J rateLimits = array; continue; } + if (property.NameEquals("cost"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(BillingMeterInfo.DeserializeBillingMeterInfo(item, options)); + } + cost = array; + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -159,6 +184,7 @@ internal static CognitiveServicesModelSku DeserializeCognitiveServicesModelSku(J deprecationDate, capacity, rateLimits ?? new ChangeTrackingList(), + cost ?? new ChangeTrackingList(), serializedAdditionalRawData); } @@ -273,6 +299,29 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Cost), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" cost: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Cost)) + { + if (Cost.Any()) + { + builder.Append(" cost: "); + builder.AppendLine("["); + foreach (var item in Cost) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " cost: "); + } + builder.AppendLine(" ]"); + } + } + } + builder.AppendLine("}"); return BinaryData.FromString(builder.ToString()); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.cs index 4e042a76ccd3f..1bbf481ce2d31 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesModelSku.cs @@ -49,6 +49,7 @@ public partial class CognitiveServicesModelSku public CognitiveServicesModelSku() { RateLimits = new ChangeTrackingList(); + Cost = new ChangeTrackingList(); } /// Initializes a new instance of . @@ -57,14 +58,16 @@ public CognitiveServicesModelSku() /// The datetime of deprecation of the model SKU. /// The capacity configuration. /// The list of rateLimit. + /// The list of billing meter info. /// Keeps track of any properties unknown to the library. - internal CognitiveServicesModelSku(string name, string usageName, DateTimeOffset? deprecationOn, CognitiveServicesCapacityConfig capacity, IReadOnlyList rateLimits, IDictionary serializedAdditionalRawData) + internal CognitiveServicesModelSku(string name, string usageName, DateTimeOffset? deprecationOn, CognitiveServicesCapacityConfig capacity, IReadOnlyList rateLimits, IList cost, IDictionary serializedAdditionalRawData) { Name = name; UsageName = usageName; DeprecationOn = deprecationOn; Capacity = capacity; RateLimits = rateLimits; + Cost = cost; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -83,5 +86,8 @@ internal CognitiveServicesModelSku(string name, string usageName, DateTimeOffset /// The list of rateLimit. [WirePath("rateLimits")] public IReadOnlyList RateLimits { get; } + /// The list of billing meter info. + [WirePath("cost")] + public IList Cost { get; } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.Serialization.cs index dfaefc438388a..3b0628dc59249 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.Serialization.cs @@ -33,6 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo writer.WritePropertyName("defaultAction"u8); writer.WriteStringValue(DefaultAction.Value.ToString()); } + if (Optional.IsDefined(Bypass)) + { + writer.WritePropertyName("bypass"u8); + writer.WriteStringValue(Bypass.Value.ToString()); + } if (Optional.IsCollectionDefined(IPRules)) { writer.WritePropertyName("ipRules"u8); @@ -92,6 +97,7 @@ internal static CognitiveServicesNetworkRuleSet DeserializeCognitiveServicesNetw return null; } CognitiveServicesNetworkRuleAction? defaultAction = default; + ByPassSelection? bypass = default; IList ipRules = default; IList virtualNetworkRules = default; IDictionary serializedAdditionalRawData = default; @@ -107,6 +113,15 @@ internal static CognitiveServicesNetworkRuleSet DeserializeCognitiveServicesNetw defaultAction = new CognitiveServicesNetworkRuleAction(property.Value.GetString()); continue; } + if (property.NameEquals("bypass"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bypass = new ByPassSelection(property.Value.GetString()); + continue; + } if (property.NameEquals("ipRules"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -141,7 +156,7 @@ internal static CognitiveServicesNetworkRuleSet DeserializeCognitiveServicesNetw } } serializedAdditionalRawData = rawDataDictionary; - return new CognitiveServicesNetworkRuleSet(defaultAction, ipRules ?? new ChangeTrackingList(), virtualNetworkRules ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new CognitiveServicesNetworkRuleSet(defaultAction, bypass, ipRules ?? new ChangeTrackingList(), virtualNetworkRules ?? new ChangeTrackingList(), serializedAdditionalRawData); } private BinaryData SerializeBicep(ModelReaderWriterOptions options) @@ -170,6 +185,21 @@ private BinaryData SerializeBicep(ModelReaderWriterOptions options) } } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Bypass), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" bypass: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Bypass)) + { + builder.Append(" bypass: "); + builder.AppendLine($"'{Bypass.Value.ToString()}'"); + } + } + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IPRules), out propertyOverride); if (hasPropertyOverride) { diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.cs index 94c896ed3c865..945ad4d417777 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesNetworkRuleSet.cs @@ -54,12 +54,14 @@ public CognitiveServicesNetworkRuleSet() /// Initializes a new instance of . /// The default action when no rule from ipRules and from virtualNetworkRules match. This is only used after the bypass property has been evaluated. + /// Setting for trusted services. /// The list of IP address rules. /// The list of virtual network rules. /// Keeps track of any properties unknown to the library. - internal CognitiveServicesNetworkRuleSet(CognitiveServicesNetworkRuleAction? defaultAction, IList ipRules, IList virtualNetworkRules, IDictionary serializedAdditionalRawData) + internal CognitiveServicesNetworkRuleSet(CognitiveServicesNetworkRuleAction? defaultAction, ByPassSelection? bypass, IList ipRules, IList virtualNetworkRules, IDictionary serializedAdditionalRawData) { DefaultAction = defaultAction; + Bypass = bypass; IPRules = ipRules; VirtualNetworkRules = virtualNetworkRules; _serializedAdditionalRawData = serializedAdditionalRawData; @@ -68,6 +70,9 @@ internal CognitiveServicesNetworkRuleSet(CognitiveServicesNetworkRuleAction? def /// The default action when no rule from ipRules and from virtualNetworkRules match. This is only used after the bypass property has been evaluated. [WirePath("defaultAction")] public CognitiveServicesNetworkRuleAction? DefaultAction { get; set; } + /// Setting for trusted services. + [WirePath("bypass")] + public ByPassSelection? Bypass { get; set; } /// The list of IP address rules. [WirePath("ipRules")] public IList IPRules { get; } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesSkuAvailabilityContent.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesSkuAvailabilityContent.cs index 1ae6342b31ea7..af227845ff1e4 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesSkuAvailabilityContent.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesSkuAvailabilityContent.cs @@ -49,7 +49,7 @@ public partial class CognitiveServicesSkuAvailabilityContent /// Initializes a new instance of . /// The SKU of the resource. - /// The Kind of the resource. + /// The kind (type) of cognitive service account. /// The Type of the resource. /// or is null. public CognitiveServicesSkuAvailabilityContent(IEnumerable skus, string kind, ResourceType resourceType) @@ -64,7 +64,7 @@ public CognitiveServicesSkuAvailabilityContent(IEnumerable skus, string /// Initializes a new instance of . /// The SKU of the resource. - /// The Kind of the resource. + /// The kind (type) of cognitive service account. /// The Type of the resource. /// Keeps track of any properties unknown to the library. internal CognitiveServicesSkuAvailabilityContent(IList skus, string kind, ResourceType resourceType, IDictionary serializedAdditionalRawData) @@ -83,7 +83,7 @@ internal CognitiveServicesSkuAvailabilityContent() /// The SKU of the resource. [WirePath("skus")] public IList Skus { get; } - /// The Kind of the resource. + /// The kind (type) of cognitive service account. [WirePath("kind")] public string Kind { get; } /// The Type of the resource. diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ContentLevel.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ContentLevel.cs new file mode 100644 index 0000000000000..ed6bb7d97f2a9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ContentLevel.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Level at which content is filtered. + public readonly partial struct ContentLevel : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ContentLevel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LowValue = "Low"; + private const string MediumValue = "Medium"; + private const string HighValue = "High"; + + /// Low. + public static ContentLevel Low { get; } = new ContentLevel(LowValue); + /// Medium. + public static ContentLevel Medium { get; } = new ContentLevel(MediumValue); + /// High. + public static ContentLevel High { get; } = new ContentLevel(HighValue); + /// Determines if two values are the same. + public static bool operator ==(ContentLevel left, ContentLevel right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ContentLevel left, ContentLevel right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ContentLevel(string value) => new ContentLevel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ContentLevel other && Equals(other); + /// + public bool Equals(ContentLevel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CustomBlocklistConfig.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CustomBlocklistConfig.Serialization.cs new file mode 100644 index 0000000000000..2fdbcd7c1d56f --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CustomBlocklistConfig.Serialization.cs @@ -0,0 +1,224 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class CustomBlocklistConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CustomBlocklistConfig)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source.Value.ToString()); + } + if (Optional.IsDefined(BlocklistName)) + { + writer.WritePropertyName("blocklistName"u8); + writer.WriteStringValue(BlocklistName); + } + if (Optional.IsDefined(Blocking)) + { + writer.WritePropertyName("blocking"u8); + writer.WriteBooleanValue(Blocking.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CustomBlocklistConfig 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(CustomBlocklistConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCustomBlocklistConfig(document.RootElement, options); + } + + internal static CustomBlocklistConfig DeserializeCustomBlocklistConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RaiPolicyContentSource? source = default; + string blocklistName = default; + bool? blocking = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("source"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + source = new RaiPolicyContentSource(property.Value.GetString()); + continue; + } + if (property.NameEquals("blocklistName"u8)) + { + blocklistName = property.Value.GetString(); + continue; + } + if (property.NameEquals("blocking"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + blocking = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CustomBlocklistConfig(blocklistName, blocking, serializedAdditionalRawData, source); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" source: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Source)) + { + builder.Append(" source: "); + builder.AppendLine($"'{Source.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlocklistName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" blocklistName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(BlocklistName)) + { + builder.Append(" blocklistName: "); + if (BlocklistName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{BlocklistName}'''"); + } + else + { + builder.AppendLine($"'{BlocklistName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Blocking), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" blocking: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Blocking)) + { + builder.Append(" blocking: "); + var boolValue = Blocking.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(CustomBlocklistConfig)} does not support writing '{options.Format}' format."); + } + } + + CustomBlocklistConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCustomBlocklistConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CustomBlocklistConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CustomBlocklistConfig.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CustomBlocklistConfig.cs new file mode 100644 index 0000000000000..4bc043cc513bb --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CustomBlocklistConfig.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Gets or sets the source to which filter applies. + public partial class CustomBlocklistConfig : RaiBlocklistConfig + { + /// Initializes a new instance of . + public CustomBlocklistConfig() + { + } + + /// Initializes a new instance of . + /// Name of ContentFilter. + /// If blocking would occur. + /// Keeps track of any properties unknown to the library. + /// Content source to apply the Content Filters. + internal CustomBlocklistConfig(string blocklistName, bool? blocking, IDictionary serializedAdditionalRawData, RaiPolicyContentSource? source) : base(blocklistName, blocking, serializedAdditionalRawData) + { + Source = source; + } + + /// Content source to apply the Content Filters. + [WirePath("source")] + public RaiPolicyContentSource? Source { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingResult.Serialization.cs new file mode 100644 index 0000000000000..f065bd78359a6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class DefenderForAISettingResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DefenderForAISettingResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DefenderForAISettingResult 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(DefenderForAISettingResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDefenderForAISettingResult(document.RootElement, options); + } + + internal static DefenderForAISettingResult DeserializeDefenderForAISettingResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(DefenderForAISettingData.DeserializeDefenderForAISettingData(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DefenderForAISettingResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(DefenderForAISettingResult)} does not support writing '{options.Format}' format."); + } + } + + DefenderForAISettingResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDefenderForAISettingResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DefenderForAISettingResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingResult.cs new file mode 100644 index 0000000000000..91e9e5cb0f604 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of cognitive services Defender for AI Settings. + internal partial class DefenderForAISettingResult + { + /// + /// 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 DefenderForAISettingResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of Defender for AI Settings. + /// The list of Defender for AI Settings. + /// Keeps track of any properties unknown to the library. + internal DefenderForAISettingResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of Defender for AI Settings. + public string NextLink { get; } + /// The list of Defender for AI Settings. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingState.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingState.cs new file mode 100644 index 0000000000000..9e03f4cbeb8f5 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DefenderForAISettingState.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Defender for AI state on the AI resource. + public readonly partial struct DefenderForAISettingState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DefenderForAISettingState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; + + /// Disabled. + public static DefenderForAISettingState Disabled { get; } = new DefenderForAISettingState(DisabledValue); + /// Enabled. + public static DefenderForAISettingState Enabled { get; } = new DefenderForAISettingState(EnabledValue); + /// Determines if two values are the same. + public static bool operator ==(DefenderForAISettingState left, DefenderForAISettingState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DefenderForAISettingState left, DefenderForAISettingState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DefenderForAISettingState(string value) => new DefenderForAISettingState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DefenderForAISettingState other && Equals(other); + /// + public bool Equals(DefenderForAISettingState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentCapacitySettings.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentCapacitySettings.Serialization.cs new file mode 100644 index 0000000000000..98b0772b46c22 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentCapacitySettings.Serialization.cs @@ -0,0 +1,189 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class DeploymentCapacitySettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeploymentCapacitySettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(DesignatedCapacity)) + { + writer.WritePropertyName("designatedCapacity"u8); + writer.WriteNumberValue(DesignatedCapacity.Value); + } + if (Optional.IsDefined(Priority)) + { + writer.WritePropertyName("priority"u8); + writer.WriteNumberValue(Priority.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DeploymentCapacitySettings 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(DeploymentCapacitySettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeploymentCapacitySettings(document.RootElement, options); + } + + internal static DeploymentCapacitySettings DeserializeDeploymentCapacitySettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? designatedCapacity = default; + int? priority = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("designatedCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + designatedCapacity = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("priority"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + priority = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DeploymentCapacitySettings(designatedCapacity, priority, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DesignatedCapacity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" designatedCapacity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(DesignatedCapacity)) + { + builder.Append(" designatedCapacity: "); + builder.AppendLine($"{DesignatedCapacity.Value}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Priority), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" priority: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Priority)) + { + builder.Append(" priority: "); + builder.AppendLine($"{Priority.Value}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(DeploymentCapacitySettings)} does not support writing '{options.Format}' format."); + } + } + + DeploymentCapacitySettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDeploymentCapacitySettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeploymentCapacitySettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentCapacitySettings.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentCapacitySettings.cs new file mode 100644 index 0000000000000..641ee4e677f4b --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentCapacitySettings.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.CognitiveServices.Models +{ + /// Internal use only. + public partial class DeploymentCapacitySettings + { + /// + /// 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 DeploymentCapacitySettings() + { + } + + /// Initializes a new instance of . + /// The designated capacity. + /// The priority of this capacity setting. + /// Keeps track of any properties unknown to the library. + internal DeploymentCapacitySettings(int? designatedCapacity, int? priority, IDictionary serializedAdditionalRawData) + { + DesignatedCapacity = designatedCapacity; + Priority = priority; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The designated capacity. + [WirePath("designatedCapacity")] + public int? DesignatedCapacity { get; set; } + /// The priority of this capacity setting. + [WirePath("priority")] + public int? Priority { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentSkuListResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentSkuListResult.Serialization.cs new file mode 100644 index 0000000000000..cde008aee8979 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentSkuListResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class DeploymentSkuListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeploymentSkuListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DeploymentSkuListResult 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(DeploymentSkuListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeploymentSkuListResult(document.RootElement, options); + } + + internal static DeploymentSkuListResult DeserializeDeploymentSkuListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(SkuResource.DeserializeSkuResource(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DeploymentSkuListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(DeploymentSkuListResult)} does not support writing '{options.Format}' format."); + } + } + + DeploymentSkuListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDeploymentSkuListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeploymentSkuListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentSkuListResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentSkuListResult.cs new file mode 100644 index 0000000000000..b16d8c588dfbd --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/DeploymentSkuListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of cognitive services accounts operation response. + internal partial class DeploymentSkuListResult + { + /// + /// 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 DeploymentSkuListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of deployment skus. + /// Gets the list of Cognitive Services accounts deployment skus. + /// Keeps track of any properties unknown to the library. + internal DeploymentSkuListResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of deployment skus. + public string NextLink { get; } + /// Gets the list of Cognitive Services accounts deployment skus. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeListResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeListResult.Serialization.cs new file mode 100644 index 0000000000000..6cf10880acf88 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeListResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class EncryptionScopeListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncryptionScopeListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + EncryptionScopeListResult 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(EncryptionScopeListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncryptionScopeListResult(document.RootElement, options); + } + + internal static EncryptionScopeListResult DeserializeEncryptionScopeListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(EncryptionScopeData.DeserializeEncryptionScopeData(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EncryptionScopeListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(EncryptionScopeListResult)} does not support writing '{options.Format}' format."); + } + } + + EncryptionScopeListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEncryptionScopeListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncryptionScopeListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeListResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeListResult.cs new file mode 100644 index 0000000000000..eb6761716a088 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of cognitive services EncryptionScopes. + internal partial class EncryptionScopeListResult + { + /// + /// 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 EncryptionScopeListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of EncryptionScope. + /// The list of EncryptionScope. + /// Keeps track of any properties unknown to the library. + internal EncryptionScopeListResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of EncryptionScope. + public string NextLink { get; } + /// The list of EncryptionScope. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProperties.Serialization.cs new file mode 100644 index 0000000000000..cf7631a7b220f --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProperties.Serialization.cs @@ -0,0 +1,249 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class EncryptionScopeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncryptionScopeProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToString()); + } + if (Optional.IsDefined(KeyVaultProperties)) + { + writer.WritePropertyName("keyVaultProperties"u8); + writer.WriteObjectValue(KeyVaultProperties, options); + } + if (Optional.IsDefined(KeySource)) + { + writer.WritePropertyName("keySource"u8); + writer.WriteStringValue(KeySource.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + EncryptionScopeProperties 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(EncryptionScopeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncryptionScopeProperties(document.RootElement, options); + } + + internal static EncryptionScopeProperties DeserializeEncryptionScopeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EncryptionScopeProvisioningState? provisioningState = default; + EncryptionScopeState? state = default; + CognitiveServicesKeyVaultProperties keyVaultProperties = default; + ServiceAccountEncryptionKeySource? keySource = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new EncryptionScopeProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("state"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new EncryptionScopeState(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyVaultProperties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyVaultProperties = CognitiveServicesKeyVaultProperties.DeserializeCognitiveServicesKeyVaultProperties(property.Value, options); + continue; + } + if (property.NameEquals("keySource"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keySource = new ServiceAccountEncryptionKeySource(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EncryptionScopeProperties(keyVaultProperties, keySource, serializedAdditionalRawData, provisioningState, state); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" provisioningState: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ProvisioningState)) + { + builder.Append(" provisioningState: "); + builder.AppendLine($"'{ProvisioningState.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(State), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" state: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(State)) + { + builder.Append(" state: "); + builder.AppendLine($"'{State.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeyVaultProperties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keyVaultProperties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeyVaultProperties)) + { + builder.Append(" keyVaultProperties: "); + BicepSerializationHelpers.AppendChildObject(builder, KeyVaultProperties, options, 2, false, " keyVaultProperties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(KeySource), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" keySource: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(KeySource)) + { + builder.Append(" keySource: "); + builder.AppendLine($"'{KeySource.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(EncryptionScopeProperties)} does not support writing '{options.Format}' format."); + } + } + + EncryptionScopeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEncryptionScopeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncryptionScopeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProperties.cs new file mode 100644 index 0000000000000..e4755b8a68e64 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProperties.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Properties to EncryptionScope. + public partial class EncryptionScopeProperties : ServiceAccountEncryptionProperties + { + /// Initializes a new instance of . + public EncryptionScopeProperties() + { + } + + /// Initializes a new instance of . + /// Properties of KeyVault. + /// Enumerates the possible value of keySource for Encryption. + /// Keeps track of any properties unknown to the library. + /// Gets the status of the resource at the time the operation was called. + /// The encryptionScope state. + internal EncryptionScopeProperties(CognitiveServicesKeyVaultProperties keyVaultProperties, ServiceAccountEncryptionKeySource? keySource, IDictionary serializedAdditionalRawData, EncryptionScopeProvisioningState? provisioningState, EncryptionScopeState? state) : base(keyVaultProperties, keySource, serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + State = state; + } + + /// Gets the status of the resource at the time the operation was called. + [WirePath("provisioningState")] + public EncryptionScopeProvisioningState? ProvisioningState { get; } + /// The encryptionScope state. + [WirePath("state")] + public EncryptionScopeState? State { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProvisioningState.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProvisioningState.cs new file mode 100644 index 0000000000000..682d4072c713d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeProvisioningState.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Gets the status of the resource at the time the operation was called. + public readonly partial struct EncryptionScopeProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EncryptionScopeProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AcceptedValue = "Accepted"; + private const string CreatingValue = "Creating"; + private const string DeletingValue = "Deleting"; + private const string MovingValue = "Moving"; + private const string FailedValue = "Failed"; + private const string SucceededValue = "Succeeded"; + private const string CanceledValue = "Canceled"; + + /// Accepted. + public static EncryptionScopeProvisioningState Accepted { get; } = new EncryptionScopeProvisioningState(AcceptedValue); + /// Creating. + public static EncryptionScopeProvisioningState Creating { get; } = new EncryptionScopeProvisioningState(CreatingValue); + /// Deleting. + public static EncryptionScopeProvisioningState Deleting { get; } = new EncryptionScopeProvisioningState(DeletingValue); + /// Moving. + public static EncryptionScopeProvisioningState Moving { get; } = new EncryptionScopeProvisioningState(MovingValue); + /// Failed. + public static EncryptionScopeProvisioningState Failed { get; } = new EncryptionScopeProvisioningState(FailedValue); + /// Succeeded. + public static EncryptionScopeProvisioningState Succeeded { get; } = new EncryptionScopeProvisioningState(SucceededValue); + /// Canceled. + public static EncryptionScopeProvisioningState Canceled { get; } = new EncryptionScopeProvisioningState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(EncryptionScopeProvisioningState left, EncryptionScopeProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EncryptionScopeProvisioningState left, EncryptionScopeProvisioningState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator EncryptionScopeProvisioningState(string value) => new EncryptionScopeProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EncryptionScopeProvisioningState other && Equals(other); + /// + public bool Equals(EncryptionScopeProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeState.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeState.cs new file mode 100644 index 0000000000000..255044fd81b6f --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/EncryptionScopeState.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The encryptionScope state. + public readonly partial struct EncryptionScopeState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EncryptionScopeState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; + + /// Disabled. + public static EncryptionScopeState Disabled { get; } = new EncryptionScopeState(DisabledValue); + /// Enabled. + public static EncryptionScopeState Enabled { get; } = new EncryptionScopeState(EnabledValue); + /// Determines if two values are the same. + public static bool operator ==(EncryptionScopeState left, EncryptionScopeState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EncryptionScopeState left, EncryptionScopeState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator EncryptionScopeState(string value) => new EncryptionScopeState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EncryptionScopeState other && Equals(other); + /// + public bool Equals(EncryptionScopeState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkload.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkload.Serialization.cs new file mode 100644 index 0000000000000..c2d249f43e025 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkload.Serialization.cs @@ -0,0 +1,141 @@ +// 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.CognitiveServices.Models +{ + public partial class ModelCapacityCalculatorWorkload : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModelCapacityCalculatorWorkload)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(RequestPerMinute)) + { + writer.WritePropertyName("requestPerMinute"u8); + writer.WriteNumberValue(RequestPerMinute.Value); + } + if (Optional.IsDefined(RequestParameters)) + { + writer.WritePropertyName("requestParameters"u8); + writer.WriteObjectValue(RequestParameters, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ModelCapacityCalculatorWorkload 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(ModelCapacityCalculatorWorkload)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelCapacityCalculatorWorkload(document.RootElement, options); + } + + internal static ModelCapacityCalculatorWorkload DeserializeModelCapacityCalculatorWorkload(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long? requestPerMinute = default; + ModelCapacityCalculatorWorkloadRequestParam requestParameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("requestPerMinute"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestPerMinute = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("requestParameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestParameters = ModelCapacityCalculatorWorkloadRequestParam.DeserializeModelCapacityCalculatorWorkloadRequestParam(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModelCapacityCalculatorWorkload(requestPerMinute, requestParameters, 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(ModelCapacityCalculatorWorkload)} does not support writing '{options.Format}' format."); + } + } + + ModelCapacityCalculatorWorkload IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModelCapacityCalculatorWorkload(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelCapacityCalculatorWorkload)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkload.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkload.cs new file mode 100644 index 0000000000000..045c23f917cb1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkload.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.CognitiveServices.Models +{ + /// Model Capacity Calculator Workload. + public partial class ModelCapacityCalculatorWorkload + { + /// + /// 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 ModelCapacityCalculatorWorkload() + { + } + + /// Initializes a new instance of . + /// Request per minute. + /// Dictionary, Model Capacity Calculator Workload Parameters. + /// Keeps track of any properties unknown to the library. + internal ModelCapacityCalculatorWorkload(long? requestPerMinute, ModelCapacityCalculatorWorkloadRequestParam requestParameters, IDictionary serializedAdditionalRawData) + { + RequestPerMinute = requestPerMinute; + RequestParameters = requestParameters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Request per minute. + [WirePath("requestPerMinute")] + public long? RequestPerMinute { get; set; } + /// Dictionary, Model Capacity Calculator Workload Parameters. + [WirePath("requestParameters")] + public ModelCapacityCalculatorWorkloadRequestParam RequestParameters { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkloadRequestParam.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkloadRequestParam.Serialization.cs new file mode 100644 index 0000000000000..30591c1af00be --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkloadRequestParam.Serialization.cs @@ -0,0 +1,141 @@ +// 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.CognitiveServices.Models +{ + public partial class ModelCapacityCalculatorWorkloadRequestParam : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModelCapacityCalculatorWorkloadRequestParam)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(AvgPromptTokens)) + { + writer.WritePropertyName("avgPromptTokens"u8); + writer.WriteNumberValue(AvgPromptTokens.Value); + } + if (Optional.IsDefined(AvgGeneratedTokens)) + { + writer.WritePropertyName("avgGeneratedTokens"u8); + writer.WriteNumberValue(AvgGeneratedTokens.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ModelCapacityCalculatorWorkloadRequestParam 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(ModelCapacityCalculatorWorkloadRequestParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelCapacityCalculatorWorkloadRequestParam(document.RootElement, options); + } + + internal static ModelCapacityCalculatorWorkloadRequestParam DeserializeModelCapacityCalculatorWorkloadRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long? avgPromptTokens = default; + long? avgGeneratedTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("avgPromptTokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + avgPromptTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("avgGeneratedTokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + avgGeneratedTokens = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModelCapacityCalculatorWorkloadRequestParam(avgPromptTokens, avgGeneratedTokens, 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(ModelCapacityCalculatorWorkloadRequestParam)} does not support writing '{options.Format}' format."); + } + } + + ModelCapacityCalculatorWorkloadRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModelCapacityCalculatorWorkloadRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelCapacityCalculatorWorkloadRequestParam)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkloadRequestParam.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkloadRequestParam.cs new file mode 100644 index 0000000000000..6757e99805b65 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityCalculatorWorkloadRequestParam.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.CognitiveServices.Models +{ + /// Dictionary, Model Capacity Calculator Workload Parameters. + public partial class ModelCapacityCalculatorWorkloadRequestParam + { + /// + /// 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 ModelCapacityCalculatorWorkloadRequestParam() + { + } + + /// Initializes a new instance of . + /// Average prompt tokens. + /// Average generated tokens. + /// Keeps track of any properties unknown to the library. + internal ModelCapacityCalculatorWorkloadRequestParam(long? avgPromptTokens, long? avgGeneratedTokens, IDictionary serializedAdditionalRawData) + { + AvgPromptTokens = avgPromptTokens; + AvgGeneratedTokens = avgGeneratedTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Average prompt tokens. + [WirePath("avgPromptTokens")] + public long? AvgPromptTokens { get; set; } + /// Average generated tokens. + [WirePath("avgGeneratedTokens")] + public long? AvgGeneratedTokens { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResult.Serialization.cs new file mode 100644 index 0000000000000..1e3e1094793d6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class ModelCapacityListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModelCapacityListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ModelCapacityListResult 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(ModelCapacityListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelCapacityListResult(document.RootElement, options); + } + + internal static ModelCapacityListResult DeserializeModelCapacityListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(ModelCapacityListResultValueItem.DeserializeModelCapacityListResultValueItem(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModelCapacityListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ModelCapacityListResult)} does not support writing '{options.Format}' format."); + } + } + + ModelCapacityListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModelCapacityListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelCapacityListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResult.cs new file mode 100644 index 0000000000000..4f10d55dfefd0 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of cognitive services accounts operation response. + internal partial class ModelCapacityListResult + { + /// + /// 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 ModelCapacityListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of ModelSkuCapacity. + /// Gets the list of Cognitive Services accounts ModelSkuCapacity. + /// Keeps track of any properties unknown to the library. + internal ModelCapacityListResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of ModelSkuCapacity. + public string NextLink { get; } + /// Gets the list of Cognitive Services accounts ModelSkuCapacity. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResultValueItem.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResultValueItem.Serialization.cs new file mode 100644 index 0000000000000..ea44e83aae809 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResultValueItem.Serialization.cs @@ -0,0 +1,298 @@ +// 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; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class ModelCapacityListResultValueItem : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModelCapacityListResultValueItem)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.Value); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ModelCapacityListResultValueItem 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(ModelCapacityListResultValueItem)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelCapacityListResultValueItem(document.RootElement, options); + } + + internal static ModelCapacityListResultValueItem DeserializeModelCapacityListResultValueItem(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureLocation? location = default; + ModelSkuCapacityProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ModelSkuCapacityProperties.DeserializeModelSkuCapacityProperties(property.Value, options); + 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModelCapacityListResultValueItem( + id, + name, + type, + systemData, + location, + properties, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" location: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Location)) + { + builder.Append(" location: "); + builder.AppendLine($"'{Location.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ModelCapacityListResultValueItem)} does not support writing '{options.Format}' format."); + } + } + + ModelCapacityListResultValueItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModelCapacityListResultValueItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelCapacityListResultValueItem)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResultValueItem.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResultValueItem.cs new file mode 100644 index 0000000000000..7de926ef61596 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelCapacityListResultValueItem.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The ModelCapacityListResultValueItem. + public partial class ModelCapacityListResultValueItem : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ModelCapacityListResultValueItem() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The location of the Model Sku Capacity. + /// Cognitive Services account ModelSkuCapacity. + /// Keeps track of any properties unknown to the library. + internal ModelCapacityListResultValueItem(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AzureLocation? location, ModelSkuCapacityProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Location = location; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The location of the Model Sku Capacity. + [WirePath("location")] + public AzureLocation? Location { get; set; } + /// Cognitive Services account ModelSkuCapacity. + [WirePath("properties")] + public ModelSkuCapacityProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelSkuCapacityProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelSkuCapacityProperties.Serialization.cs new file mode 100644 index 0000000000000..923e13e7fbed4 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelSkuCapacityProperties.Serialization.cs @@ -0,0 +1,253 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class ModelSkuCapacityProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModelSkuCapacityProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteObjectValue(Model, options); + } + if (Optional.IsDefined(SkuName)) + { + writer.WritePropertyName("skuName"u8); + writer.WriteStringValue(SkuName); + } + if (Optional.IsDefined(AvailableCapacity)) + { + writer.WritePropertyName("availableCapacity"u8); + writer.WriteNumberValue(AvailableCapacity.Value); + } + if (Optional.IsDefined(AvailableFinetuneCapacity)) + { + writer.WritePropertyName("availableFinetuneCapacity"u8); + writer.WriteNumberValue(AvailableFinetuneCapacity.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ModelSkuCapacityProperties 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(ModelSkuCapacityProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelSkuCapacityProperties(document.RootElement, options); + } + + internal static ModelSkuCapacityProperties DeserializeModelSkuCapacityProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CognitiveServicesAccountDeploymentModel model = default; + string skuName = default; + float? availableCapacity = default; + float? availableFinetuneCapacity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = CognitiveServicesAccountDeploymentModel.DeserializeCognitiveServicesAccountDeploymentModel(property.Value, options); + continue; + } + if (property.NameEquals("skuName"u8)) + { + skuName = property.Value.GetString(); + continue; + } + if (property.NameEquals("availableCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + availableCapacity = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("availableFinetuneCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + availableFinetuneCapacity = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModelSkuCapacityProperties(model, skuName, availableCapacity, availableFinetuneCapacity, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Model), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" model: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Model)) + { + builder.Append(" model: "); + BicepSerializationHelpers.AppendChildObject(builder, Model, options, 2, false, " model: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SkuName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" skuName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SkuName)) + { + builder.Append(" skuName: "); + if (SkuName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{SkuName}'''"); + } + else + { + builder.AppendLine($"'{SkuName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailableCapacity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" availableCapacity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(AvailableCapacity)) + { + builder.Append(" availableCapacity: "); + builder.AppendLine($"'{AvailableCapacity.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AvailableFinetuneCapacity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" availableFinetuneCapacity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(AvailableFinetuneCapacity)) + { + builder.Append(" availableFinetuneCapacity: "); + builder.AppendLine($"'{AvailableFinetuneCapacity.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ModelSkuCapacityProperties)} does not support writing '{options.Format}' format."); + } + } + + ModelSkuCapacityProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModelSkuCapacityProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelSkuCapacityProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelSkuCapacityProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelSkuCapacityProperties.cs new file mode 100644 index 0000000000000..967f3ae750af4 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ModelSkuCapacityProperties.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Cognitive Services account ModelSkuCapacity. + public partial class ModelSkuCapacityProperties + { + /// + /// 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 ModelSkuCapacityProperties() + { + } + + /// Initializes a new instance of . + /// Properties of Cognitive Services account deployment model. + /// + /// The available capacity for deployment with this model and sku. + /// The available capacity for deployment with a fine-tune version of this model and sku. + /// Keeps track of any properties unknown to the library. + internal ModelSkuCapacityProperties(CognitiveServicesAccountDeploymentModel model, string skuName, float? availableCapacity, float? availableFinetuneCapacity, IDictionary serializedAdditionalRawData) + { + Model = model; + SkuName = skuName; + AvailableCapacity = availableCapacity; + AvailableFinetuneCapacity = availableFinetuneCapacity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Properties of Cognitive Services account deployment model. + [WirePath("model")] + public CognitiveServicesAccountDeploymentModel Model { get; set; } + /// Gets or sets the sku name. + [WirePath("skuName")] + public string SkuName { get; set; } + /// The available capacity for deployment with this model and sku. + [WirePath("availableCapacity")] + public float? AvailableCapacity { get; set; } + /// The available capacity for deployment with a fine-tune version of this model and sku. + [WirePath("availableFinetuneCapacity")] + public float? AvailableFinetuneCapacity { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeter.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeter.Serialization.cs new file mode 100644 index 0000000000000..10ef7495a8f25 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeter.Serialization.cs @@ -0,0 +1,223 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class NetworkSecurityPerimeter : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeter)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(PerimeterGuid)) + { + writer.WritePropertyName("perimeterGuid"u8); + writer.WriteStringValue(PerimeterGuid); + } + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeter 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(NetworkSecurityPerimeter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeter(document.RootElement, options); + } + + internal static NetworkSecurityPerimeter DeserializeNetworkSecurityPerimeter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string perimeterGuid = default; + AzureLocation? location = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("perimeterGuid"u8)) + { + perimeterGuid = property.Value.GetString(); + continue; + } + if (property.NameEquals("location"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeter(id, perimeterGuid, location, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PerimeterGuid), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" perimeterGuid: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(PerimeterGuid)) + { + builder.Append(" perimeterGuid: "); + if (PerimeterGuid.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{PerimeterGuid}'''"); + } + else + { + builder.AppendLine($"'{PerimeterGuid}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Location), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" location: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Location)) + { + builder.Append(" location: "); + builder.AppendLine($"'{Location.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeter)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeter.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeter.cs new file mode 100644 index 0000000000000..8da9a3ae073c9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeter.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Information about a linked Network Security Perimeter. + public partial class NetworkSecurityPerimeter + { + /// + /// 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 NetworkSecurityPerimeter() + { + } + + /// Initializes a new instance of . + /// Fully qualified identifier of the resource. + /// Guid of the resource. + /// Location of the resource. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeter(ResourceIdentifier id, string perimeterGuid, AzureLocation? location, IDictionary serializedAdditionalRawData) + { + Id = id; + PerimeterGuid = perimeterGuid; + Location = location; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Fully qualified identifier of the resource. + [WirePath("id")] + public ResourceIdentifier Id { get; set; } + /// Guid of the resource. + [WirePath("perimeterGuid")] + public string PerimeterGuid { get; set; } + /// Location of the resource. + [WirePath("location")] + public AzureLocation? Location { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRule.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRule.Serialization.cs new file mode 100644 index 0000000000000..4ed66725231e1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRule.Serialization.cs @@ -0,0 +1,193 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class NetworkSecurityPerimeterAccessRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterAccessRule)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterAccessRule 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(NetworkSecurityPerimeterAccessRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterAccessRule(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterAccessRule DeserializeNetworkSecurityPerimeterAccessRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + NetworkSecurityPerimeterAccessRuleProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = NetworkSecurityPerimeterAccessRuleProperties.DeserializeNetworkSecurityPerimeterAccessRuleProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterAccessRule(name, properties, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterAccessRule)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterAccessRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeterAccessRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterAccessRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRule.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRule.cs new file mode 100644 index 0000000000000..dd922fccce931 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRule.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.CognitiveServices.Models +{ + /// Network Security Perimeter Access Rule. + public partial class NetworkSecurityPerimeterAccessRule + { + /// + /// 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 NetworkSecurityPerimeterAccessRule() + { + } + + /// Initializes a new instance of . + /// Network Security Perimeter Access Rule Name. + /// Properties of Network Security Perimeter Access Rule. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterAccessRule(string name, NetworkSecurityPerimeterAccessRuleProperties properties, IDictionary serializedAdditionalRawData) + { + Name = name; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Network Security Perimeter Access Rule Name. + [WirePath("name")] + public string Name { get; set; } + /// Properties of Network Security Perimeter Access Rule. + [WirePath("properties")] + public NetworkSecurityPerimeterAccessRuleProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRuleProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRuleProperties.Serialization.cs new file mode 100644 index 0000000000000..79b3b727f1942 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRuleProperties.Serialization.cs @@ -0,0 +1,385 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class NetworkSecurityPerimeterAccessRuleProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterAccessRuleProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Direction)) + { + writer.WritePropertyName("direction"u8); + writer.WriteStringValue(Direction.Value.ToString()); + } + if (Optional.IsCollectionDefined(AddressPrefixes)) + { + writer.WritePropertyName("addressPrefixes"u8); + writer.WriteStartArray(); + foreach (var item in AddressPrefixes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Subscriptions)) + { + writer.WritePropertyName("subscriptions"u8); + writer.WriteStartArray(); + foreach (var item in Subscriptions) + { + JsonSerializer.Serialize(writer, item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(NetworkSecurityPerimeters)) + { + writer.WritePropertyName("networkSecurityPerimeters"u8); + writer.WriteStartArray(); + foreach (var item in NetworkSecurityPerimeters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(FullyQualifiedDomainNames)) + { + writer.WritePropertyName("fullyQualifiedDomainNames"u8); + writer.WriteStartArray(); + foreach (var item in FullyQualifiedDomainNames) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterAccessRuleProperties 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(NetworkSecurityPerimeterAccessRuleProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterAccessRuleProperties(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterAccessRuleProperties DeserializeNetworkSecurityPerimeterAccessRuleProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NspAccessRuleDirection? direction = default; + IList addressPrefixes = default; + IList subscriptions = default; + IList networkSecurityPerimeters = default; + IList fullyQualifiedDomainNames = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("direction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + direction = new NspAccessRuleDirection(property.Value.GetString()); + continue; + } + if (property.NameEquals("addressPrefixes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + addressPrefixes = array; + continue; + } + if (property.NameEquals("subscriptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + subscriptions = array; + continue; + } + if (property.NameEquals("networkSecurityPerimeters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NetworkSecurityPerimeter.DeserializeNetworkSecurityPerimeter(item, options)); + } + networkSecurityPerimeters = array; + continue; + } + if (property.NameEquals("fullyQualifiedDomainNames"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fullyQualifiedDomainNames = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterAccessRuleProperties( + direction, + addressPrefixes ?? new ChangeTrackingList(), + subscriptions ?? new ChangeTrackingList(), + networkSecurityPerimeters ?? new ChangeTrackingList(), + fullyQualifiedDomainNames ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Direction), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" direction: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Direction)) + { + builder.Append(" direction: "); + builder.AppendLine($"'{Direction.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AddressPrefixes), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" addressPrefixes: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(AddressPrefixes)) + { + if (AddressPrefixes.Any()) + { + builder.Append(" addressPrefixes: "); + builder.AppendLine("["); + foreach (var item in AddressPrefixes) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Subscriptions), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" subscriptions: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Subscriptions)) + { + if (Subscriptions.Any()) + { + builder.Append(" subscriptions: "); + builder.AppendLine("["); + foreach (var item in Subscriptions) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " subscriptions: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetworkSecurityPerimeters), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" networkSecurityPerimeters: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(NetworkSecurityPerimeters)) + { + if (NetworkSecurityPerimeters.Any()) + { + builder.Append(" networkSecurityPerimeters: "); + builder.AppendLine("["); + foreach (var item in NetworkSecurityPerimeters) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " networkSecurityPerimeters: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(FullyQualifiedDomainNames), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" fullyQualifiedDomainNames: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(FullyQualifiedDomainNames)) + { + if (FullyQualifiedDomainNames.Any()) + { + builder.Append(" fullyQualifiedDomainNames: "); + builder.AppendLine("["); + foreach (var item in FullyQualifiedDomainNames) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterAccessRuleProperties)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterAccessRuleProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeterAccessRuleProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterAccessRuleProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRuleProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRuleProperties.cs new file mode 100644 index 0000000000000..2aa10281d949d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterAccessRuleProperties.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The Properties of Network Security Perimeter Rule. + public partial class NetworkSecurityPerimeterAccessRuleProperties + { + /// + /// 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 NetworkSecurityPerimeterAccessRuleProperties() + { + AddressPrefixes = new ChangeTrackingList(); + Subscriptions = new ChangeTrackingList(); + NetworkSecurityPerimeters = new ChangeTrackingList(); + FullyQualifiedDomainNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Direction of Access Rule. + /// Address prefixes for inbound rules. + /// Subscriptions for inbound rules. + /// NetworkSecurityPerimeters for inbound rules. + /// Fully qualified domain name for outbound rules. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterAccessRuleProperties(NspAccessRuleDirection? direction, IList addressPrefixes, IList subscriptions, IList networkSecurityPerimeters, IList fullyQualifiedDomainNames, IDictionary serializedAdditionalRawData) + { + Direction = direction; + AddressPrefixes = addressPrefixes; + Subscriptions = subscriptions; + NetworkSecurityPerimeters = networkSecurityPerimeters; + FullyQualifiedDomainNames = fullyQualifiedDomainNames; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Direction of Access Rule. + [WirePath("direction")] + public NspAccessRuleDirection? Direction { get; set; } + /// Address prefixes for inbound rules. + [WirePath("addressPrefixes")] + public IList AddressPrefixes { get; } + /// Subscriptions for inbound rules. + [WirePath("subscriptions")] + public IList Subscriptions { get; } + /// NetworkSecurityPerimeters for inbound rules. + [WirePath("networkSecurityPerimeters")] + public IList NetworkSecurityPerimeters { get; } + /// Fully qualified domain name for outbound rules. + [WirePath("fullyQualifiedDomainNames")] + public IList FullyQualifiedDomainNames { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationAssociationInfo.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationAssociationInfo.Serialization.cs new file mode 100644 index 0000000000000..8c130c0b96c10 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationAssociationInfo.Serialization.cs @@ -0,0 +1,197 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class NetworkSecurityPerimeterConfigurationAssociationInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationAssociationInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(AccessMode)) + { + writer.WritePropertyName("accessMode"u8); + writer.WriteStringValue(AccessMode); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterConfigurationAssociationInfo 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(NetworkSecurityPerimeterConfigurationAssociationInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterConfigurationAssociationInfo(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterConfigurationAssociationInfo DeserializeNetworkSecurityPerimeterConfigurationAssociationInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string accessMode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("accessMode"u8)) + { + accessMode = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterConfigurationAssociationInfo(name, accessMode, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessMode), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" accessMode: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(AccessMode)) + { + builder.Append(" accessMode: "); + if (AccessMode.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AccessMode}'''"); + } + else + { + builder.AppendLine($"'{AccessMode}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationAssociationInfo)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterConfigurationAssociationInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeterConfigurationAssociationInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationAssociationInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationAssociationInfo.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationAssociationInfo.cs new file mode 100644 index 0000000000000..a2280a1569f1e --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationAssociationInfo.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.CognitiveServices.Models +{ + /// Network Security Perimeter Configuration Association Information. + public partial class NetworkSecurityPerimeterConfigurationAssociationInfo + { + /// + /// 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 NetworkSecurityPerimeterConfigurationAssociationInfo() + { + } + + /// Initializes a new instance of . + /// Name of the resource association. + /// Access Mode of the resource association. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterConfigurationAssociationInfo(string name, string accessMode, IDictionary serializedAdditionalRawData) + { + Name = name; + AccessMode = accessMode; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of the resource association. + [WirePath("name")] + public string Name { get; set; } + /// Access Mode of the resource association. + [WirePath("accessMode")] + public string AccessMode { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationList.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationList.Serialization.cs new file mode 100644 index 0000000000000..e5b7a9362286f --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationList.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class NetworkSecurityPerimeterConfigurationList : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationList)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Value)) + { + 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); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterConfigurationList 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(NetworkSecurityPerimeterConfigurationList)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterConfigurationList(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterConfigurationList DeserializeNetworkSecurityPerimeterConfigurationList(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NetworkSecurityPerimeterConfigurationData.DeserializeNetworkSecurityPerimeterConfigurationData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterConfigurationList(value ?? new ChangeTrackingList(), nextLink, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationList)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterConfigurationList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeterConfigurationList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationList)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationList.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationList.cs new file mode 100644 index 0000000000000..a8d80cda7b2db --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationList.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// A list of NSP configurations for an Cognitive Services account. + internal partial class NetworkSecurityPerimeterConfigurationList + { + /// + /// 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 NetworkSecurityPerimeterConfigurationList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Array of NSP configurations List Result for an Cognitive Services account. + /// Link to retrieve next page of results. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterConfigurationList(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Array of NSP configurations List Result for an Cognitive Services account. + public IReadOnlyList Value { get; } + /// Link to retrieve next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationProperties.Serialization.cs new file mode 100644 index 0000000000000..e6d28a1b2df2d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationProperties.Serialization.cs @@ -0,0 +1,308 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class NetworkSecurityPerimeterConfigurationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + if (Optional.IsCollectionDefined(ProvisioningIssues)) + { + writer.WritePropertyName("provisioningIssues"u8); + writer.WriteStartArray(); + foreach (var item in ProvisioningIssues) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NetworkSecurityPerimeter)) + { + writer.WritePropertyName("networkSecurityPerimeter"u8); + writer.WriteObjectValue(NetworkSecurityPerimeter, options); + } + if (Optional.IsDefined(ResourceAssociation)) + { + writer.WritePropertyName("resourceAssociation"u8); + writer.WriteObjectValue(ResourceAssociation, options); + } + if (Optional.IsDefined(Profile)) + { + writer.WritePropertyName("profile"u8); + writer.WriteObjectValue(Profile, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterConfigurationProperties 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(NetworkSecurityPerimeterConfigurationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterConfigurationProperties(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterConfigurationProperties DeserializeNetworkSecurityPerimeterConfigurationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string provisioningState = default; + IList provisioningIssues = default; + NetworkSecurityPerimeter networkSecurityPerimeter = default; + NetworkSecurityPerimeterConfigurationAssociationInfo resourceAssociation = default; + NetworkSecurityPerimeterProfileInfo profile = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + provisioningState = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningIssues"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ProvisioningIssue.DeserializeProvisioningIssue(item, options)); + } + provisioningIssues = array; + continue; + } + if (property.NameEquals("networkSecurityPerimeter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkSecurityPerimeter = NetworkSecurityPerimeter.DeserializeNetworkSecurityPerimeter(property.Value, options); + continue; + } + if (property.NameEquals("resourceAssociation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceAssociation = NetworkSecurityPerimeterConfigurationAssociationInfo.DeserializeNetworkSecurityPerimeterConfigurationAssociationInfo(property.Value, options); + continue; + } + if (property.NameEquals("profile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + profile = NetworkSecurityPerimeterProfileInfo.DeserializeNetworkSecurityPerimeterProfileInfo(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterConfigurationProperties( + provisioningState, + provisioningIssues ?? new ChangeTrackingList(), + networkSecurityPerimeter, + resourceAssociation, + profile, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningState), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" provisioningState: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ProvisioningState)) + { + builder.Append(" provisioningState: "); + if (ProvisioningState.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ProvisioningState}'''"); + } + else + { + builder.AppendLine($"'{ProvisioningState}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ProvisioningIssues), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" provisioningIssues: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(ProvisioningIssues)) + { + if (ProvisioningIssues.Any()) + { + builder.Append(" provisioningIssues: "); + builder.AppendLine("["); + foreach (var item in ProvisioningIssues) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " provisioningIssues: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NetworkSecurityPerimeter), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" networkSecurityPerimeter: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NetworkSecurityPerimeter)) + { + builder.Append(" networkSecurityPerimeter: "); + BicepSerializationHelpers.AppendChildObject(builder, NetworkSecurityPerimeter, options, 2, false, " networkSecurityPerimeter: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceAssociation), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" resourceAssociation: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ResourceAssociation)) + { + builder.Append(" resourceAssociation: "); + BicepSerializationHelpers.AppendChildObject(builder, ResourceAssociation, options, 2, false, " resourceAssociation: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Profile), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" profile: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Profile)) + { + builder.Append(" profile: "); + BicepSerializationHelpers.AppendChildObject(builder, Profile, options, 2, false, " profile: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationProperties)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterConfigurationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeterConfigurationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationProperties.cs new file mode 100644 index 0000000000000..e64c41672058d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterConfigurationProperties.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The properties of an NSP Configuration. + public partial class NetworkSecurityPerimeterConfigurationProperties + { + /// + /// 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 NetworkSecurityPerimeterConfigurationProperties() + { + ProvisioningIssues = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Provisioning state of NetworkSecurityPerimeter configuration. + /// List of Provisioning Issues. + /// Information about a linked Network Security Perimeter. + /// Network Security Perimeter Configuration Association Information. + /// Network Security Perimeter Profile Information. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterConfigurationProperties(string provisioningState, IList provisioningIssues, NetworkSecurityPerimeter networkSecurityPerimeter, NetworkSecurityPerimeterConfigurationAssociationInfo resourceAssociation, NetworkSecurityPerimeterProfileInfo profile, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + ProvisioningIssues = provisioningIssues; + NetworkSecurityPerimeter = networkSecurityPerimeter; + ResourceAssociation = resourceAssociation; + Profile = profile; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Provisioning state of NetworkSecurityPerimeter configuration. + [WirePath("provisioningState")] + public string ProvisioningState { get; } + /// List of Provisioning Issues. + [WirePath("provisioningIssues")] + public IList ProvisioningIssues { get; } + /// Information about a linked Network Security Perimeter. + [WirePath("networkSecurityPerimeter")] + public NetworkSecurityPerimeter NetworkSecurityPerimeter { get; set; } + /// Network Security Perimeter Configuration Association Information. + [WirePath("resourceAssociation")] + public NetworkSecurityPerimeterConfigurationAssociationInfo ResourceAssociation { get; set; } + /// Network Security Perimeter Profile Information. + [WirePath("profile")] + public NetworkSecurityPerimeterProfileInfo Profile { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterProfileInfo.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterProfileInfo.Serialization.cs new file mode 100644 index 0000000000000..eb54a0b35c573 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterProfileInfo.Serialization.cs @@ -0,0 +1,339 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class NetworkSecurityPerimeterProfileInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterProfileInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(AccessRulesVersion)) + { + writer.WritePropertyName("accessRulesVersion"u8); + writer.WriteNumberValue(AccessRulesVersion.Value); + } + if (Optional.IsCollectionDefined(AccessRules)) + { + writer.WritePropertyName("accessRules"u8); + writer.WriteStartArray(); + foreach (var item in AccessRules) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(DiagnosticSettingsVersion)) + { + writer.WritePropertyName("diagnosticSettingsVersion"u8); + writer.WriteNumberValue(DiagnosticSettingsVersion.Value); + } + if (Optional.IsCollectionDefined(EnabledLogCategories)) + { + writer.WritePropertyName("enabledLogCategories"u8); + writer.WriteStartArray(); + foreach (var item in EnabledLogCategories) + { + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterProfileInfo 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(NetworkSecurityPerimeterProfileInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterProfileInfo(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterProfileInfo DeserializeNetworkSecurityPerimeterProfileInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + long? accessRulesVersion = default; + IList accessRules = default; + long? diagnosticSettingsVersion = default; + IList enabledLogCategories = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("accessRulesVersion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + accessRulesVersion = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("accessRules"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NetworkSecurityPerimeterAccessRule.DeserializeNetworkSecurityPerimeterAccessRule(item, options)); + } + accessRules = array; + continue; + } + if (property.NameEquals("diagnosticSettingsVersion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diagnosticSettingsVersion = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("enabledLogCategories"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + enabledLogCategories = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterProfileInfo( + name, + accessRulesVersion, + accessRules ?? new ChangeTrackingList(), + diagnosticSettingsVersion, + enabledLogCategories ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessRulesVersion), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" accessRulesVersion: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(AccessRulesVersion)) + { + builder.Append(" accessRulesVersion: "); + builder.AppendLine($"'{AccessRulesVersion.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AccessRules), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" accessRules: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(AccessRules)) + { + if (AccessRules.Any()) + { + builder.Append(" accessRules: "); + builder.AppendLine("["); + foreach (var item in AccessRules) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " accessRules: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(DiagnosticSettingsVersion), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" diagnosticSettingsVersion: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(DiagnosticSettingsVersion)) + { + builder.Append(" diagnosticSettingsVersion: "); + builder.AppendLine($"'{DiagnosticSettingsVersion.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(EnabledLogCategories), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" enabledLogCategories: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(EnabledLogCategories)) + { + if (EnabledLogCategories.Any()) + { + builder.Append(" enabledLogCategories: "); + builder.AppendLine("["); + foreach (var item in EnabledLogCategories) + { + if (item == null) + { + builder.Append("null"); + continue; + } + if (item.Contains(Environment.NewLine)) + { + builder.AppendLine(" '''"); + builder.AppendLine($"{item}'''"); + } + else + { + builder.AppendLine($" '{item}'"); + } + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterProfileInfo)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterProfileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeterProfileInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterProfileInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterProfileInfo.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterProfileInfo.cs new file mode 100644 index 0000000000000..3219e4c44351d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NetworkSecurityPerimeterProfileInfo.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Network Security Perimeter Profile Information. + public partial class NetworkSecurityPerimeterProfileInfo + { + /// + /// 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 NetworkSecurityPerimeterProfileInfo() + { + AccessRules = new ChangeTrackingList(); + EnabledLogCategories = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Name of the resource profile. + /// Access rules version of the resource profile. + /// + /// Current diagnostic settings version. + /// List of enabled log categories. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterProfileInfo(string name, long? accessRulesVersion, IList accessRules, long? diagnosticSettingsVersion, IList enabledLogCategories, IDictionary serializedAdditionalRawData) + { + Name = name; + AccessRulesVersion = accessRulesVersion; + AccessRules = accessRules; + DiagnosticSettingsVersion = diagnosticSettingsVersion; + EnabledLogCategories = enabledLogCategories; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of the resource profile. + [WirePath("name")] + public string Name { get; set; } + /// Access rules version of the resource profile. + [WirePath("accessRulesVersion")] + public long? AccessRulesVersion { get; set; } + /// Gets the access rules. + [WirePath("accessRules")] + public IList AccessRules { get; } + /// Current diagnostic settings version. + [WirePath("diagnosticSettingsVersion")] + public long? DiagnosticSettingsVersion { get; set; } + /// List of enabled log categories. + [WirePath("enabledLogCategories")] + public IList EnabledLogCategories { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NspAccessRuleDirection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NspAccessRuleDirection.cs new file mode 100644 index 0000000000000..376dd152173a2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/NspAccessRuleDirection.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Direction of Access Rule. + public readonly partial struct NspAccessRuleDirection : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NspAccessRuleDirection(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InboundValue = "Inbound"; + private const string OutboundValue = "Outbound"; + + /// Inbound. + public static NspAccessRuleDirection Inbound { get; } = new NspAccessRuleDirection(InboundValue); + /// Outbound. + public static NspAccessRuleDirection Outbound { get; } = new NspAccessRuleDirection(OutboundValue); + /// Determines if two values are the same. + public static bool operator ==(NspAccessRuleDirection left, NspAccessRuleDirection right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NspAccessRuleDirection left, NspAccessRuleDirection right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator NspAccessRuleDirection(string value) => new NspAccessRuleDirection(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NspAccessRuleDirection other && Equals(other); + /// + public bool Equals(NspAccessRuleDirection other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCommitmentPlanPatch.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/PatchResourceTagsAndSku.Serialization.cs similarity index 65% rename from sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCommitmentPlanPatch.Serialization.cs rename to sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/PatchResourceTagsAndSku.Serialization.cs index 924806c238716..5319d59762c8c 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCommitmentPlanPatch.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/PatchResourceTagsAndSku.Serialization.cs @@ -13,16 +13,16 @@ namespace Azure.ResourceManager.CognitiveServices.Models { - public partial class CognitiveServicesCommitmentPlanPatch : IUtf8JsonSerializable, IJsonModel + public partial class PatchResourceTagsAndSku : 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) { - 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(CognitiveServicesCommitmentPlanPatch)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(PatchResourceTagsAndSku)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -60,19 +60,19 @@ void IJsonModel.Write(Utf8JsonWriter write writer.WriteEndObject(); } - CognitiveServicesCommitmentPlanPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + PatchResourceTagsAndSku 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(CognitiveServicesCommitmentPlanPatch)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(PatchResourceTagsAndSku)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCognitiveServicesCommitmentPlanPatch(document.RootElement, options); + return DeserializePatchResourceTagsAndSku(document.RootElement, options); } - internal static CognitiveServicesCommitmentPlanPatch DeserializeCognitiveServicesCommitmentPlanPatch(JsonElement element, ModelReaderWriterOptions options = null) + internal static PatchResourceTagsAndSku DeserializePatchResourceTagsAndSku(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -115,38 +115,38 @@ internal static CognitiveServicesCommitmentPlanPatch DeserializeCognitiveService } } serializedAdditionalRawData = rawDataDictionary; - return new CognitiveServicesCommitmentPlanPatch(tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData, sku); + return new PatchResourceTagsAndSku(tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData, sku); } - 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(CognitiveServicesCommitmentPlanPatch)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(PatchResourceTagsAndSku)} does not support writing '{options.Format}' format."); } } - CognitiveServicesCommitmentPlanPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + PatchResourceTagsAndSku 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); - return DeserializeCognitiveServicesCommitmentPlanPatch(document.RootElement, options); + return DeserializePatchResourceTagsAndSku(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(CognitiveServicesCommitmentPlanPatch)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(PatchResourceTagsAndSku)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCommitmentPlanPatch.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/PatchResourceTagsAndSku.cs similarity index 59% rename from sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCommitmentPlanPatch.cs rename to sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/PatchResourceTagsAndSku.cs index 42b7b1575d75e..c0949ff93a5a4 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesCommitmentPlanPatch.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/PatchResourceTagsAndSku.cs @@ -11,18 +11,18 @@ namespace Azure.ResourceManager.CognitiveServices.Models { /// The object being used to update tags and sku of a resource, in general used for PATCH operations. - public partial class CognitiveServicesCommitmentPlanPatch : CognitiveServicesPatchResourceTags + public partial class PatchResourceTagsAndSku : CognitiveServicesPatchResourceTags { - /// Initializes a new instance of . - public CognitiveServicesCommitmentPlanPatch() + /// Initializes a new instance of . + public PatchResourceTagsAndSku() { } - /// Initializes a new instance of . + /// Initializes a new instance of . /// Resource tags. /// Keeps track of any properties unknown to the library. /// The resource model definition representing SKU. - internal CognitiveServicesCommitmentPlanPatch(IDictionary tags, IDictionary serializedAdditionalRawData, CognitiveServicesSku sku) : base(tags, serializedAdditionalRawData) + internal PatchResourceTagsAndSku(IDictionary tags, IDictionary serializedAdditionalRawData, CognitiveServicesSku sku) : base(tags, serializedAdditionalRawData) { Sku = sku; } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssue.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssue.Serialization.cs new file mode 100644 index 0000000000000..e633c53ccca9e --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssue.Serialization.cs @@ -0,0 +1,193 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class ProvisioningIssue : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProvisioningIssue)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ProvisioningIssue 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(ProvisioningIssue)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProvisioningIssue(document.RootElement, options); + } + + internal static ProvisioningIssue DeserializeProvisioningIssue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ProvisioningIssueProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = ProvisioningIssueProperties.DeserializeProvisioningIssueProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProvisioningIssue(name, properties, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ProvisioningIssue)} does not support writing '{options.Format}' format."); + } + } + + ProvisioningIssue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeProvisioningIssue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProvisioningIssue)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssue.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssue.cs new file mode 100644 index 0000000000000..fd5cb98f8bd5d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssue.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.CognitiveServices.Models +{ + /// The ProvisioningIssue. + public partial class ProvisioningIssue + { + /// + /// 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 ProvisioningIssue() + { + } + + /// Initializes a new instance of . + /// Name of the NSP provisioning issue. + /// Properties of Provisioning Issue. + /// Keeps track of any properties unknown to the library. + internal ProvisioningIssue(string name, ProvisioningIssueProperties properties, IDictionary serializedAdditionalRawData) + { + Name = name; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of the NSP provisioning issue. + [WirePath("name")] + public string Name { get; set; } + /// Properties of Provisioning Issue. + [WirePath("properties")] + public ProvisioningIssueProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssueProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssueProperties.Serialization.cs new file mode 100644 index 0000000000000..e72384b2910ee --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssueProperties.Serialization.cs @@ -0,0 +1,351 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class ProvisioningIssueProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProvisioningIssueProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(IssueType)) + { + writer.WritePropertyName("issueType"u8); + writer.WriteStringValue(IssueType); + } + if (Optional.IsDefined(Severity)) + { + writer.WritePropertyName("severity"u8); + writer.WriteStringValue(Severity); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(SuggestedResourceIds)) + { + writer.WritePropertyName("suggestedResourceIds"u8); + writer.WriteStartArray(); + foreach (var item in SuggestedResourceIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(SuggestedAccessRules)) + { + writer.WritePropertyName("suggestedAccessRules"u8); + writer.WriteStartArray(); + foreach (var item in SuggestedAccessRules) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ProvisioningIssueProperties 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(ProvisioningIssueProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProvisioningIssueProperties(document.RootElement, options); + } + + internal static ProvisioningIssueProperties DeserializeProvisioningIssueProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string issueType = default; + string severity = default; + string description = default; + IList suggestedResourceIds = default; + IList suggestedAccessRules = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("issueType"u8)) + { + issueType = property.Value.GetString(); + continue; + } + if (property.NameEquals("severity"u8)) + { + severity = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("suggestedResourceIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + suggestedResourceIds = array; + continue; + } + if (property.NameEquals("suggestedAccessRules"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NetworkSecurityPerimeterAccessRule.DeserializeNetworkSecurityPerimeterAccessRule(item, options)); + } + suggestedAccessRules = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProvisioningIssueProperties( + issueType, + severity, + description, + suggestedResourceIds ?? new ChangeTrackingList(), + suggestedAccessRules ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IssueType), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" issueType: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(IssueType)) + { + builder.Append(" issueType: "); + if (IssueType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{IssueType}'''"); + } + else + { + builder.AppendLine($"'{IssueType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Severity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" severity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Severity)) + { + builder.Append(" severity: "); + if (Severity.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Severity}'''"); + } + else + { + builder.AppendLine($"'{Severity}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" description: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Description)) + { + builder.Append(" description: "); + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SuggestedResourceIds), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" suggestedResourceIds: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(SuggestedResourceIds)) + { + if (SuggestedResourceIds.Any()) + { + builder.Append(" suggestedResourceIds: "); + builder.AppendLine("["); + foreach (var item in SuggestedResourceIds) + { + if (item == null) + { + builder.Append("null"); + continue; + } + builder.AppendLine($" '{item.ToString()}'"); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SuggestedAccessRules), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" suggestedAccessRules: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(SuggestedAccessRules)) + { + if (SuggestedAccessRules.Any()) + { + builder.Append(" suggestedAccessRules: "); + builder.AppendLine("["); + foreach (var item in SuggestedAccessRules) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " suggestedAccessRules: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(ProvisioningIssueProperties)} does not support writing '{options.Format}' format."); + } + } + + ProvisioningIssueProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeProvisioningIssueProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProvisioningIssueProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssueProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssueProperties.cs new file mode 100644 index 0000000000000..c571c2eec7f86 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ProvisioningIssueProperties.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Properties of Provisioning Issue. + public partial class ProvisioningIssueProperties + { + /// + /// 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 ProvisioningIssueProperties() + { + SuggestedResourceIds = new ChangeTrackingList(); + SuggestedAccessRules = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Type of Issue. + /// Severity of the issue. + /// Description of the issue. + /// IDs of resources that can be associated to the same perimeter to remediate the issue. + /// Optional array, suggested access rules. + /// Keeps track of any properties unknown to the library. + internal ProvisioningIssueProperties(string issueType, string severity, string description, IList suggestedResourceIds, IList suggestedAccessRules, IDictionary serializedAdditionalRawData) + { + IssueType = issueType; + Severity = severity; + Description = description; + SuggestedResourceIds = suggestedResourceIds; + SuggestedAccessRules = suggestedAccessRules; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of Issue. + [WirePath("issueType")] + public string IssueType { get; set; } + /// Severity of the issue. + [WirePath("severity")] + public string Severity { get; set; } + /// Description of the issue. + [WirePath("description")] + public string Description { get; set; } + /// IDs of resources that can be associated to the same perimeter to remediate the issue. + [WirePath("suggestedResourceIds")] + public IList SuggestedResourceIds { get; } + /// Optional array, suggested access rules. + [WirePath("suggestedAccessRules")] + public IList SuggestedAccessRules { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListItemsResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListItemsResult.Serialization.cs new file mode 100644 index 0000000000000..da6140a783c11 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListItemsResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class RaiBlockListItemsResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlockListItemsResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlockListItemsResult 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(RaiBlockListItemsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlockListItemsResult(document.RootElement, options); + } + + internal static RaiBlockListItemsResult DeserializeRaiBlockListItemsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(RaiBlocklistItemData.DeserializeRaiBlocklistItemData(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlockListItemsResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiBlockListItemsResult)} does not support writing '{options.Format}' format."); + } + } + + RaiBlockListItemsResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlockListItemsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlockListItemsResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListItemsResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListItemsResult.cs new file mode 100644 index 0000000000000..e69ceb530a391 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListItemsResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of cognitive services RAI Blocklist Items. + internal partial class RaiBlockListItemsResult + { + /// + /// 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 RaiBlockListItemsResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of RaiBlocklistItems. + /// The list of RaiBlocklistItems. + /// Keeps track of any properties unknown to the library. + internal RaiBlockListItemsResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of RaiBlocklistItems. + public string NextLink { get; } + /// The list of RaiBlocklistItems. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListResult.Serialization.cs new file mode 100644 index 0000000000000..3eeba96a95cbc --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class RaiBlockListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlockListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlockListResult 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(RaiBlockListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlockListResult(document.RootElement, options); + } + + internal static RaiBlockListResult DeserializeRaiBlockListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(RaiBlocklistData.DeserializeRaiBlocklistData(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlockListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiBlockListResult)} does not support writing '{options.Format}' format."); + } + } + + RaiBlockListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlockListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlockListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListResult.cs new file mode 100644 index 0000000000000..50339400f62da --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlockListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of cognitive services RAI Blocklists. + internal partial class RaiBlockListResult + { + /// + /// 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 RaiBlockListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of RaiBlocklists. + /// The list of RaiBlocklist. + /// Keeps track of any properties unknown to the library. + internal RaiBlockListResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of RaiBlocklists. + public string NextLink { get; } + /// The list of RaiBlocklist. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistConfig.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistConfig.Serialization.cs new file mode 100644 index 0000000000000..489d5ce80e7c5 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistConfig.Serialization.cs @@ -0,0 +1,194 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class RaiBlocklistConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlocklistConfig)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(BlocklistName)) + { + writer.WritePropertyName("blocklistName"u8); + writer.WriteStringValue(BlocklistName); + } + if (Optional.IsDefined(Blocking)) + { + writer.WritePropertyName("blocking"u8); + writer.WriteBooleanValue(Blocking.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlocklistConfig 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(RaiBlocklistConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlocklistConfig(document.RootElement, options); + } + + internal static RaiBlocklistConfig DeserializeRaiBlocklistConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string blocklistName = default; + bool? blocking = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("blocklistName"u8)) + { + blocklistName = property.Value.GetString(); + continue; + } + if (property.NameEquals("blocking"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + blocking = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlocklistConfig(blocklistName, blocking, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BlocklistName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" blocklistName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(BlocklistName)) + { + builder.Append(" blocklistName: "); + if (BlocklistName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{BlocklistName}'''"); + } + else + { + builder.AppendLine($"'{BlocklistName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Blocking), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" blocking: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Blocking)) + { + builder.Append(" blocking: "); + var boolValue = Blocking.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiBlocklistConfig)} does not support writing '{options.Format}' format."); + } + } + + RaiBlocklistConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlocklistConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlocklistConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistConfig.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistConfig.cs new file mode 100644 index 0000000000000..3aa06b7c3095c --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistConfig.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.CognitiveServices.Models +{ + /// Azure OpenAI blocklist config. + public partial class RaiBlocklistConfig + { + /// + /// 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 protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RaiBlocklistConfig() + { + } + + /// Initializes a new instance of . + /// Name of ContentFilter. + /// If blocking would occur. + /// Keeps track of any properties unknown to the library. + internal RaiBlocklistConfig(string blocklistName, bool? blocking, IDictionary serializedAdditionalRawData) + { + BlocklistName = blocklistName; + Blocking = blocking; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of ContentFilter. + [WirePath("blocklistName")] + public string BlocklistName { get; set; } + /// If blocking would occur. + [WirePath("blocking")] + public bool? Blocking { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemBulkRequest.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemBulkRequest.Serialization.cs new file mode 100644 index 0000000000000..4742060078c2a --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemBulkRequest.Serialization.cs @@ -0,0 +1,137 @@ +// 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.CognitiveServices.Models +{ + public partial class RaiBlocklistItemBulkRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlocklistItemBulkRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlocklistItemBulkRequest 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(RaiBlocklistItemBulkRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlocklistItemBulkRequest(document.RootElement, options); + } + + internal static RaiBlocklistItemBulkRequest DeserializeRaiBlocklistItemBulkRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + RaiBlocklistItemProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = RaiBlocklistItemProperties.DeserializeRaiBlocklistItemProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlocklistItemBulkRequest(name, properties, 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(RaiBlocklistItemBulkRequest)} does not support writing '{options.Format}' format."); + } + } + + RaiBlocklistItemBulkRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlocklistItemBulkRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlocklistItemBulkRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemBulkRequest.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemBulkRequest.cs new file mode 100644 index 0000000000000..32f8b1d29c1e3 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemBulkRequest.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.CognitiveServices.Models +{ + /// The Cognitive Services RaiBlocklist Item request body. + public partial class RaiBlocklistItemBulkRequest + { + /// + /// 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 RaiBlocklistItemBulkRequest() + { + } + + /// Initializes a new instance of . + /// + /// Properties of Cognitive Services RaiBlocklist Item. + /// Keeps track of any properties unknown to the library. + internal RaiBlocklistItemBulkRequest(string name, RaiBlocklistItemProperties properties, IDictionary serializedAdditionalRawData) + { + Name = name; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the name. + [WirePath("name")] + public string Name { get; set; } + /// Properties of Cognitive Services RaiBlocklist Item. + [WirePath("properties")] + public RaiBlocklistItemProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemProperties.Serialization.cs new file mode 100644 index 0000000000000..aa1144e561984 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemProperties.Serialization.cs @@ -0,0 +1,194 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class RaiBlocklistItemProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlocklistItemProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Pattern)) + { + writer.WritePropertyName("pattern"u8); + writer.WriteStringValue(Pattern); + } + if (Optional.IsDefined(IsRegex)) + { + writer.WritePropertyName("isRegex"u8); + writer.WriteBooleanValue(IsRegex.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlocklistItemProperties 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(RaiBlocklistItemProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlocklistItemProperties(document.RootElement, options); + } + + internal static RaiBlocklistItemProperties DeserializeRaiBlocklistItemProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string pattern = default; + bool? isRegex = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("pattern"u8)) + { + pattern = property.Value.GetString(); + continue; + } + if (property.NameEquals("isRegex"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isRegex = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlocklistItemProperties(pattern, isRegex, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Pattern), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" pattern: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Pattern)) + { + builder.Append(" pattern: "); + if (Pattern.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Pattern}'''"); + } + else + { + builder.AppendLine($"'{Pattern}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsRegex), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" isRegex: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(IsRegex)) + { + builder.Append(" isRegex: "); + var boolValue = IsRegex.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiBlocklistItemProperties)} does not support writing '{options.Format}' format."); + } + } + + RaiBlocklistItemProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlocklistItemProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlocklistItemProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemProperties.cs new file mode 100644 index 0000000000000..a6b112600d505 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistItemProperties.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.CognitiveServices.Models +{ + /// RAI Custom Blocklist Item properties. + public partial class RaiBlocklistItemProperties + { + /// + /// 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 RaiBlocklistItemProperties() + { + } + + /// Initializes a new instance of . + /// Pattern to match against. + /// If the pattern is a regex pattern. + /// Keeps track of any properties unknown to the library. + internal RaiBlocklistItemProperties(string pattern, bool? isRegex, IDictionary serializedAdditionalRawData) + { + Pattern = pattern; + IsRegex = isRegex; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Pattern to match against. + [WirePath("pattern")] + public string Pattern { get; set; } + /// If the pattern is a regex pattern. + [WirePath("isRegex")] + public bool? IsRegex { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistProperties.Serialization.cs new file mode 100644 index 0000000000000..06694ad7d2435 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistProperties.Serialization.cs @@ -0,0 +1,163 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class RaiBlocklistProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlocklistProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlocklistProperties 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(RaiBlocklistProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlocklistProperties(document.RootElement, options); + } + + internal static RaiBlocklistProperties DeserializeRaiBlocklistProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlocklistProperties(description, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Description), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" description: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Description)) + { + builder.Append(" description: "); + if (Description.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Description}'''"); + } + else + { + builder.AppendLine($"'{Description}'"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiBlocklistProperties)} does not support writing '{options.Format}' format."); + } + } + + RaiBlocklistProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlocklistProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlocklistProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistProperties.cs new file mode 100644 index 0000000000000..8a6fab4435c6d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiBlocklistProperties.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// RAI Custom Blocklist properties. + internal partial class RaiBlocklistProperties + { + /// + /// 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 RaiBlocklistProperties() + { + } + + /// Initializes a new instance of . + /// Description of the block list. + /// Keeps track of any properties unknown to the library. + internal RaiBlocklistProperties(string description, IDictionary serializedAdditionalRawData) + { + Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Description of the block list. + [WirePath("description")] + public string Description { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterListResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterListResult.Serialization.cs new file mode 100644 index 0000000000000..56c867d28c0a1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterListResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class RaiContentFilterListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiContentFilterListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiContentFilterListResult 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(RaiContentFilterListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiContentFilterListResult(document.RootElement, options); + } + + internal static RaiContentFilterListResult DeserializeRaiContentFilterListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(RaiContentFilterData.DeserializeRaiContentFilterData(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiContentFilterListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiContentFilterListResult)} does not support writing '{options.Format}' format."); + } + } + + RaiContentFilterListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiContentFilterListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiContentFilterListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterListResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterListResult.cs new file mode 100644 index 0000000000000..bd1ceadc594fb --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of Content Filters. + internal partial class RaiContentFilterListResult + { + /// + /// 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 RaiContentFilterListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of Content Filters. + /// The list of RaiContentFilter. + /// Keeps track of any properties unknown to the library. + internal RaiContentFilterListResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of Content Filters. + public string NextLink { get; } + /// The list of RaiContentFilter. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterProperties.Serialization.cs new file mode 100644 index 0000000000000..7754348ec819f --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterProperties.Serialization.cs @@ -0,0 +1,224 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class RaiContentFilterProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiContentFilterProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(IsMultiLevelFilter)) + { + writer.WritePropertyName("isMultiLevelFilter"u8); + writer.WriteBooleanValue(IsMultiLevelFilter.Value); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiContentFilterProperties 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(RaiContentFilterProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiContentFilterProperties(document.RootElement, options); + } + + internal static RaiContentFilterProperties DeserializeRaiContentFilterProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + bool? isMultiLevelFilter = default; + RaiPolicyContentSource? source = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("isMultiLevelFilter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isMultiLevelFilter = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("source"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + source = new RaiPolicyContentSource(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiContentFilterProperties(name, isMultiLevelFilter, source, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IsMultiLevelFilter), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" isMultiLevelFilter: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(IsMultiLevelFilter)) + { + builder.Append(" isMultiLevelFilter: "); + var boolValue = IsMultiLevelFilter.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" source: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Source)) + { + builder.Append(" source: "); + builder.AppendLine($"'{Source.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiContentFilterProperties)} does not support writing '{options.Format}' format."); + } + } + + RaiContentFilterProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiContentFilterProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiContentFilterProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterProperties.cs new file mode 100644 index 0000000000000..91ac0ee712f07 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiContentFilterProperties.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Azure OpenAI Content Filter Properties. + public partial class RaiContentFilterProperties + { + /// + /// 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 RaiContentFilterProperties() + { + } + + /// Initializes a new instance of . + /// Name of Content Filter. + /// If the Content Filter has multi severity levels(Low, Medium, or High). + /// Content source to apply the Content Filters. + /// Keeps track of any properties unknown to the library. + internal RaiContentFilterProperties(string name, bool? isMultiLevelFilter, RaiPolicyContentSource? source, IDictionary serializedAdditionalRawData) + { + Name = name; + IsMultiLevelFilter = isMultiLevelFilter; + Source = source; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of Content Filter. + [WirePath("name")] + public string Name { get; set; } + /// If the Content Filter has multi severity levels(Low, Medium, or High). + [WirePath("isMultiLevelFilter")] + public bool? IsMultiLevelFilter { get; set; } + /// Content source to apply the Content Filters. + [WirePath("source")] + public RaiPolicyContentSource? Source { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiMonitorConfig.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiMonitorConfig.Serialization.cs new file mode 100644 index 0000000000000..3af564f7fd1ad --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiMonitorConfig.Serialization.cs @@ -0,0 +1,193 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class RaiMonitorConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiMonitorConfig)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(AdxStorageResourceId)) + { + writer.WritePropertyName("adxStorageResourceId"u8); + writer.WriteStringValue(AdxStorageResourceId); + } + if (Optional.IsDefined(IdentityClientId)) + { + writer.WritePropertyName("identityClientId"u8); + writer.WriteStringValue(IdentityClientId.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiMonitorConfig 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(RaiMonitorConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiMonitorConfig(document.RootElement, options); + } + + internal static RaiMonitorConfig DeserializeRaiMonitorConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string adxStorageResourceId = default; + Guid? identityClientId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("adxStorageResourceId"u8)) + { + adxStorageResourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("identityClientId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identityClientId = property.Value.GetGuid(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiMonitorConfig(adxStorageResourceId, identityClientId, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(AdxStorageResourceId), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" adxStorageResourceId: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(AdxStorageResourceId)) + { + builder.Append(" adxStorageResourceId: "); + if (AdxStorageResourceId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{AdxStorageResourceId}'''"); + } + else + { + builder.AppendLine($"'{AdxStorageResourceId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IdentityClientId), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" identityClientId: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(IdentityClientId)) + { + builder.Append(" identityClientId: "); + builder.AppendLine($"'{IdentityClientId.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiMonitorConfig)} does not support writing '{options.Format}' format."); + } + } + + RaiMonitorConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiMonitorConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiMonitorConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiMonitorConfig.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiMonitorConfig.cs new file mode 100644 index 0000000000000..273f2bbb34465 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiMonitorConfig.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.CognitiveServices.Models +{ + /// Cognitive Services Rai Monitor Config. + public partial class RaiMonitorConfig + { + /// + /// 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 RaiMonitorConfig() + { + } + + /// Initializes a new instance of . + /// The storage resource Id. + /// The identity client Id to access the storage. + /// Keeps track of any properties unknown to the library. + internal RaiMonitorConfig(string adxStorageResourceId, Guid? identityClientId, IDictionary serializedAdditionalRawData) + { + AdxStorageResourceId = adxStorageResourceId; + IdentityClientId = identityClientId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The storage resource Id. + [WirePath("adxStorageResourceId")] + public string AdxStorageResourceId { get; set; } + /// The identity client Id to access the storage. + [WirePath("identityClientId")] + public Guid? IdentityClientId { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentFilter.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentFilter.Serialization.cs new file mode 100644 index 0000000000000..9d97e1df8a99f --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentFilter.Serialization.cs @@ -0,0 +1,291 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class RaiPolicyContentFilter : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiPolicyContentFilter)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(SeverityThreshold)) + { + writer.WritePropertyName("severityThreshold"u8); + writer.WriteStringValue(SeverityThreshold.Value.ToString()); + } + if (Optional.IsDefined(Blocking)) + { + writer.WritePropertyName("blocking"u8); + writer.WriteBooleanValue(Blocking.Value); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiPolicyContentFilter 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(RaiPolicyContentFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiPolicyContentFilter(document.RootElement, options); + } + + internal static RaiPolicyContentFilter DeserializeRaiPolicyContentFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + bool? enabled = default; + ContentLevel? severityThreshold = default; + bool? blocking = default; + RaiPolicyContentSource? source = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("enabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("severityThreshold"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + severityThreshold = new ContentLevel(property.Value.GetString()); + continue; + } + if (property.NameEquals("blocking"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + blocking = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("source"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + source = new RaiPolicyContentSource(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiPolicyContentFilter( + name, + enabled, + severityThreshold, + blocking, + source, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Enabled), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" enabled: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Enabled)) + { + builder.Append(" enabled: "); + var boolValue = Enabled.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SeverityThreshold), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" severityThreshold: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SeverityThreshold)) + { + builder.Append(" severityThreshold: "); + builder.AppendLine($"'{SeverityThreshold.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Blocking), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" blocking: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Blocking)) + { + builder.Append(" blocking: "); + var boolValue = Blocking.Value == true ? "true" : "false"; + builder.AppendLine($"{boolValue}"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Source), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" source: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Source)) + { + builder.Append(" source: "); + builder.AppendLine($"'{Source.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiPolicyContentFilter)} does not support writing '{options.Format}' format."); + } + } + + RaiPolicyContentFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiPolicyContentFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiPolicyContentFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentFilter.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentFilter.cs new file mode 100644 index 0000000000000..5a91784da4828 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentFilter.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Azure OpenAI Content Filter. + public partial class RaiPolicyContentFilter + { + /// + /// 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 RaiPolicyContentFilter() + { + } + + /// Initializes a new instance of . + /// Name of ContentFilter. + /// If the ContentFilter is enabled. + /// Level at which content is filtered. + /// If blocking would occur. + /// Content source to apply the Content Filters. + /// Keeps track of any properties unknown to the library. + internal RaiPolicyContentFilter(string name, bool? enabled, ContentLevel? severityThreshold, bool? blocking, RaiPolicyContentSource? source, IDictionary serializedAdditionalRawData) + { + Name = name; + Enabled = enabled; + SeverityThreshold = severityThreshold; + Blocking = blocking; + Source = source; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of ContentFilter. + [WirePath("name")] + public string Name { get; set; } + /// If the ContentFilter is enabled. + [WirePath("enabled")] + public bool? Enabled { get; set; } + /// Level at which content is filtered. + [WirePath("severityThreshold")] + public ContentLevel? SeverityThreshold { get; set; } + /// If blocking would occur. + [WirePath("blocking")] + public bool? Blocking { get; set; } + /// Content source to apply the Content Filters. + [WirePath("source")] + public RaiPolicyContentSource? Source { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentSource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentSource.cs new file mode 100644 index 0000000000000..6cf98676f6772 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyContentSource.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Content source to apply the Content Filters. + public readonly partial struct RaiPolicyContentSource : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RaiPolicyContentSource(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PromptValue = "Prompt"; + private const string CompletionValue = "Completion"; + + /// Prompt. + public static RaiPolicyContentSource Prompt { get; } = new RaiPolicyContentSource(PromptValue); + /// Completion. + public static RaiPolicyContentSource Completion { get; } = new RaiPolicyContentSource(CompletionValue); + /// Determines if two values are the same. + public static bool operator ==(RaiPolicyContentSource left, RaiPolicyContentSource right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RaiPolicyContentSource left, RaiPolicyContentSource right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RaiPolicyContentSource(string value) => new RaiPolicyContentSource(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RaiPolicyContentSource other && Equals(other); + /// + public bool Equals(RaiPolicyContentSource other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyListResult.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyListResult.Serialization.cs new file mode 100644 index 0000000000000..78218cb485cc1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyListResult.Serialization.cs @@ -0,0 +1,212 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + internal partial class RaiPolicyListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiPolicyListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiPolicyListResult 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(RaiPolicyListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiPolicyListResult(document.RootElement, options); + } + + internal static RaiPolicyListResult DeserializeRaiPolicyListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string nextLink = default; + IReadOnlyList value = 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()) + { + array.Add(RaiPolicyData.DeserializeRaiPolicyData(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiPolicyListResult(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(NextLink), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" nextLink: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(NextLink)) + { + builder.Append(" nextLink: "); + if (NextLink.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{NextLink}'''"); + } + else + { + builder.AppendLine($"'{NextLink}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Value), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" value: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Value)) + { + if (Value.Any()) + { + builder.Append(" value: "); + builder.AppendLine("["); + foreach (var item in Value) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " value: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiPolicyListResult)} does not support writing '{options.Format}' format."); + } + } + + RaiPolicyListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiPolicyListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiPolicyListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyListResult.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyListResult.cs new file mode 100644 index 0000000000000..8f64a202e64b1 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// The list of cognitive services RaiPolicies. + internal partial class RaiPolicyListResult + { + /// + /// 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 RaiPolicyListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The link used to get the next page of RaiPolicy. + /// The list of RaiPolicy. + /// Keeps track of any properties unknown to the library. + internal RaiPolicyListResult(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + NextLink = nextLink; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The link used to get the next page of RaiPolicy. + public string NextLink { get; } + /// The list of RaiPolicy. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyMode.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyMode.cs new file mode 100644 index 0000000000000..cb4d9645fec84 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyMode.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, Asynchronous_filter =3. Please use 'Asynchronous_filter' after 2024-06-01-preview. It is the same as 'Deferred' in previous version. + public readonly partial struct RaiPolicyMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RaiPolicyMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DefaultValue = "Default"; + private const string DeferredValue = "Deferred"; + private const string BlockingValue = "Blocking"; + private const string AsynchronousFilterValue = "Asynchronous_filter"; + + /// Default. + public static RaiPolicyMode Default { get; } = new RaiPolicyMode(DefaultValue); + /// Deferred. + public static RaiPolicyMode Deferred { get; } = new RaiPolicyMode(DeferredValue); + /// Blocking. + public static RaiPolicyMode Blocking { get; } = new RaiPolicyMode(BlockingValue); + /// Asynchronous_filter. + public static RaiPolicyMode AsynchronousFilter { get; } = new RaiPolicyMode(AsynchronousFilterValue); + /// Determines if two values are the same. + public static bool operator ==(RaiPolicyMode left, RaiPolicyMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RaiPolicyMode left, RaiPolicyMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RaiPolicyMode(string value) => new RaiPolicyMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RaiPolicyMode other && Equals(other); + /// + public bool Equals(RaiPolicyMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyProperties.Serialization.cs new file mode 100644 index 0000000000000..38f95672552fb --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyProperties.Serialization.cs @@ -0,0 +1,326 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class RaiPolicyProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiPolicyProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(PolicyType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(PolicyType.Value.ToString()); + } + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (Optional.IsDefined(BasePolicyName)) + { + writer.WritePropertyName("basePolicyName"u8); + writer.WriteStringValue(BasePolicyName); + } + if (Optional.IsCollectionDefined(ContentFilters)) + { + writer.WritePropertyName("contentFilters"u8); + writer.WriteStartArray(); + foreach (var item in ContentFilters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(CustomBlocklists)) + { + writer.WritePropertyName("customBlocklists"u8); + writer.WriteStartArray(); + foreach (var item in CustomBlocklists) + { + writer.WriteObjectValue(item, options); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiPolicyProperties 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(RaiPolicyProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiPolicyProperties(document.RootElement, options); + } + + internal static RaiPolicyProperties DeserializeRaiPolicyProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RaiPolicyType? type = default; + RaiPolicyMode? mode = default; + string basePolicyName = default; + IList contentFilters = default; + IList customBlocklists = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new RaiPolicyType(property.Value.GetString()); + continue; + } + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new RaiPolicyMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("basePolicyName"u8)) + { + basePolicyName = property.Value.GetString(); + continue; + } + if (property.NameEquals("contentFilters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RaiPolicyContentFilter.DeserializeRaiPolicyContentFilter(item, options)); + } + contentFilters = array; + continue; + } + if (property.NameEquals("customBlocklists"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CustomBlocklistConfig.DeserializeCustomBlocklistConfig(item, options)); + } + customBlocklists = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiPolicyProperties( + type, + mode, + basePolicyName, + contentFilters ?? new ChangeTrackingList(), + customBlocklists ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(PolicyType), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" type: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(PolicyType)) + { + builder.Append(" type: "); + builder.AppendLine($"'{PolicyType.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Mode), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" mode: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Mode)) + { + builder.Append(" mode: "); + builder.AppendLine($"'{Mode.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(BasePolicyName), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" basePolicyName: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(BasePolicyName)) + { + builder.Append(" basePolicyName: "); + if (BasePolicyName.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{BasePolicyName}'''"); + } + else + { + builder.AppendLine($"'{BasePolicyName}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ContentFilters), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" contentFilters: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(ContentFilters)) + { + if (ContentFilters.Any()) + { + builder.Append(" contentFilters: "); + builder.AppendLine("["); + foreach (var item in ContentFilters) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " contentFilters: "); + } + builder.AppendLine(" ]"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(CustomBlocklists), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" customBlocklists: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(CustomBlocklists)) + { + if (CustomBlocklists.Any()) + { + builder.Append(" customBlocklists: "); + builder.AppendLine("["); + foreach (var item in CustomBlocklists) + { + BicepSerializationHelpers.AppendChildObject(builder, item, options, 4, true, " customBlocklists: "); + } + builder.AppendLine(" ]"); + } + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiPolicyProperties)} does not support writing '{options.Format}' format."); + } + } + + RaiPolicyProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiPolicyProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiPolicyProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyProperties.cs new file mode 100644 index 0000000000000..df1886e93e094 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyProperties.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Azure OpenAI Content Filters properties. + public partial class RaiPolicyProperties + { + /// + /// 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 RaiPolicyProperties() + { + ContentFilters = new ChangeTrackingList(); + CustomBlocklists = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Content Filters policy type. + /// Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, Asynchronous_filter =3. Please use 'Asynchronous_filter' after 2024-06-01-preview. It is the same as 'Deferred' in previous version. + /// Name of Rai policy. + /// The list of Content Filters. + /// The list of custom Blocklist. + /// Keeps track of any properties unknown to the library. + internal RaiPolicyProperties(RaiPolicyType? policyType, RaiPolicyMode? mode, string basePolicyName, IList contentFilters, IList customBlocklists, IDictionary serializedAdditionalRawData) + { + PolicyType = policyType; + Mode = mode; + BasePolicyName = basePolicyName; + ContentFilters = contentFilters; + CustomBlocklists = customBlocklists; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Content Filters policy type. + [WirePath("type")] + public RaiPolicyType? PolicyType { get; } + /// Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, Asynchronous_filter =3. Please use 'Asynchronous_filter' after 2024-06-01-preview. It is the same as 'Deferred' in previous version. + [WirePath("mode")] + public RaiPolicyMode? Mode { get; set; } + /// Name of Rai policy. + [WirePath("basePolicyName")] + public string BasePolicyName { get; set; } + /// The list of Content Filters. + [WirePath("contentFilters")] + public IList ContentFilters { get; } + /// The list of custom Blocklist. + [WirePath("customBlocklists")] + public IList CustomBlocklists { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyType.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyType.cs new file mode 100644 index 0000000000000..70a6f33d8ad11 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/RaiPolicyType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Content Filters policy type. + public readonly partial struct RaiPolicyType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RaiPolicyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserManagedValue = "UserManaged"; + private const string SystemManagedValue = "SystemManaged"; + + /// UserManaged. + public static RaiPolicyType UserManaged { get; } = new RaiPolicyType(UserManagedValue); + /// SystemManaged. + public static RaiPolicyType SystemManaged { get; } = new RaiPolicyType(SystemManagedValue); + /// Determines if two values are the same. + public static bool operator ==(RaiPolicyType left, RaiPolicyType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RaiPolicyType left, RaiPolicyType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RaiPolicyType(string value) => new RaiPolicyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RaiPolicyType other && Equals(other); + /// + public bool Equals(RaiPolicyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs index f1d51270bd689..311472300f7ba 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs @@ -43,7 +43,7 @@ public partial class ServiceAccountEncryptionProperties /// /// /// - private IDictionary _serializedAdditionalRawData; + private protected IDictionary _serializedAdditionalRawData; /// Initializes a new instance of . public ServiceAccountEncryptionProperties() diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/SkuResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/SkuResource.Serialization.cs new file mode 100644 index 0000000000000..40b773edb2348 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/SkuResource.Serialization.cs @@ -0,0 +1,223 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class SkuResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SkuResource)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + } + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + if (Optional.IsDefined(Capacity)) + { + writer.WritePropertyName("capacity"u8); + writer.WriteObjectValue(Capacity, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SkuResource 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(SkuResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSkuResource(document.RootElement, options); + } + + internal static SkuResource DeserializeSkuResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string resourceType = default; + CognitiveServicesSku sku = default; + CognitiveServicesCapacityConfig capacity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceType"u8)) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = CognitiveServicesSku.DeserializeCognitiveServicesSku(property.Value, options); + continue; + } + if (property.NameEquals("capacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacity = CognitiveServicesCapacityConfig.DeserializeCognitiveServicesCapacityConfig(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SkuResource(resourceType, sku, capacity, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceType), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" resourceType: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ResourceType)) + { + builder.Append(" resourceType: "); + if (ResourceType.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ResourceType}'''"); + } + else + { + builder.AppendLine($"'{ResourceType}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Sku), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" sku: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Sku)) + { + builder.Append(" sku: "); + BicepSerializationHelpers.AppendChildObject(builder, Sku, options, 2, false, " sku: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Capacity), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" capacity: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Capacity)) + { + builder.Append(" capacity: "); + BicepSerializationHelpers.AppendChildObject(builder, Capacity, options, 2, false, " capacity: "); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(SkuResource)} does not support writing '{options.Format}' format."); + } + } + + SkuResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSkuResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SkuResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/SkuResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/SkuResource.cs new file mode 100644 index 0000000000000..6c921c00b6088 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/SkuResource.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Properties of Cognitive Services account resource sku resource properties. + public partial class SkuResource + { + /// + /// 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 SkuResource() + { + } + + /// Initializes a new instance of . + /// The resource type name. + /// The resource model definition representing SKU. + /// The capacity configuration. + /// Keeps track of any properties unknown to the library. + internal SkuResource(string resourceType, CognitiveServicesSku sku, CognitiveServicesCapacityConfig capacity, IDictionary serializedAdditionalRawData) + { + ResourceType = resourceType; + Sku = sku; + Capacity = capacity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource type name. + [WirePath("resourceType")] + public string ResourceType { get; } + /// The resource model definition representing SKU. + [WirePath("sku")] + public CognitiveServicesSku Sku { get; } + /// The capacity configuration. + [WirePath("capacity")] + public CognitiveServicesCapacityConfig Capacity { get; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/UserOwnedAmlWorkspace.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/UserOwnedAmlWorkspace.Serialization.cs new file mode 100644 index 0000000000000..08fb6604e24cc --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/UserOwnedAmlWorkspace.Serialization.cs @@ -0,0 +1,193 @@ +// 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; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class UserOwnedAmlWorkspace : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserOwnedAmlWorkspace)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + if (Optional.IsDefined(IdentityClientId)) + { + writer.WritePropertyName("identityClientId"u8); + writer.WriteStringValue(IdentityClientId.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UserOwnedAmlWorkspace 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(UserOwnedAmlWorkspace)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserOwnedAmlWorkspace(document.RootElement, options); + } + + internal static UserOwnedAmlWorkspace DeserializeUserOwnedAmlWorkspace(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string resourceId = default; + Guid? identityClientId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("identityClientId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identityClientId = property.Value.GetGuid(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UserOwnedAmlWorkspace(resourceId, identityClientId, serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ResourceId), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" resourceId: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ResourceId)) + { + builder.Append(" resourceId: "); + if (ResourceId.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{ResourceId}'''"); + } + else + { + builder.AppendLine($"'{ResourceId}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(IdentityClientId), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" identityClientId: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(IdentityClientId)) + { + builder.Append(" identityClientId: "); + builder.AppendLine($"'{IdentityClientId.Value.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(UserOwnedAmlWorkspace)} does not support writing '{options.Format}' format."); + } + } + + UserOwnedAmlWorkspace IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUserOwnedAmlWorkspace(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserOwnedAmlWorkspace)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/UserOwnedAmlWorkspace.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/UserOwnedAmlWorkspace.cs new file mode 100644 index 0000000000000..6f557760b25ae --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/UserOwnedAmlWorkspace.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.CognitiveServices.Models +{ + /// The user owned AML workspace for Cognitive Services account. + public partial class UserOwnedAmlWorkspace + { + /// + /// 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 UserOwnedAmlWorkspace() + { + } + + /// Initializes a new instance of . + /// Full resource id of a AML workspace resource. + /// Identity Client id of a AML workspace resource. + /// Keeps track of any properties unknown to the library. + internal UserOwnedAmlWorkspace(string resourceId, Guid? identityClientId, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + IdentityClientId = identityClientId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Full resource id of a AML workspace resource. + [WirePath("resourceId")] + public string ResourceId { get; set; } + /// Identity Client id of a AML workspace resource. + [WirePath("identityClientId")] + public Guid? IdentityClientId { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationCollection.cs new file mode 100644 index 0000000000000..392a8baee867e --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationCollection.cs @@ -0,0 +1,395 @@ +// 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.CognitiveServices +{ + /// + /// 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 GetNetworkSecurityPerimeterConfigurations method from an instance of . + /// + public partial class NetworkSecurityPerimeterConfigurationCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _networkSecurityPerimeterConfigurationClientDiagnostics; + private readonly NetworkSecurityPerimeterConfigurationsRestOperations _networkSecurityPerimeterConfigurationRestClient; + + /// Initializes a new instance of the class for mocking. + protected NetworkSecurityPerimeterConfigurationCollection() + { + } + + /// 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 NetworkSecurityPerimeterConfigurationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _networkSecurityPerimeterConfigurationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", NetworkSecurityPerimeterConfigurationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NetworkSecurityPerimeterConfigurationResource.ResourceType, out string networkSecurityPerimeterConfigurationApiVersion); + _networkSecurityPerimeterConfigurationRestClient = new NetworkSecurityPerimeterConfigurationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, networkSecurityPerimeterConfigurationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CognitiveServicesAccountResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CognitiveServicesAccountResource.ResourceType), nameof(id)); + } + + /// + /// Gets the specified NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationCollection.Get"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterConfigurationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, nspConfigurationName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationCollection.Get"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, nspConfigurationName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets a list of NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _networkSecurityPerimeterConfigurationRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _networkSecurityPerimeterConfigurationRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NetworkSecurityPerimeterConfigurationResource(Client, NetworkSecurityPerimeterConfigurationData.DeserializeNetworkSecurityPerimeterConfigurationData(e)), _networkSecurityPerimeterConfigurationClientDiagnostics, Pipeline, "NetworkSecurityPerimeterConfigurationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets a list of NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _networkSecurityPerimeterConfigurationRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _networkSecurityPerimeterConfigurationRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NetworkSecurityPerimeterConfigurationResource(Client, NetworkSecurityPerimeterConfigurationData.DeserializeNetworkSecurityPerimeterConfigurationData(e)), _networkSecurityPerimeterConfigurationClientDiagnostics, Pipeline, "NetworkSecurityPerimeterConfigurationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationCollection.Exists"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterConfigurationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, nspConfigurationName, 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.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationCollection.Exists"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, nspConfigurationName, 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.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterConfigurationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, nspConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterConfigurationResource(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.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationCollection.GetIfExists"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, nspConfigurationName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterConfigurationResource(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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationData.Serialization.cs new file mode 100644 index 0000000000000..3f4cfdcdb5958 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationData.Serialization.cs @@ -0,0 +1,268 @@ +// 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; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + public partial class NetworkSecurityPerimeterConfigurationData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterConfigurationData 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(NetworkSecurityPerimeterConfigurationData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterConfigurationData(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterConfigurationData DeserializeNetworkSecurityPerimeterConfigurationData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NetworkSecurityPerimeterConfigurationProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = NetworkSecurityPerimeterConfigurationProperties.DeserializeNetworkSecurityPerimeterConfigurationProperties(property.Value, options); + 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterConfigurationData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationData)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterConfigurationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNetworkSecurityPerimeterConfigurationData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterConfigurationData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationData.cs new file mode 100644 index 0000000000000..f9bd30b4903ed --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationData.cs @@ -0,0 +1,76 @@ +// 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.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A class representing the NetworkSecurityPerimeterConfiguration data model. + /// NSP Configuration for an Cognitive Services account. + /// + public partial class NetworkSecurityPerimeterConfigurationData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public NetworkSecurityPerimeterConfigurationData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// NSP Configuration properties. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterConfigurationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, NetworkSecurityPerimeterConfigurationProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// NSP Configuration properties. + [WirePath("properties")] + public NetworkSecurityPerimeterConfigurationProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationResource.Serialization.cs new file mode 100644 index 0000000000000..023b5154ab3a8 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationResource.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.CognitiveServices +{ + public partial class NetworkSecurityPerimeterConfigurationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NetworkSecurityPerimeterConfigurationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NetworkSecurityPerimeterConfigurationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationResource.cs new file mode 100644 index 0000000000000..d6f6113c487e3 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/NetworkSecurityPerimeterConfigurationResource.cs @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A Class representing a NetworkSecurityPerimeterConfiguration 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 GetNetworkSecurityPerimeterConfigurationResource method. + /// Otherwise you can get one from its parent resource using the GetNetworkSecurityPerimeterConfiguration method. + /// + public partial class NetworkSecurityPerimeterConfigurationResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + /// The nspConfigurationName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _networkSecurityPerimeterConfigurationClientDiagnostics; + private readonly NetworkSecurityPerimeterConfigurationsRestOperations _networkSecurityPerimeterConfigurationRestClient; + private readonly NetworkSecurityPerimeterConfigurationData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CognitiveServices/accounts/networkSecurityPerimeterConfigurations"; + + /// Initializes a new instance of the class for mocking. + protected NetworkSecurityPerimeterConfigurationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NetworkSecurityPerimeterConfigurationResource(ArmClient client, NetworkSecurityPerimeterConfigurationData 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 NetworkSecurityPerimeterConfigurationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _networkSecurityPerimeterConfigurationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string networkSecurityPerimeterConfigurationApiVersion); + _networkSecurityPerimeterConfigurationRestClient = new NetworkSecurityPerimeterConfigurationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, networkSecurityPerimeterConfigurationApiVersion); +#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 NetworkSecurityPerimeterConfigurationData 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 specified NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationResource.Get"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterConfigurationRestClient.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 NetworkSecurityPerimeterConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP configurations for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationResource.Get"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Reconcile the NSP configuration for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName}/reconcile + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Reconcile + /// + /// + /// Default Api Version + /// 2024-06-01-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> ReconcileAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationResource.Reconcile"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterConfigurationRestClient.ReconcileAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new CognitiveServicesArmOperation(new NetworkSecurityPerimeterConfigurationOperationSource(Client), _networkSecurityPerimeterConfigurationClientDiagnostics, Pipeline, _networkSecurityPerimeterConfigurationRestClient.CreateReconcileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Reconcile the NSP configuration for an account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName}/reconcile + /// + /// + /// Operation Id + /// NetworkSecurityPerimeterConfigurations_Reconcile + /// + /// + /// Default Api Version + /// 2024-06-01-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 Reconcile(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterConfigurationClientDiagnostics.CreateScope("NetworkSecurityPerimeterConfigurationResource.Reconcile"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterConfigurationRestClient.Reconcile(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new CognitiveServicesArmOperation(new NetworkSecurityPerimeterConfigurationOperationSource(Client), _networkSecurityPerimeterConfigurationClientDiagnostics, Pipeline, _networkSecurityPerimeterConfigurationRestClient.CreateReconcileRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistCollection.cs new file mode 100644 index 0000000000000..e3784d990e9f5 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistCollection.cs @@ -0,0 +1,497 @@ +// 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.CognitiveServices +{ + /// + /// 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 GetRaiBlocklists method from an instance of . + /// + public partial class RaiBlocklistCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _raiBlocklistClientDiagnostics; + private readonly RaiBlocklistsRestOperations _raiBlocklistRestClient; + + /// Initializes a new instance of the class for mocking. + protected RaiBlocklistCollection() + { + } + + /// 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 RaiBlocklistCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _raiBlocklistClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", RaiBlocklistResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(RaiBlocklistResource.ResourceType, out string raiBlocklistApiVersion); + _raiBlocklistRestClient = new RaiBlocklistsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiBlocklistApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CognitiveServicesAccountResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CognitiveServicesAccountResource.ResourceType), nameof(id)); + } + + /// + /// Update the state of specified blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the RaiBlocklist associated with the Cognitive Services Account. + /// Properties describing the custom blocklist. + /// 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 raiBlocklistName, RaiBlocklistData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _raiBlocklistRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, data, cancellationToken).ConfigureAwait(false); + var uri = _raiBlocklistRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the RaiBlocklist associated with the Cognitive Services Account. + /// Properties describing the custom blocklist. + /// 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 raiBlocklistName, RaiBlocklistData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _raiBlocklistRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, data, cancellationToken); + var uri = _raiBlocklistRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.Get"); + scope.Start(); + try + { + var response = await _raiBlocklistRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.Get"); + scope.Start(); + try + { + var response = _raiBlocklistRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the custom blocklists associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists + /// + /// + /// Operation Id + /// RaiBlocklists_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiBlocklistRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiBlocklistRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new RaiBlocklistResource(Client, RaiBlocklistData.DeserializeRaiBlocklistData(e)), _raiBlocklistClientDiagnostics, Pipeline, "RaiBlocklistCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the custom blocklists associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists + /// + /// + /// Operation Id + /// RaiBlocklists_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiBlocklistRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiBlocklistRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new RaiBlocklistResource(Client, RaiBlocklistData.DeserializeRaiBlocklistData(e)), _raiBlocklistClientDiagnostics, Pipeline, "RaiBlocklistCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.Exists"); + scope.Start(); + try + { + var response = await _raiBlocklistRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.Exists"); + scope.Start(); + try + { + var response = _raiBlocklistRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _raiBlocklistRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistResource(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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistCollection.GetIfExists"); + scope.Start(); + try + { + var response = _raiBlocklistRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiBlocklistName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistResource(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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistData.Serialization.cs new file mode 100644 index 0000000000000..52bdec8b56b3b --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistData.Serialization.cs @@ -0,0 +1,367 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + public partial class RaiBlocklistData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlocklistData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + 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(); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlocklistData 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(RaiBlocklistData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlocklistData(document.RootElement, options); + } + + internal static RaiBlocklistData DeserializeRaiBlocklistData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ETag? etag = default; + IDictionary tags = default; + RaiBlocklistProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + 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) + { + continue; + } + properties = RaiBlocklistProperties.DeserializeRaiBlocklistProperties(property.Value, options); + 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlocklistData( + id, + name, + type, + systemData, + etag, + tags ?? new ChangeTrackingDictionary(), + properties, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" etag: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ETag)) + { + builder.Append(" etag: "); + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue("RaiBlocklistDescription", out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine("{"); + builder.Append(" description: "); + builder.AppendLine(propertyOverride); + builder.AppendLine(" }"); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiBlocklistData)} does not support writing '{options.Format}' format."); + } + } + + RaiBlocklistData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlocklistData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlocklistData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistData.cs new file mode 100644 index 0000000000000..e4da2f0a58936 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistData.cs @@ -0,0 +1,98 @@ +// 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.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A class representing the RaiBlocklist data model. + /// Cognitive Services RaiBlocklist. + /// + public partial class RaiBlocklistData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RaiBlocklistData() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services RaiBlocklist. + /// Keeps track of any properties unknown to the library. + internal RaiBlocklistData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, IDictionary tags, RaiBlocklistProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ETag = etag; + Tags = tags; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource Etag. + [WirePath("etag")] + public ETag? ETag { get; } + /// Resource tags. + [WirePath("tags")] + public IDictionary Tags { get; } + /// Properties of Cognitive Services RaiBlocklist. + internal RaiBlocklistProperties Properties { get; set; } + /// Description of the block list. + [WirePath("properties.description")] + public string RaiBlocklistDescription + { + get => Properties is null ? default : Properties.Description; + set + { + if (Properties is null) + Properties = new RaiBlocklistProperties(); + Properties.Description = value; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemCollection.cs new file mode 100644 index 0000000000000..f7c311e76b080 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemCollection.cs @@ -0,0 +1,497 @@ +// 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.CognitiveServices +{ + /// + /// 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 GetRaiBlocklistItems method from an instance of . + /// + public partial class RaiBlocklistItemCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _raiBlocklistItemClientDiagnostics; + private readonly RaiBlocklistItemsRestOperations _raiBlocklistItemRestClient; + + /// Initializes a new instance of the class for mocking. + protected RaiBlocklistItemCollection() + { + } + + /// 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 RaiBlocklistItemCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _raiBlocklistItemClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", RaiBlocklistItemResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(RaiBlocklistItemResource.ResourceType, out string raiBlocklistItemApiVersion); + _raiBlocklistItemRestClient = new RaiBlocklistItemsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiBlocklistItemApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != RaiBlocklistResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, RaiBlocklistResource.ResourceType), nameof(id)); + } + + /// + /// Update the state of specified blocklist item associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the RaiBlocklist Item associated with the custom blocklist. + /// Properties describing the custom blocklist. + /// 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 raiBlocklistItemName, RaiBlocklistItemData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, data, cancellationToken).ConfigureAwait(false); + var uri = _raiBlocklistItemRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistItemResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified blocklist item associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the RaiBlocklist Item associated with the custom blocklist. + /// Properties describing the custom blocklist. + /// 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 raiBlocklistItemName, RaiBlocklistItemData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, data, cancellationToken); + var uri = _raiBlocklistItemRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistItemResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified custom blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.Get"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistItemResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified custom blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.Get"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistItemResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the blocklist items associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems + /// + /// + /// Operation Id + /// RaiBlocklistItems_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiBlocklistItemRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiBlocklistItemRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new RaiBlocklistItemResource(Client, RaiBlocklistItemData.DeserializeRaiBlocklistItemData(e)), _raiBlocklistItemClientDiagnostics, Pipeline, "RaiBlocklistItemCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the blocklist items associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems + /// + /// + /// Operation Id + /// RaiBlocklistItems_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiBlocklistItemRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiBlocklistItemRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new RaiBlocklistItemResource(Client, RaiBlocklistItemData.DeserializeRaiBlocklistItemData(e)), _raiBlocklistItemClientDiagnostics, Pipeline, "RaiBlocklistItemCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.Exists"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.Exists"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistItemResource(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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemCollection.GetIfExists"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistItemResource(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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemData.Serialization.cs new file mode 100644 index 0000000000000..71c5c26c4a8ed --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemData.Serialization.cs @@ -0,0 +1,364 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + public partial class RaiBlocklistItemData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiBlocklistItemData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + 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(); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiBlocklistItemData 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(RaiBlocklistItemData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiBlocklistItemData(document.RootElement, options); + } + + internal static RaiBlocklistItemData DeserializeRaiBlocklistItemData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ETag? etag = default; + IDictionary tags = default; + RaiBlocklistItemProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + 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) + { + continue; + } + properties = RaiBlocklistItemProperties.DeserializeRaiBlocklistItemProperties(property.Value, options); + 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiBlocklistItemData( + id, + name, + type, + systemData, + etag, + tags ?? new ChangeTrackingDictionary(), + properties, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" etag: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ETag)) + { + builder.Append(" etag: "); + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiBlocklistItemData)} does not support writing '{options.Format}' format."); + } + } + + RaiBlocklistItemData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiBlocklistItemData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiBlocklistItemData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemData.cs new file mode 100644 index 0000000000000..07ac6f1562cb2 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemData.cs @@ -0,0 +1,87 @@ +// 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.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A class representing the RaiBlocklistItem data model. + /// Cognitive Services RaiBlocklist Item. + /// + public partial class RaiBlocklistItemData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RaiBlocklistItemData() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services RaiBlocklist Item. + /// Keeps track of any properties unknown to the library. + internal RaiBlocklistItemData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, IDictionary tags, RaiBlocklistItemProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ETag = etag; + Tags = tags; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource Etag. + [WirePath("etag")] + public ETag? ETag { get; } + /// Resource tags. + [WirePath("tags")] + public IDictionary Tags { get; } + /// Properties of Cognitive Services RaiBlocklist Item. + [WirePath("properties")] + public RaiBlocklistItemProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemResource.Serialization.cs new file mode 100644 index 0000000000000..20880f8ec4abb --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemResource.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.CognitiveServices +{ + public partial class RaiBlocklistItemResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + RaiBlocklistItemData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + RaiBlocklistItemData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemResource.cs new file mode 100644 index 0000000000000..75c720f99a303 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistItemResource.cs @@ -0,0 +1,689 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A Class representing a RaiBlocklistItem 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 GetRaiBlocklistItemResource method. + /// Otherwise you can get one from its parent resource using the GetRaiBlocklistItem method. + /// + public partial class RaiBlocklistItemResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + /// The raiBlocklistName. + /// The raiBlocklistItemName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, string raiBlocklistItemName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _raiBlocklistItemClientDiagnostics; + private readonly RaiBlocklistItemsRestOperations _raiBlocklistItemRestClient; + private readonly RaiBlocklistItemData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CognitiveServices/accounts/raiBlocklists/raiBlocklistItems"; + + /// Initializes a new instance of the class for mocking. + protected RaiBlocklistItemResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal RaiBlocklistItemResource(ArmClient client, RaiBlocklistItemData 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 RaiBlocklistItemResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _raiBlocklistItemClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string raiBlocklistItemApiVersion); + _raiBlocklistItemRestClient = new RaiBlocklistItemsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiBlocklistItemApiVersion); +#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 RaiBlocklistItemData 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 specified custom blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.Get"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistItemResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified custom blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.Get"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistItemResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.Delete"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new CognitiveServicesArmOperation(_raiBlocklistItemClientDiagnostics, Pipeline, _raiBlocklistItemRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.Delete"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new CognitiveServicesArmOperation(_raiBlocklistItemClientDiagnostics, Pipeline, _raiBlocklistItemRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified blocklist item associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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. + /// Properties describing the custom blocklist. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, RaiBlocklistItemData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.Update"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _raiBlocklistItemRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistItemResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified blocklist item associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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. + /// Properties describing the custom blocklist. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, RaiBlocklistItemData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.Update"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _raiBlocklistItemRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistItemResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.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 _raiBlocklistItemRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiBlocklistItemResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.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 = _raiBlocklistItemRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiBlocklistItemResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.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 _raiBlocklistItemRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiBlocklistItemResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.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 = _raiBlocklistItemRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiBlocklistItemResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.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 _raiBlocklistItemRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiBlocklistItemResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistItemResource.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 = _raiBlocklistItemRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiBlocklistItemResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistResource.Serialization.cs new file mode 100644 index 0000000000000..611eb8c88b48c --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistResource.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.CognitiveServices +{ + public partial class RaiBlocklistResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + RaiBlocklistData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + RaiBlocklistData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistResource.cs new file mode 100644 index 0000000000000..39df1d86f58ba --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiBlocklistResource.cs @@ -0,0 +1,931 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A Class representing a RaiBlocklist 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 GetRaiBlocklistResource method. + /// Otherwise you can get one from its parent resource using the GetRaiBlocklist method. + /// + public partial class RaiBlocklistResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + /// The raiBlocklistName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _raiBlocklistClientDiagnostics; + private readonly RaiBlocklistsRestOperations _raiBlocklistRestClient; + private readonly ClientDiagnostics _raiBlocklistItemClientDiagnostics; + private readonly RaiBlocklistItemsRestOperations _raiBlocklistItemRestClient; + private readonly RaiBlocklistData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CognitiveServices/accounts/raiBlocklists"; + + /// Initializes a new instance of the class for mocking. + protected RaiBlocklistResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal RaiBlocklistResource(ArmClient client, RaiBlocklistData 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 RaiBlocklistResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _raiBlocklistClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string raiBlocklistApiVersion); + _raiBlocklistRestClient = new RaiBlocklistsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiBlocklistApiVersion); + _raiBlocklistItemClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", RaiBlocklistItemResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(RaiBlocklistItemResource.ResourceType, out string raiBlocklistItemApiVersion); + _raiBlocklistItemRestClient = new RaiBlocklistItemsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiBlocklistItemApiVersion); +#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 RaiBlocklistData 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 a collection of RaiBlocklistItemResources in the RaiBlocklist. + /// An object representing collection of RaiBlocklistItemResources and their operations over a RaiBlocklistItemResource. + public virtual RaiBlocklistItemCollection GetRaiBlocklistItems() + { + return GetCachedClient(client => new RaiBlocklistItemCollection(client, Id)); + } + + /// + /// Gets the specified custom blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetRaiBlocklistItemAsync(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + return await GetRaiBlocklistItems().GetAsync(raiBlocklistItemName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified custom blocklist Item associated with the custom blocklist. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName} + /// + /// + /// Operation Id + /// RaiBlocklistItems_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetRaiBlocklistItem(string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + return GetRaiBlocklistItems().Get(raiBlocklistItemName, cancellationToken); + } + + /// + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.Get"); + scope.Start(); + try + { + var response = await _raiBlocklistRestClient.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 RaiBlocklistResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.Get"); + scope.Start(); + try + { + var response = _raiBlocklistRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiBlocklistResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.Delete"); + scope.Start(); + try + { + var response = await _raiBlocklistRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new CognitiveServicesArmOperation(_raiBlocklistClientDiagnostics, Pipeline, _raiBlocklistRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified custom blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.Delete"); + scope.Start(); + try + { + var response = _raiBlocklistRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new CognitiveServicesArmOperation(_raiBlocklistClientDiagnostics, Pipeline, _raiBlocklistRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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. + /// Properties describing the custom blocklist. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, RaiBlocklistData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.Update"); + scope.Start(); + try + { + var response = await _raiBlocklistRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _raiBlocklistRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified blocklist associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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. + /// Properties describing the custom blocklist. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, RaiBlocklistData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.Update"); + scope.Start(); + try + { + var response = _raiBlocklistRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _raiBlocklistRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiBlocklistResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Batch operation to add blocklist items. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/addRaiBlocklistItems + /// + /// + /// Operation Id + /// RaiBlocklistItems_BatchAdd + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Properties describing the custom blocklist items. + /// The cancellation token to use. + /// is null. + public virtual async Task> BatchAddRaiBlocklistItemAsync(IEnumerable content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistResource.BatchAddRaiBlocklistItem"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.BatchAddAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiBlocklistResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Batch operation to add blocklist items. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/addRaiBlocklistItems + /// + /// + /// Operation Id + /// RaiBlocklistItems_BatchAdd + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Properties describing the custom blocklist items. + /// The cancellation token to use. + /// is null. + public virtual Response BatchAddRaiBlocklistItem(IEnumerable content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistResource.BatchAddRaiBlocklistItem"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.BatchAdd(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); + return Response.FromValue(new RaiBlocklistResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Batch operation to delete blocklist items. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/deleteRaiBlocklistItems + /// + /// + /// Operation Id + /// RaiBlocklistItems_BatchDelete + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// List of RAI Blocklist Items Names. + /// The cancellation token to use. + /// is null. + public virtual async Task BatchDeleteRaiBlocklistItemAsync(BinaryData raiBlocklistItemsNames, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(raiBlocklistItemsNames, nameof(raiBlocklistItemsNames)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistResource.BatchDeleteRaiBlocklistItem"); + scope.Start(); + try + { + var response = await _raiBlocklistItemRestClient.BatchDeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemsNames, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Batch operation to delete blocklist items. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/deleteRaiBlocklistItems + /// + /// + /// Operation Id + /// RaiBlocklistItems_BatchDelete + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// List of RAI Blocklist Items Names. + /// The cancellation token to use. + /// is null. + public virtual Response BatchDeleteRaiBlocklistItem(BinaryData raiBlocklistItemsNames, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(raiBlocklistItemsNames, nameof(raiBlocklistItemsNames)); + + using var scope = _raiBlocklistItemClientDiagnostics.CreateScope("RaiBlocklistResource.BatchDeleteRaiBlocklistItem"); + scope.Start(); + try + { + var response = _raiBlocklistItemRestClient.BatchDelete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, raiBlocklistItemsNames, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.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 _raiBlocklistRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiBlocklistResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.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 = _raiBlocklistRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiBlocklistResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.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 _raiBlocklistRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiBlocklistResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.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 = _raiBlocklistRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiBlocklistResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.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 _raiBlocklistRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiBlocklistResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName} + /// + /// + /// Operation Id + /// RaiBlocklists_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiBlocklistClientDiagnostics.CreateScope("RaiBlocklistResource.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 = _raiBlocklistRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiBlocklistResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterCollection.cs new file mode 100644 index 0000000000000..ee16f8e3c054c --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterCollection.cs @@ -0,0 +1,399 @@ +// 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; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// 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 GetRaiContentFilters method from an instance of . + /// + public partial class RaiContentFilterCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _raiContentFilterClientDiagnostics; + private readonly RaiContentFiltersRestOperations _raiContentFilterRestClient; + private readonly AzureLocation _location; + + /// Initializes a new instance of the class for mocking. + protected RaiContentFilterCollection() + { + } + + /// 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. + /// Resource location. + internal RaiContentFilterCollection(ArmClient client, ResourceIdentifier id, AzureLocation location) : base(client, id) + { + _location = location; + _raiContentFilterClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", RaiContentFilterResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(RaiContentFilterResource.ResourceType, out string raiContentFilterApiVersion); + _raiContentFilterRestClient = new RaiContentFiltersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiContentFilterApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != SubscriptionResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, SubscriptionResource.ResourceType), nameof(id)); + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterCollection.Get"); + scope.Start(); + try + { + var response = await _raiContentFilterRestClient.GetAsync(Id.SubscriptionId, new AzureLocation(_location), filterName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiContentFilterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterCollection.Get"); + scope.Start(); + try + { + var response = _raiContentFilterRestClient.Get(Id.SubscriptionId, new AzureLocation(_location), filterName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiContentFilterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters + /// + /// + /// Operation Id + /// RaiContentFilters_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiContentFilterRestClient.CreateListRequest(Id.SubscriptionId, new AzureLocation(_location)); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiContentFilterRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, new AzureLocation(_location)); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new RaiContentFilterResource(Client, RaiContentFilterData.DeserializeRaiContentFilterData(e)), _raiContentFilterClientDiagnostics, Pipeline, "RaiContentFilterCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters + /// + /// + /// Operation Id + /// RaiContentFilters_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiContentFilterRestClient.CreateListRequest(Id.SubscriptionId, new AzureLocation(_location)); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiContentFilterRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, new AzureLocation(_location)); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new RaiContentFilterResource(Client, RaiContentFilterData.DeserializeRaiContentFilterData(e)), _raiContentFilterClientDiagnostics, Pipeline, "RaiContentFilterCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterCollection.Exists"); + scope.Start(); + try + { + var response = await _raiContentFilterRestClient.GetAsync(Id.SubscriptionId, new AzureLocation(_location), filterName, 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}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterCollection.Exists"); + scope.Start(); + try + { + var response = _raiContentFilterRestClient.Get(Id.SubscriptionId, new AzureLocation(_location), filterName, 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}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _raiContentFilterRestClient.GetAsync(Id.SubscriptionId, new AzureLocation(_location), filterName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiContentFilterResource(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}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RAI Content Filter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterCollection.GetIfExists"); + scope.Start(); + try + { + var response = _raiContentFilterRestClient.Get(Id.SubscriptionId, new AzureLocation(_location), filterName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiContentFilterResource(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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterData.Serialization.cs new file mode 100644 index 0000000000000..e94a5c3918cff --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterData.Serialization.cs @@ -0,0 +1,268 @@ +// 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; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + public partial class RaiContentFilterData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiContentFilterData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiContentFilterData 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(RaiContentFilterData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiContentFilterData(document.RootElement, options); + } + + internal static RaiContentFilterData DeserializeRaiContentFilterData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RaiContentFilterProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = RaiContentFilterProperties.DeserializeRaiContentFilterProperties(property.Value, options); + 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiContentFilterData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiContentFilterData)} does not support writing '{options.Format}' format."); + } + } + + RaiContentFilterData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiContentFilterData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiContentFilterData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterData.cs new file mode 100644 index 0000000000000..e6a5c1b04310a --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterData.cs @@ -0,0 +1,76 @@ +// 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.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A class representing the RaiContentFilter data model. + /// Azure OpenAI Content Filter. + /// + public partial class RaiContentFilterData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RaiContentFilterData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Azure OpenAI Content Filter Properties. + /// Keeps track of any properties unknown to the library. + internal RaiContentFilterData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, RaiContentFilterProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Azure OpenAI Content Filter Properties. + [WirePath("properties")] + public RaiContentFilterProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterResource.Serialization.cs new file mode 100644 index 0000000000000..b49ec54dc3f60 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterResource.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.CognitiveServices +{ + public partial class RaiContentFilterResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + RaiContentFilterData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + RaiContentFilterData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterResource.cs new file mode 100644 index 0000000000000..c1f9db5f8b7c7 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiContentFilterResource.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A Class representing a RaiContentFilter 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 GetRaiContentFilterResource method. + /// Otherwise you can get one from its parent resource using the GetRaiContentFilter method. + /// + public partial class RaiContentFilterResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The location. + /// The filterName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, AzureLocation location, string filterName) + { + var resourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _raiContentFilterClientDiagnostics; + private readonly RaiContentFiltersRestOperations _raiContentFilterRestClient; + private readonly RaiContentFilterData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CognitiveServices/locations/raiContentFilters"; + + /// Initializes a new instance of the class for mocking. + protected RaiContentFilterResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal RaiContentFilterResource(ArmClient client, RaiContentFilterData 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 RaiContentFilterResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _raiContentFilterClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string raiContentFilterApiVersion); + _raiContentFilterRestClient = new RaiContentFiltersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiContentFilterApiVersion); +#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 RaiContentFilterData 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)); + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterResource.Get"); + scope.Start(); + try + { + var response = await _raiContentFilterRestClient.GetAsync(Id.SubscriptionId, new AzureLocation(Id.Parent.Name), Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiContentFilterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get Content Filters types. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName} + /// + /// + /// Operation Id + /// RaiContentFilters_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _raiContentFilterClientDiagnostics.CreateScope("RaiContentFilterResource.Get"); + scope.Start(); + try + { + var response = _raiContentFilterRestClient.Get(Id.SubscriptionId, new AzureLocation(Id.Parent.Name), Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiContentFilterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyCollection.cs new file mode 100644 index 0000000000000..d1df3c0be066b --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyCollection.cs @@ -0,0 +1,497 @@ +// 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.CognitiveServices +{ + /// + /// 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 GetRaiPolicies method from an instance of . + /// + public partial class RaiPolicyCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _raiPolicyClientDiagnostics; + private readonly RaiPoliciesRestOperations _raiPolicyRestClient; + + /// Initializes a new instance of the class for mocking. + protected RaiPolicyCollection() + { + } + + /// 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 RaiPolicyCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _raiPolicyClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", RaiPolicyResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(RaiPolicyResource.ResourceType, out string raiPolicyApiVersion); + _raiPolicyRestClient = new RaiPoliciesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiPolicyApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CognitiveServicesAccountResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CognitiveServicesAccountResource.ResourceType), nameof(id)); + } + + /// + /// Update the state of specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the RaiPolicy associated with the Cognitive Services Account. + /// Properties describing the Content Filters. + /// 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 raiPolicyName, RaiPolicyData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _raiPolicyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, data, cancellationToken).ConfigureAwait(false); + var uri = _raiPolicyRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiPolicyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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 name of the RaiPolicy associated with the Cognitive Services Account. + /// Properties describing the Content Filters. + /// 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 raiPolicyName, RaiPolicyData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _raiPolicyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, data, cancellationToken); + var uri = _raiPolicyRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiPolicyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.Get"); + scope.Start(); + try + { + var response = await _raiPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiPolicyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.Get"); + scope.Start(); + try + { + var response = _raiPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiPolicyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the content filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies + /// + /// + /// Operation Id + /// RaiPolicies_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiPolicyRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiPolicyRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new RaiPolicyResource(Client, RaiPolicyData.DeserializeRaiPolicyData(e)), _raiPolicyClientDiagnostics, Pipeline, "RaiPolicyCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the content filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies + /// + /// + /// Operation Id + /// RaiPolicies_List + /// + /// + /// Default Api Version + /// 2024-06-01-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) => _raiPolicyRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _raiPolicyRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new RaiPolicyResource(Client, RaiPolicyData.DeserializeRaiPolicyData(e)), _raiPolicyClientDiagnostics, Pipeline, "RaiPolicyCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.Exists"); + scope.Start(); + try + { + var response = await _raiPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, 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.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.Exists"); + scope.Start(); + try + { + var response = _raiPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, 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.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _raiPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiPolicyResource(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.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyCollection.GetIfExists"); + scope.Start(); + try + { + var response = _raiPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, raiPolicyName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new RaiPolicyResource(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/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyData.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyData.Serialization.cs new file mode 100644 index 0000000000000..380c764c61183 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyData.Serialization.cs @@ -0,0 +1,364 @@ +// 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.Linq; +using System.Text; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + public partial class RaiPolicyData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiPolicyData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + 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(); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RaiPolicyData 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(RaiPolicyData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiPolicyData(document.RootElement, options); + } + + internal static RaiPolicyData DeserializeRaiPolicyData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ETag? etag = default; + IDictionary tags = default; + RaiPolicyProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + 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) + { + continue; + } + properties = RaiPolicyProperties.DeserializeRaiPolicyProperties(property.Value, options); + 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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RaiPolicyData( + id, + name, + type, + systemData, + etag, + tags ?? new ChangeTrackingDictionary(), + properties, + serializedAdditionalRawData); + } + + private BinaryData SerializeBicep(ModelReaderWriterOptions options) + { + StringBuilder builder = new StringBuilder(); + BicepModelReaderWriterOptions bicepOptions = options as BicepModelReaderWriterOptions; + IDictionary propertyOverrides = null; + bool hasObjectOverride = bicepOptions != null && bicepOptions.PropertyOverrides.TryGetValue(this, out propertyOverrides); + bool hasPropertyOverride = false; + string propertyOverride = null; + + builder.AppendLine("{"); + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Name), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" name: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Name)) + { + builder.Append(" name: "); + if (Name.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{Name}'''"); + } + else + { + builder.AppendLine($"'{Name}'"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Tags), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" tags: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsCollectionDefined(Tags)) + { + if (Tags.Any()) + { + builder.Append(" tags: "); + builder.AppendLine("{"); + foreach (var item in Tags) + { + builder.Append($" '{item.Key}': "); + if (item.Value == null) + { + builder.Append("null"); + continue; + } + if (item.Value.Contains(Environment.NewLine)) + { + builder.AppendLine("'''"); + builder.AppendLine($"{item.Value}'''"); + } + else + { + builder.AppendLine($"'{item.Value}'"); + } + } + builder.AppendLine(" }"); + } + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(ETag), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" etag: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(ETag)) + { + builder.Append(" etag: "); + builder.AppendLine($"'{ETag.Value.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Properties), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" properties: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Properties)) + { + builder.Append(" properties: "); + BicepSerializationHelpers.AppendChildObject(builder, Properties, options, 2, false, " properties: "); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(Id), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" id: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(Id)) + { + builder.Append(" id: "); + builder.AppendLine($"'{Id.ToString()}'"); + } + } + + hasPropertyOverride = hasObjectOverride && propertyOverrides.TryGetValue(nameof(SystemData), out propertyOverride); + if (hasPropertyOverride) + { + builder.Append(" systemData: "); + builder.AppendLine(propertyOverride); + } + else + { + if (Optional.IsDefined(SystemData)) + { + builder.Append(" systemData: "); + builder.AppendLine($"'{SystemData.ToString()}'"); + } + } + + builder.AppendLine("}"); + return BinaryData.FromString(builder.ToString()); + } + + 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); + case "bicep": + return SerializeBicep(options); + default: + throw new FormatException($"The model {nameof(RaiPolicyData)} does not support writing '{options.Format}' format."); + } + } + + RaiPolicyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRaiPolicyData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiPolicyData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyData.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyData.cs new file mode 100644 index 0000000000000..a8c48d9f079be --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyData.cs @@ -0,0 +1,87 @@ +// 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.CognitiveServices.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A class representing the RaiPolicy data model. + /// Cognitive Services RaiPolicy. + /// + public partial class RaiPolicyData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RaiPolicyData() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Resource Etag. + /// Resource tags. + /// Properties of Cognitive Services RaiPolicy. + /// Keeps track of any properties unknown to the library. + internal RaiPolicyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ETag? etag, IDictionary tags, RaiPolicyProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ETag = etag; + Tags = tags; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource Etag. + [WirePath("etag")] + public ETag? ETag { get; } + /// Resource tags. + [WirePath("tags")] + public IDictionary Tags { get; } + /// Properties of Cognitive Services RaiPolicy. + [WirePath("properties")] + public RaiPolicyProperties Properties { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyResource.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyResource.Serialization.cs new file mode 100644 index 0000000000000..fa4d81a4cc3f6 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyResource.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.CognitiveServices +{ + public partial class RaiPolicyResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + RaiPolicyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + RaiPolicyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyResource.cs new file mode 100644 index 0000000000000..ba3ecac1798fa --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RaiPolicyResource.cs @@ -0,0 +1,688 @@ +// 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; + +namespace Azure.ResourceManager.CognitiveServices +{ + /// + /// A Class representing a RaiPolicy 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 GetRaiPolicyResource method. + /// Otherwise you can get one from its parent resource using the GetRaiPolicy method. + /// + public partial class RaiPolicyResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The accountName. + /// The raiPolicyName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string accountName, string raiPolicyName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _raiPolicyClientDiagnostics; + private readonly RaiPoliciesRestOperations _raiPolicyRestClient; + private readonly RaiPolicyData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.CognitiveServices/accounts/raiPolicies"; + + /// Initializes a new instance of the class for mocking. + protected RaiPolicyResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal RaiPolicyResource(ArmClient client, RaiPolicyData 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 RaiPolicyResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _raiPolicyClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.CognitiveServices", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string raiPolicyApiVersion); + _raiPolicyRestClient = new RaiPoliciesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, raiPolicyApiVersion); +#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 RaiPolicyData 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 specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.Get"); + scope.Start(); + try + { + var response = await _raiPolicyRestClient.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 RaiPolicyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.Get"); + scope.Start(); + try + { + var response = _raiPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new RaiPolicyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.Delete"); + scope.Start(); + try + { + var response = await _raiPolicyRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new CognitiveServicesArmOperation(_raiPolicyClientDiagnostics, Pipeline, _raiPolicyRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Delete + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.Delete"); + scope.Start(); + try + { + var response = _raiPolicyRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new CognitiveServicesArmOperation(_raiPolicyClientDiagnostics, Pipeline, _raiPolicyRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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. + /// Properties describing the Content Filters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, RaiPolicyData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.Update"); + scope.Start(); + try + { + var response = await _raiPolicyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _raiPolicyRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiPolicyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update the state of specified Content Filters associated with the Azure OpenAI account. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-06-01-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. + /// Properties describing the Content Filters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, RaiPolicyData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.Update"); + scope.Start(); + try + { + var response = _raiPolicyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _raiPolicyRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new CognitiveServicesArmOperation(Response.FromValue(new RaiPolicyResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.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 _raiPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.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 = _raiPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.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 _raiPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + 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.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.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 = _raiPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.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 _raiPolicyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new RaiPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName} + /// + /// + /// Operation Id + /// RaiPolicies_Get + /// + /// + /// Default Api Version + /// 2024-06-01-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 = _raiPolicyClientDiagnostics.CreateScope("RaiPolicyResource.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 = _raiPolicyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new RaiPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/AccountsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/AccountsRestOperations.cs index 5ac809f181e15..f9daf6cfb2d07 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/AccountsRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/AccountsRestOperations.cs @@ -32,7 +32,7 @@ public AccountsRestOperations(HttpPipeline pipeline, string applicationId, Uri e { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CognitiveServicesManagementRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CognitiveServicesManagementRestOperations.cs index fd0704d753e18..0216f9a2c5a8f 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CognitiveServicesManagementRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CognitiveServicesManagementRestOperations.cs @@ -32,7 +32,7 @@ public CognitiveServicesManagementRestOperations(HttpPipeline pipeline, string a { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } @@ -213,5 +213,91 @@ public Response CheckDomainAvailability throw new RequestFailedException(message.Response); } } + + internal RequestUriBuilder CreateCalculateModelCapacityRequestUri(string subscriptionId, CalculateModelCapacityParameter calculateModelCapacityParameter) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/calculateModelCapacity", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCalculateModelCapacityRequest(string subscriptionId, CalculateModelCapacityParameter calculateModelCapacityParameter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/calculateModelCapacity", 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(calculateModelCapacityParameter, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Model capacity calculator. + /// The ID of the target subscription. + /// Check Domain Availability parameter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> CalculateModelCapacityAsync(string subscriptionId, CalculateModelCapacityParameter calculateModelCapacityParameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(calculateModelCapacityParameter, nameof(calculateModelCapacityParameter)); + + using var message = CreateCalculateModelCapacityRequest(subscriptionId, calculateModelCapacityParameter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CalculateModelCapacityResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CalculateModelCapacityResult.DeserializeCalculateModelCapacityResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Model capacity calculator. + /// The ID of the target subscription. + /// Check Domain Availability parameter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response CalculateModelCapacity(string subscriptionId, CalculateModelCapacityParameter calculateModelCapacityParameter, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(calculateModelCapacityParameter, nameof(calculateModelCapacityParameter)); + + using var message = CreateCalculateModelCapacityRequest(subscriptionId, calculateModelCapacityParameter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CalculateModelCapacityResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CalculateModelCapacityResult.DeserializeCalculateModelCapacityResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentPlansRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentPlansRestOperations.cs index 04f396355561d..e6ad7a9ecf7f5 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentPlansRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentPlansRestOperations.cs @@ -32,7 +32,7 @@ public CommitmentPlansRestOperations(HttpPipeline pipeline, string applicationId { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } @@ -530,7 +530,7 @@ public Response CreateOrUpdatePlan(string subscriptionId, string resourceGroupNa } } - internal RequestUriBuilder CreateUpdatePlanRequestUri(string subscriptionId, string resourceGroupName, string commitmentPlanName, CognitiveServicesCommitmentPlanPatch patch) + internal RequestUriBuilder CreateUpdatePlanRequestUri(string subscriptionId, string resourceGroupName, string commitmentPlanName, PatchResourceTagsAndSku commitmentPlan) { var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); @@ -544,7 +544,7 @@ internal RequestUriBuilder CreateUpdatePlanRequestUri(string subscriptionId, str return uri; } - internal HttpMessage CreateUpdatePlanRequest(string subscriptionId, string resourceGroupName, string commitmentPlanName, CognitiveServicesCommitmentPlanPatch patch) + internal HttpMessage CreateUpdatePlanRequest(string subscriptionId, string resourceGroupName, string commitmentPlanName, PatchResourceTagsAndSku commitmentPlan) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -562,7 +562,7 @@ internal HttpMessage CreateUpdatePlanRequest(string subscriptionId, string resou request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(commitmentPlan, ModelSerializationExtensions.WireOptions); request.Content = content; _userAgent.Apply(message); return message; @@ -572,18 +572,18 @@ internal HttpMessage CreateUpdatePlanRequest(string subscriptionId, string resou /// The ID of the target subscription. /// The name of the resource group. The name is case insensitive. /// The name of the commitmentPlan associated with the Cognitive Services Account. - /// The parameters to provide for the created commitment plan. + /// The parameters to provide for the created commitment plan. /// 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 UpdatePlanAsync(string subscriptionId, string resourceGroupName, string commitmentPlanName, CognitiveServicesCommitmentPlanPatch patch, CancellationToken cancellationToken = default) + public async Task UpdatePlanAsync(string subscriptionId, string resourceGroupName, string commitmentPlanName, PatchResourceTagsAndSku commitmentPlan, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(commitmentPlanName, nameof(commitmentPlanName)); - Argument.AssertNotNull(patch, nameof(patch)); + Argument.AssertNotNull(commitmentPlan, nameof(commitmentPlan)); - using var message = CreateUpdatePlanRequest(subscriptionId, resourceGroupName, commitmentPlanName, patch); + using var message = CreateUpdatePlanRequest(subscriptionId, resourceGroupName, commitmentPlanName, commitmentPlan); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -599,18 +599,18 @@ public async Task UpdatePlanAsync(string subscriptionId, string resour /// The ID of the target subscription. /// The name of the resource group. The name is case insensitive. /// The name of the commitmentPlan associated with the Cognitive Services Account. - /// The parameters to provide for the created commitment plan. + /// The parameters to provide for the created commitment plan. /// 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 UpdatePlan(string subscriptionId, string resourceGroupName, string commitmentPlanName, CognitiveServicesCommitmentPlanPatch patch, CancellationToken cancellationToken = default) + public Response UpdatePlan(string subscriptionId, string resourceGroupName, string commitmentPlanName, PatchResourceTagsAndSku commitmentPlan, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(commitmentPlanName, nameof(commitmentPlanName)); - Argument.AssertNotNull(patch, nameof(patch)); + Argument.AssertNotNull(commitmentPlan, nameof(commitmentPlan)); - using var message = CreateUpdatePlanRequest(subscriptionId, resourceGroupName, commitmentPlanName, patch); + using var message = CreateUpdatePlanRequest(subscriptionId, resourceGroupName, commitmentPlanName, commitmentPlan); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentTiersRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentTiersRestOperations.cs index 4c2f96e453750..b8f355cf90bab 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentTiersRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/CommitmentTiersRestOperations.cs @@ -32,7 +32,7 @@ public CommitmentTiersRestOperations(HttpPipeline pipeline, string applicationId { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DefenderForAISettingsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DefenderForAISettingsRestOperations.cs new file mode 100644 index 0000000000000..930aa4d97a942 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DefenderForAISettingsRestOperations.cs @@ -0,0 +1,539 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class DefenderForAISettingsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DefenderForAISettingsRestOperations. + /// 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 DefenderForAISettingsRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the Defender for AI settings. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DefenderForAISettingResult.DeserializeDefenderForAISettingResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the Defender for AI settings. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DefenderForAISettingResult.DeserializeDefenderForAISettingResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string accountName, string defenderForAISettingName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings/", false); + uri.AppendPath(defenderForAISettingName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName, string defenderForAISettingName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings/", false); + uri.AppendPath(defenderForAISettingName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified Defender for AI setting by name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the defender for AI setting. + /// 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 accountName, string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, defenderForAISettingName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DefenderForAISettingData.DeserializeDefenderForAISettingData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DefenderForAISettingData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified Defender for AI setting by name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the defender for AI setting. + /// 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 accountName, string defenderForAISettingName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, defenderForAISettingName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DefenderForAISettingData.DeserializeDefenderForAISettingData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DefenderForAISettingData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string accountName, string defenderForAISettingName, DefenderForAISettingData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings/", false); + uri.AppendPath(defenderForAISettingName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, string defenderForAISettingName, DefenderForAISettingData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings/", false); + uri.AppendPath(defenderForAISettingName, 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 the specified Defender for AI setting. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the defender for AI setting. + /// Properties describing the Defender for AI setting. + /// 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 accountName, string defenderForAISettingName, DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, defenderForAISettingName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + DefenderForAISettingData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DefenderForAISettingData.DeserializeDefenderForAISettingData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or Updates the specified Defender for AI setting. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the defender for AI setting. + /// Properties describing the Defender for AI setting. + /// 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 accountName, string defenderForAISettingName, DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, defenderForAISettingName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + DefenderForAISettingData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DefenderForAISettingData.DeserializeDefenderForAISettingData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string accountName, string defenderForAISettingName, DefenderForAISettingData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings/", false); + uri.AppendPath(defenderForAISettingName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, string defenderForAISettingName, DefenderForAISettingData data) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/defenderForAISettings/", false); + uri.AppendPath(defenderForAISettingName, 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; + } + + /// Updates the specified Defender for AI setting. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the defender for AI setting. + /// Properties describing the Defender for AI setting. + /// 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 accountName, string defenderForAISettingName, DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, accountName, defenderForAISettingName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DefenderForAISettingData.DeserializeDefenderForAISettingData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Updates the specified Defender for AI setting. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the defender for AI setting. + /// Properties describing the Defender for AI setting. + /// 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 accountName, string defenderForAISettingName, DefenderForAISettingData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(defenderForAISettingName, nameof(defenderForAISettingName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, accountName, defenderForAISettingName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DefenderForAISettingData.DeserializeDefenderForAISettingData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + 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; + } + + /// Lists the Defender for AI settings. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DefenderForAISettingResult.DeserializeDefenderForAISettingResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the Defender for AI settings. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DefenderForAISettingResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DefenderForAISettingResult.DeserializeDefenderForAISettingResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeletedAccountsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeletedAccountsRestOperations.cs index edd732fd85825..3546305e32fee 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeletedAccountsRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeletedAccountsRestOperations.cs @@ -32,7 +32,7 @@ public DeletedAccountsRestOperations(HttpPipeline pipeline, string applicationId { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeploymentsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeploymentsRestOperations.cs index 0ca0846b627dd..7c8b299026f2b 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeploymentsRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/DeploymentsRestOperations.cs @@ -32,7 +32,7 @@ public DeploymentsRestOperations(HttpPipeline pipeline, string applicationId, Ur { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } @@ -334,6 +334,106 @@ public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, } } + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string accountName, string deploymentName, PatchResourceTagsAndSku deployment) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, string deploymentName, PatchResourceTagsAndSku deployment) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentName, 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(deployment, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update specified deployments associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the deployment associated with the Cognitive Services Account. + /// The deployment properties. + /// 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 accountName, string deploymentName, PatchResourceTagsAndSku deployment, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(deployment, nameof(deployment)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, accountName, deploymentName, deployment); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update specified deployments associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the deployment associated with the Cognitive Services Account. + /// The deployment properties. + /// 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 accountName, string deploymentName, PatchResourceTagsAndSku deployment, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(deployment, nameof(deployment)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, accountName, deploymentName, deployment); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string accountName, string deploymentName) { var uri = new RawRequestUriBuilder(); @@ -428,6 +528,108 @@ public Response Delete(string subscriptionId, string resourceGroupName, string a } } + internal RequestUriBuilder CreateListSkusRequestUri(string subscriptionId, string resourceGroupName, string accountName, string deploymentName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentName, true); + uri.AppendPath("/skus", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListSkusRequest(string subscriptionId, string resourceGroupName, string accountName, string deploymentName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentName, true); + uri.AppendPath("/skus", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the specified deployments skus associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the deployment associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListSkusAsync(string subscriptionId, string resourceGroupName, string accountName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateListSkusRequest(subscriptionId, resourceGroupName, accountName, deploymentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentSkuListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentSkuListResult.DeserializeDeploymentSkuListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the specified deployments skus associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the deployment associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListSkus(string subscriptionId, string resourceGroupName, string accountName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateListSkusRequest(subscriptionId, resourceGroupName, accountName, deploymentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentSkuListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentSkuListResult.DeserializeDeploymentSkuListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName) { var uri = new RawRequestUriBuilder(); @@ -511,5 +713,93 @@ public Response ListNextPage(strin throw new RequestFailedException(message.Response); } } + + internal RequestUriBuilder CreateListSkusNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string deploymentName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListSkusNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string deploymentName) + { + 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; + } + + /// Lists the specified deployments skus associated with the Cognitive Services account. + /// 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. + /// The name of Cognitive Services account. + /// The name of the deployment associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListSkusNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateListSkusNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName, deploymentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentSkuListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentSkuListResult.DeserializeDeploymentSkuListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the specified deployments skus associated with the Cognitive Services account. + /// 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. + /// The name of Cognitive Services account. + /// The name of the deployment associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListSkusNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateListSkusNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName, deploymentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentSkuListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentSkuListResult.DeserializeDeploymentSkuListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/EncryptionScopesRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/EncryptionScopesRestOperations.cs new file mode 100644 index 0000000000000..a09404a696d45 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/EncryptionScopesRestOperations.cs @@ -0,0 +1,523 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class EncryptionScopesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of EncryptionScopesRestOperations. + /// 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 EncryptionScopesRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the content filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EncryptionScopeListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EncryptionScopeListResult.DeserializeEncryptionScopeListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the content filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EncryptionScopeListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EncryptionScopeListResult.DeserializeEncryptionScopeListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string accountName, string encryptionScopeName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes/", false); + uri.AppendPath(encryptionScopeName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName, string encryptionScopeName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes/", false); + uri.AppendPath(encryptionScopeName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified EncryptionScope associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// 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 accountName, string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, encryptionScopeName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EncryptionScopeData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EncryptionScopeData.DeserializeEncryptionScopeData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EncryptionScopeData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified EncryptionScope associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// 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 accountName, string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, encryptionScopeName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EncryptionScopeData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EncryptionScopeData.DeserializeEncryptionScopeData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((EncryptionScopeData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string accountName, string encryptionScopeName, EncryptionScopeData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes/", false); + uri.AppendPath(encryptionScopeName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, string encryptionScopeName, EncryptionScopeData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes/", false); + uri.AppendPath(encryptionScopeName, 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; + } + + /// Update the state of specified encryptionScope associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The encryptionScope properties. + /// 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 accountName, string encryptionScopeName, EncryptionScopeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, encryptionScopeName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + EncryptionScopeData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EncryptionScopeData.DeserializeEncryptionScopeData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update the state of specified encryptionScope associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// The encryptionScope properties. + /// 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 accountName, string encryptionScopeName, EncryptionScopeData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, encryptionScopeName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + EncryptionScopeData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EncryptionScopeData.DeserializeEncryptionScopeData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string accountName, string encryptionScopeName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes/", false); + uri.AppendPath(encryptionScopeName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string accountName, string encryptionScopeName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/encryptionScopes/", false); + uri.AppendPath(encryptionScopeName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the specified encryptionScope associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// 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 accountName, string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, encryptionScopeName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the specified encryptionScope associated with the Cognitive Services account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the encryptionScope associated with the Cognitive Services Account. + /// 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 accountName, string encryptionScopeName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(encryptionScopeName, nameof(encryptionScopeName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, encryptionScopeName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + 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 the content filters associated with the Azure OpenAI account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + EncryptionScopeListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = EncryptionScopeListResult.DeserializeEncryptionScopeListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the content filters associated with the Azure OpenAI account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + EncryptionScopeListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = EncryptionScopeListResult.DeserializeEncryptionScopeListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/LocationBasedModelCapacitiesRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/LocationBasedModelCapacitiesRestOperations.cs new file mode 100644 index 0000000000000..10ac151a83ec9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/LocationBasedModelCapacitiesRestOperations.cs @@ -0,0 +1,231 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class LocationBasedModelCapacitiesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of LocationBasedModelCapacitiesRestOperations. + /// 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 LocationBasedModelCapacitiesRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/modelCapacities", false); + uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendQuery("modelFormat", modelFormat, true); + uri.AppendQuery("modelName", modelName, true); + uri.AppendQuery("modelVersion", modelVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion) + { + 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("/providers/Microsoft.CognitiveServices/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/modelCapacities", false); + uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendQuery("modelFormat", modelFormat, true); + uri.AppendQuery("modelName", modelName, true); + uri.AppendQuery("modelVersion", modelVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Location Based ModelCapacities. + /// The ID of the target subscription. + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListRequest(subscriptionId, location, modelFormat, modelName, modelVersion); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Location Based ModelCapacities. + /// The ID of the target subscription. + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListRequest(subscriptionId, location, modelFormat, modelName, modelVersion); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion) + { + 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; + } + + /// List Location Based ModelCapacities. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, location, modelFormat, modelName, modelVersion); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Location Based ModelCapacities. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// Resource location. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , , or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, AzureLocation location, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, location, modelFormat, modelName, modelVersion); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ModelCapacitiesRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ModelCapacitiesRestOperations.cs new file mode 100644 index 0000000000000..25420d4dea3bb --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ModelCapacitiesRestOperations.cs @@ -0,0 +1,223 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class ModelCapacitiesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ModelCapacitiesRestOperations. + /// 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 ModelCapacitiesRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string modelFormat, string modelName, string modelVersion) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/modelCapacities", false); + uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendQuery("modelFormat", modelFormat, true); + uri.AppendQuery("modelName", modelName, true); + uri.AppendQuery("modelVersion", modelVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string modelFormat, string modelName, string modelVersion) + { + 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("/providers/Microsoft.CognitiveServices/modelCapacities", false); + uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendQuery("modelFormat", modelFormat, true); + uri.AppendQuery("modelName", modelName, true); + uri.AppendQuery("modelVersion", modelVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List ModelCapacities. + /// The ID of the target subscription. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListRequest(subscriptionId, modelFormat, modelName, modelVersion); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List ModelCapacities. + /// The ID of the target subscription. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListRequest(subscriptionId, modelFormat, modelName, modelVersion); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string modelFormat, string modelName, string modelVersion) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string modelFormat, string modelName, string modelVersion) + { + 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; + } + + /// List ModelCapacities. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , , or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, modelFormat, modelName, modelVersion); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List ModelCapacities. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The format of the Model. + /// The name of the Model. + /// The version of the Model. + /// The cancellation token to use. + /// , , , or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string modelFormat, string modelName, string modelVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(modelFormat, nameof(modelFormat)); + Argument.AssertNotNull(modelName, nameof(modelName)); + Argument.AssertNotNull(modelVersion, nameof(modelVersion)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, modelFormat, modelName, modelVersion); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ModelCapacityListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ModelCapacityListResult.DeserializeModelCapacityListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ModelsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ModelsRestOperations.cs index 4cfcc8c7eaeed..7f7d9ac451c69 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ModelsRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ModelsRestOperations.cs @@ -32,7 +32,7 @@ public ModelsRestOperations(HttpPipeline pipeline, string applicationId, Uri end { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/NetworkSecurityPerimeterConfigurationsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/NetworkSecurityPerimeterConfigurationsRestOperations.cs new file mode 100644 index 0000000000000..0f2367ef66fb9 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/NetworkSecurityPerimeterConfigurationsRestOperations.cs @@ -0,0 +1,415 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class NetworkSecurityPerimeterConfigurationsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NetworkSecurityPerimeterConfigurationsRestOperations. + /// 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 NetworkSecurityPerimeterConfigurationsRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/networkSecurityPerimeterConfigurations", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/networkSecurityPerimeterConfigurations", 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 NSP configurations for an account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterConfigurationList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterConfigurationList.DeserializeNetworkSecurityPerimeterConfigurationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of NSP configurations for an account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterConfigurationList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterConfigurationList.DeserializeNetworkSecurityPerimeterConfigurationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/networkSecurityPerimeterConfigurations/", false); + uri.AppendPath(nspConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/networkSecurityPerimeterConfigurations/", false); + uri.AppendPath(nspConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified NSP configurations for an account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the NSP Configuration. + /// 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 accountName, string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, nspConfigurationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterConfigurationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterConfigurationData.DeserializeNetworkSecurityPerimeterConfigurationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NetworkSecurityPerimeterConfigurationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified NSP configurations for an account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the NSP Configuration. + /// 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 accountName, string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, nspConfigurationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterConfigurationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterConfigurationData.DeserializeNetworkSecurityPerimeterConfigurationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NetworkSecurityPerimeterConfigurationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateReconcileRequestUri(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/networkSecurityPerimeterConfigurations/", false); + uri.AppendPath(nspConfigurationName, true); + uri.AppendPath("/reconcile", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateReconcileRequest(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/networkSecurityPerimeterConfigurations/", false); + uri.AppendPath(nspConfigurationName, true); + uri.AppendPath("/reconcile", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Reconcile the NSP configuration for an account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task ReconcileAsync(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var message = CreateReconcileRequest(subscriptionId, resourceGroupName, accountName, nspConfigurationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Reconcile the NSP configuration for an account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the NSP Configuration. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Reconcile(string subscriptionId, string resourceGroupName, string accountName, string nspConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(nspConfigurationName, nameof(nspConfigurationName)); + + using var message = CreateReconcileRequest(subscriptionId, resourceGroupName, accountName, nspConfigurationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + 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 NSP configurations for an account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterConfigurationList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterConfigurationList.DeserializeNetworkSecurityPerimeterConfigurationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of NSP configurations for an account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterConfigurationList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterConfigurationList.DeserializeNetworkSecurityPerimeterConfigurationList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs index 355fb789c38e3..ecee84ca86ca5 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateEndpointConnectionsRestOperations.cs @@ -32,7 +32,7 @@ public PrivateEndpointConnectionsRestOperations(HttpPipeline pipeline, string ap { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs index e03e51f8409c5..efeb0dfa67567 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs @@ -32,7 +32,7 @@ public PrivateLinkResourcesRestOperations(HttpPipeline pipeline, string applicat { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiBlocklistItemsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiBlocklistItemsRestOperations.cs new file mode 100644 index 0000000000000..957e5be876ef5 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiBlocklistItemsRestOperations.cs @@ -0,0 +1,782 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class RaiBlocklistItemsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of RaiBlocklistItemsRestOperations. + /// 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 RaiBlocklistItemsRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the blocklist items associated with the custom blocklist. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListItemsResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlockListItemsResult.DeserializeRaiBlockListItemsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the blocklist items associated with the custom blocklist. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListItemsResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlockListItemsResult.DeserializeRaiBlockListItemsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, string raiBlocklistItemName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems/", false); + uri.AppendPath(raiBlocklistItemName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, string raiBlocklistItemName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems/", false); + uri.AppendPath(raiBlocklistItemName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified custom blocklist Item associated with the custom blocklist. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// 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 accountName, string raiBlocklistName, string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiBlocklistItemData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlocklistItemData.DeserializeRaiBlocklistItemData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiBlocklistItemData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified custom blocklist Item associated with the custom blocklist. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// 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 accountName, string raiBlocklistName, string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiBlocklistItemData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlocklistItemData.DeserializeRaiBlocklistItemData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiBlocklistItemData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, string raiBlocklistItemName, RaiBlocklistItemData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems/", false); + uri.AppendPath(raiBlocklistItemName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, string raiBlocklistItemName, RaiBlocklistItemData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems/", false); + uri.AppendPath(raiBlocklistItemName, 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; + } + + /// Update the state of specified blocklist item associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// Properties describing the custom blocklist. + /// 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 accountName, string raiBlocklistName, string raiBlocklistItemName, RaiBlocklistItemData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + RaiBlocklistItemData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlocklistItemData.DeserializeRaiBlocklistItemData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update the state of specified blocklist item associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// Properties describing the custom blocklist. + /// 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 accountName, string raiBlocklistName, string raiBlocklistItemName, RaiBlocklistItemData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + RaiBlocklistItemData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlocklistItemData.DeserializeRaiBlocklistItemData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, string raiBlocklistItemName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems/", false); + uri.AppendPath(raiBlocklistItemName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, string raiBlocklistItemName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/raiBlocklistItems/", false); + uri.AppendPath(raiBlocklistItemName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the specified blocklist Item associated with the custom blocklist. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// 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 accountName, string raiBlocklistName, string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the specified blocklist Item associated with the custom blocklist. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The name of the RaiBlocklist Item associated with the custom blocklist. + /// 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 accountName, string raiBlocklistName, string raiBlocklistItemName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNullOrEmpty(raiBlocklistItemName, nameof(raiBlocklistItemName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateBatchAddRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, IEnumerable content) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/addRaiBlocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateBatchAddRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, IEnumerable content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/addRaiBlocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteStartArray(); + foreach (var item in content) + { + content0.JsonWriter.WriteObjectValue(item, ModelSerializationExtensions.WireOptions); + } + content0.JsonWriter.WriteEndArray(); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Batch operation to add blocklist items. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// Properties describing the custom blocklist items. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> BatchAddAsync(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, IEnumerable content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateBatchAddRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiBlocklistData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlocklistData.DeserializeRaiBlocklistData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Batch operation to add blocklist items. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// Properties describing the custom blocklist items. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response BatchAdd(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, IEnumerable content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateBatchAddRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiBlocklistData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlocklistData.DeserializeRaiBlocklistData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateBatchDeleteRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, BinaryData raiBlocklistItemsNames) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/deleteRaiBlocklistItems", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateBatchDeleteRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, BinaryData raiBlocklistItemsNames) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendPath("/deleteRaiBlocklistItems", 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(); +#if NET6_0_OR_GREATER + content.JsonWriter.WriteRawValue(raiBlocklistItemsNames); +#else + using (JsonDocument document = JsonDocument.Parse(raiBlocklistItemsNames)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); + } +#endif + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Batch operation to delete blocklist items. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// List of RAI Blocklist Items Names. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task BatchDeleteAsync(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, BinaryData raiBlocklistItemsNames, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(raiBlocklistItemsNames, nameof(raiBlocklistItemsNames)); + + using var message = CreateBatchDeleteRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemsNames); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Batch operation to delete blocklist items. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// List of RAI Blocklist Items Names. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response BatchDelete(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, BinaryData raiBlocklistItemsNames, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(raiBlocklistItemsNames, nameof(raiBlocklistItemsNames)); + + using var message = CreateBatchDeleteRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemsNames); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + 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 the blocklist items associated with the custom blocklist. + /// 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. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName, raiBlocklistName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListItemsResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlockListItemsResult.DeserializeRaiBlockListItemsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the blocklist items associated with the custom blocklist. + /// 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. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName, raiBlocklistName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListItemsResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlockListItemsResult.DeserializeRaiBlockListItemsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiBlocklistsRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiBlocklistsRestOperations.cs new file mode 100644 index 0000000000000..e3253bbebf52e --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiBlocklistsRestOperations.cs @@ -0,0 +1,523 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class RaiBlocklistsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of RaiBlocklistsRestOperations. + /// 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 RaiBlocklistsRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the custom blocklists associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlockListResult.DeserializeRaiBlockListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the custom blocklists associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlockListResult.DeserializeRaiBlockListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// 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 accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiBlocklistData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlocklistData.DeserializeRaiBlocklistData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiBlocklistData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified custom blocklist associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// 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 accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiBlocklistData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlocklistData.DeserializeRaiBlocklistData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiBlocklistData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, RaiBlocklistData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName, RaiBlocklistData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, 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; + } + + /// Update the state of specified blocklist associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// Properties describing the custom blocklist. + /// 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 accountName, string raiBlocklistName, RaiBlocklistData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + RaiBlocklistData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlocklistData.DeserializeRaiBlocklistData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update the state of specified blocklist associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// Properties describing the custom blocklist. + /// 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 accountName, string raiBlocklistName, RaiBlocklistData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + RaiBlocklistData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlocklistData.DeserializeRaiBlocklistData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string accountName, string raiBlocklistName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiBlocklists/", false); + uri.AppendPath(raiBlocklistName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the specified custom blocklist associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// 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 accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the specified custom blocklist associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiBlocklist associated with the Cognitive Services Account. + /// 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 accountName, string raiBlocklistName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiBlocklistName, nameof(raiBlocklistName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, raiBlocklistName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + 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 the custom blocklists associated with the Azure OpenAI account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiBlockListResult.DeserializeRaiBlockListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the custom blocklists associated with the Azure OpenAI account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiBlockListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiBlockListResult.DeserializeRaiBlockListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiContentFiltersRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiContentFiltersRestOperations.cs new file mode 100644 index 0000000000000..698a825f8f98a --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiContentFiltersRestOperations.cs @@ -0,0 +1,295 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class RaiContentFiltersRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of RaiContentFiltersRestOperations. + /// 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 RaiContentFiltersRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, AzureLocation location) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/raiContentFilters", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, AzureLocation location) + { + 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("/providers/Microsoft.CognitiveServices/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/raiContentFilters", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Content Filters types. + /// The ID of the target subscription. + /// Resource location. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListRequest(subscriptionId, location); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiContentFilterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiContentFilterListResult.DeserializeRaiContentFilterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Content Filters types. + /// The ID of the target subscription. + /// Resource location. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListRequest(subscriptionId, location); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiContentFilterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiContentFilterListResult.DeserializeRaiContentFilterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, AzureLocation location, string filterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.CognitiveServices/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/raiContentFilters/", false); + uri.AppendPath(filterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, AzureLocation location, string filterName) + { + 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("/providers/Microsoft.CognitiveServices/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/raiContentFilters/", false); + uri.AppendPath(filterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get Content Filters types. + /// The ID of the target subscription. + /// Resource location. + /// The name of the RAI Content Filter. + /// 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, AzureLocation location, string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var message = CreateGetRequest(subscriptionId, location, filterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiContentFilterData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiContentFilterData.DeserializeRaiContentFilterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiContentFilterData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get Content Filters types. + /// The ID of the target subscription. + /// Resource location. + /// The name of the RAI Content Filter. + /// 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, AzureLocation location, string filterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(filterName, nameof(filterName)); + + using var message = CreateGetRequest(subscriptionId, location, filterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiContentFilterData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiContentFilterData.DeserializeRaiContentFilterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiContentFilterData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, AzureLocation location) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, AzureLocation location) + { + 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; + } + + /// List Content Filters types. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// Resource location. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, location); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiContentFilterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiContentFilterListResult.DeserializeRaiContentFilterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Content Filters types. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// Resource location. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, location); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiContentFilterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiContentFilterListResult.DeserializeRaiContentFilterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiPoliciesRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiPoliciesRestOperations.cs new file mode 100644 index 0000000000000..1dd017dc08324 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/RaiPoliciesRestOperations.cs @@ -0,0 +1,523 @@ +// 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.CognitiveServices.Models; + +namespace Azure.ResourceManager.CognitiveServices +{ + internal partial class RaiPoliciesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of RaiPoliciesRestOperations. + /// 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 RaiPoliciesRestOperations(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 ?? "2024-06-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string accountName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the content filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiPolicyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiPolicyListResult.DeserializeRaiPolicyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the content filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiPolicyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiPolicyListResult.DeserializeRaiPolicyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiPolicyName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies/", false); + uri.AppendPath(raiPolicyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string accountName, string raiPolicyName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies/", false); + uri.AppendPath(raiPolicyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified Content Filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// 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 accountName, string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, raiPolicyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiPolicyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiPolicyData.DeserializeRaiPolicyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiPolicyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified Content Filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// 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 accountName, string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, accountName, raiPolicyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiPolicyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiPolicyData.DeserializeRaiPolicyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((RaiPolicyData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiPolicyName, RaiPolicyData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies/", false); + uri.AppendPath(raiPolicyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string accountName, string raiPolicyName, RaiPolicyData 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies/", false); + uri.AppendPath(raiPolicyName, 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; + } + + /// Update the state of specified Content Filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// Properties describing the Content Filters. + /// 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 accountName, string raiPolicyName, RaiPolicyData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, raiPolicyName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + RaiPolicyData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiPolicyData.DeserializeRaiPolicyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update the state of specified Content Filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// Properties describing the Content Filters. + /// 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 accountName, string raiPolicyName, RaiPolicyData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, accountName, raiPolicyName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + RaiPolicyData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiPolicyData.DeserializeRaiPolicyData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string accountName, string raiPolicyName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies/", false); + uri.AppendPath(raiPolicyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string accountName, string raiPolicyName) + { + 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.CognitiveServices/accounts/", false); + uri.AppendPath(accountName, true); + uri.AppendPath("/raiPolicies/", false); + uri.AppendPath(raiPolicyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the specified Content Filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// 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 accountName, string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, raiPolicyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the specified Content Filters associated with the Azure OpenAI account. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The name of Cognitive Services account. + /// The name of the RaiPolicy associated with the Cognitive Services Account. + /// 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 accountName, string raiPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + Argument.AssertNotNullOrEmpty(raiPolicyName, nameof(raiPolicyName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, accountName, raiPolicyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string accountName) + { + 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 the content filters associated with the Azure OpenAI account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + RaiPolicyListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = RaiPolicyListResult.DeserializeRaiPolicyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the content filters associated with the Azure OpenAI account. + /// 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. + /// The name of Cognitive Services account. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string accountName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, accountName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + RaiPolicyListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = RaiPolicyListResult.DeserializeRaiPolicyListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ResourceSkusRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ResourceSkusRestOperations.cs index 3f7f074d2f6d5..e529814a7678c 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ResourceSkusRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/ResourceSkusRestOperations.cs @@ -32,7 +32,7 @@ public ResourceSkusRestOperations(HttpPipeline pipeline, string applicationId, U { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/UsagesRestOperations.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/UsagesRestOperations.cs index 632e3c0630a95..049325cb3b0f2 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/UsagesRestOperations.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/RestOperations/UsagesRestOperations.cs @@ -32,7 +32,7 @@ public UsagesRestOperations(HttpPipeline pipeline, string applicationId, Uri end { _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2023-05-01"; + _apiVersion = apiVersion ?? "2024-06-01-preview"; _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md index c5ff2c2fa510d..b2b645e9979fa 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md @@ -8,7 +8,7 @@ azure-arm: true csharp: true library-name: CognitiveServices namespace: Azure.ResourceManager.CognitiveServices -require: https://github.com/Azure/azure-rest-api-specs/blob/ba1884683c35d1ea63d229a7106f207e507c3861/specification/cognitiveservices/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/cognitiveservices/resource-manager/readme.md output-folder: $(this-folder)/Generated clear-output-folder: true sample-gen: