diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/api/Azure.ResourceManager.DataProtectionBackup.netstandard2.0.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/api/Azure.ResourceManager.DataProtectionBackup.netstandard2.0.cs index a6901422b19a0..d89cedb9ce4d8 100644 --- a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/api/Azure.ResourceManager.DataProtectionBackup.netstandard2.0.cs +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/api/Azure.ResourceManager.DataProtectionBackup.netstandard2.0.cs @@ -19,6 +19,7 @@ public static partial class DataProtectionBackupExtensions public static Azure.ResourceManager.DataProtectionBackup.DeletedDataProtectionBackupInstanceResource GetDeletedDataProtectionBackupInstanceResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Response GetResourceGuard(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string resourceGuardsName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> GetResourceGuardAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string resourceGuardsName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.DataProtectionBackup.ResourceGuardProxyBaseResource GetResourceGuardProxyBaseResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.DataProtectionBackup.ResourceGuardResource GetResourceGuardResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.DataProtectionBackup.ResourceGuardCollection GetResourceGuards(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetResourceGuards(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -225,6 +226,9 @@ protected DataProtectionBackupVaultResource() { } public virtual Azure.Response GetDeletedDataProtectionBackupInstance(string backupInstanceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetDeletedDataProtectionBackupInstanceAsync(string backupInstanceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.DataProtectionBackup.DeletedDataProtectionBackupInstanceCollection GetDeletedDataProtectionBackupInstances() { throw null; } + public virtual Azure.Response GetResourceGuardProxyBaseResource(string resourceGuardProxyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetResourceGuardProxyBaseResourceAsync(string resourceGuardProxyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DataProtectionBackup.ResourceGuardProxyBaseResourceCollection GetResourceGuardProxyBaseResources() { 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; } @@ -296,6 +300,42 @@ public ResourceGuardData(Azure.Core.AzureLocation location) : base (default(Azur public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.DataProtectionBackup.Models.ResourceGuardProperties Properties { get { throw null; } set { } } } + public partial class ResourceGuardProxyBaseResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ResourceGuardProxyBaseResource() { } + public virtual Azure.ResourceManager.DataProtectionBackup.ResourceGuardProxyBaseResourceData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName) { 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 UnlockDelete(Azure.ResourceManager.DataProtectionBackup.Models.UnlockDeleteContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UnlockDeleteAsync(Azure.ResourceManager.DataProtectionBackup.Models.UnlockDeleteContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DataProtectionBackup.ResourceGuardProxyBaseResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DataProtectionBackup.ResourceGuardProxyBaseResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ResourceGuardProxyBaseResourceCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ResourceGuardProxyBaseResourceCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string resourceGuardProxyName, Azure.ResourceManager.DataProtectionBackup.ResourceGuardProxyBaseResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string resourceGuardProxyName, Azure.ResourceManager.DataProtectionBackup.ResourceGuardProxyBaseResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string resourceGuardProxyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string resourceGuardProxyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string resourceGuardProxyName, 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 resourceGuardProxyName, 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 ResourceGuardProxyBaseResourceData : Azure.ResourceManager.Models.ResourceData + { + public ResourceGuardProxyBaseResourceData() { } + public Azure.ResourceManager.DataProtectionBackup.Models.ResourceGuardProxyBase Properties { get { throw null; } set { } } + } public partial class ResourceGuardResource : Azure.ResourceManager.ArmResource { public static readonly Azure.Core.ResourceType ResourceType; @@ -1332,6 +1372,12 @@ public RecoveryPointDataStoreDetail() { } public static bool operator !=(Azure.ResourceManager.DataProtectionBackup.Models.RecoverySetting left, Azure.ResourceManager.DataProtectionBackup.Models.RecoverySetting right) { throw null; } public override string ToString() { throw null; } } + public partial class ResourceGuardOperationDetail + { + public ResourceGuardOperationDetail() { } + public string DefaultResourceRequest { get { throw null; } set { } } + public string VaultCriticalOperation { get { throw null; } set { } } + } public partial class ResourceGuardOperationDetails { internal ResourceGuardOperationDetails() { } @@ -1356,6 +1402,14 @@ public partial class ResourceGuardProtectedObjectData : Azure.ResourceManager.Mo { internal ResourceGuardProtectedObjectData() { } } + public partial class ResourceGuardProxyBase + { + public ResourceGuardProxyBase() { } + public string Description { get { throw null; } set { } } + public string LastUpdatedTime { get { throw null; } set { } } + public System.Collections.Generic.IList ResourceGuardOperationDetails { get { throw null; } } + public string ResourceGuardResourceId { get { throw null; } set { } } + } public partial class RestorableTimeRange { public RestorableTimeRange(System.DateTimeOffset startOn, System.DateTimeOffset endOn) { } @@ -1558,4 +1612,15 @@ public TargetCopySetting(Azure.ResourceManager.DataProtectionBackup.Models.DataP public Azure.ResourceManager.DataProtectionBackup.Models.DataProtectionBackupCopySetting CopyAfter { get { throw null; } set { } } public Azure.ResourceManager.DataProtectionBackup.Models.DataStoreInfoBase DataStore { get { throw null; } set { } } } + public partial class UnlockDeleteContent + { + public UnlockDeleteContent() { } + public System.Collections.Generic.IList ResourceGuardOperationRequests { get { throw null; } } + public string ResourceToBeDeleted { get { throw null; } set { } } + } + public partial class UnlockDeleteResponse + { + internal UnlockDeleteResponse() { } + public string UnlockDeleteExpiryTime { get { throw null; } } + } } diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/DataProtectionBackupVaultResource.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/DataProtectionBackupVaultResource.cs index 6a29b28f331ad..90deae40c8504 100644 --- a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/DataProtectionBackupVaultResource.cs +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/DataProtectionBackupVaultResource.cs @@ -310,6 +310,59 @@ public virtual Response GetDeletedD return GetDeletedDataProtectionBackupInstances().Get(backupInstanceName, cancellationToken); } + /// Gets a collection of ResourceGuardProxyBaseResources in the DataProtectionBackupVault. + /// An object representing collection of ResourceGuardProxyBaseResources and their operations over a ResourceGuardProxyBaseResource. + public virtual ResourceGuardProxyBaseResourceCollection GetResourceGuardProxyBaseResources() + { + return GetCachedClient(Client => new ResourceGuardProxyBaseResourceCollection(Client, Id)); + } + + /// + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// name of the resource guard proxy. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetResourceGuardProxyBaseResourceAsync(string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + return await GetResourceGuardProxyBaseResources().GetAsync(resourceGuardProxyName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// name of the resource guard proxy. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetResourceGuardProxyBaseResource(string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + return GetResourceGuardProxyBaseResources().Get(resourceGuardProxyName, cancellationToken); + } + /// /// Returns a resource belonging to a resource group. /// diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Extensions/DataProtectionBackupExtensions.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Extensions/DataProtectionBackupExtensions.cs index dd9a4728a0bdb..6f9957cf32bfc 100644 --- a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Extensions/DataProtectionBackupExtensions.cs +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Extensions/DataProtectionBackupExtensions.cs @@ -465,5 +465,24 @@ public static ResourceGuardResource GetResourceGuardResource(this ArmClient clie ); } #endregion + + #region ResourceGuardProxyBaseResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ResourceGuardProxyBaseResource GetResourceGuardProxyBaseResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + ResourceGuardProxyBaseResource.ValidateResourceId(id); + return new ResourceGuardProxyBaseResource(client, id); + } + ); + } + #endregion } } diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardOperationDetail.Serialization.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardOperationDetail.Serialization.cs new file mode 100644 index 0000000000000..081a49d33f34d --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardOperationDetail.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + public partial class ResourceGuardOperationDetail : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(VaultCriticalOperation)) + { + writer.WritePropertyName("vaultCriticalOperation"u8); + writer.WriteStringValue(VaultCriticalOperation); + } + if (Optional.IsDefined(DefaultResourceRequest)) + { + writer.WritePropertyName("defaultResourceRequest"u8); + writer.WriteStringValue(DefaultResourceRequest); + } + writer.WriteEndObject(); + } + + internal static ResourceGuardOperationDetail DeserializeResourceGuardOperationDetail(JsonElement element) + { + Optional vaultCriticalOperation = default; + Optional defaultResourceRequest = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vaultCriticalOperation"u8)) + { + vaultCriticalOperation = property.Value.GetString(); + continue; + } + if (property.NameEquals("defaultResourceRequest"u8)) + { + defaultResourceRequest = property.Value.GetString(); + continue; + } + } + return new ResourceGuardOperationDetail(vaultCriticalOperation.Value, defaultResourceRequest.Value); + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardOperationDetail.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardOperationDetail.cs new file mode 100644 index 0000000000000..f564b90df0d35 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardOperationDetail.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + /// VaultCritical Operation protected by a resource guard. + public partial class ResourceGuardOperationDetail + { + /// Initializes a new instance of ResourceGuardOperationDetail. + public ResourceGuardOperationDetail() + { + } + + /// Initializes a new instance of ResourceGuardOperationDetail. + /// + /// + internal ResourceGuardOperationDetail(string vaultCriticalOperation, string defaultResourceRequest) + { + VaultCriticalOperation = vaultCriticalOperation; + DefaultResourceRequest = defaultResourceRequest; + } + + /// Gets or sets the vault critical operation. + public string VaultCriticalOperation { get; set; } + /// Gets or sets the default resource request. + public string DefaultResourceRequest { get; set; } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBase.Serialization.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBase.Serialization.cs new file mode 100644 index 0000000000000..2bbbaa5d47622 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBase.Serialization.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + public partial class ResourceGuardProxyBase : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ResourceGuardResourceId)) + { + writer.WritePropertyName("resourceGuardResourceId"u8); + writer.WriteStringValue(ResourceGuardResourceId); + } + if (Optional.IsCollectionDefined(ResourceGuardOperationDetails)) + { + writer.WritePropertyName("resourceGuardOperationDetails"u8); + writer.WriteStartArray(); + foreach (var item in ResourceGuardOperationDetails) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(LastUpdatedTime)) + { + writer.WritePropertyName("lastUpdatedTime"u8); + writer.WriteStringValue(LastUpdatedTime); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WriteEndObject(); + } + + internal static ResourceGuardProxyBase DeserializeResourceGuardProxyBase(JsonElement element) + { + Optional resourceGuardResourceId = default; + Optional> resourceGuardOperationDetails = default; + Optional lastUpdatedTime = default; + Optional description = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceGuardResourceId"u8)) + { + resourceGuardResourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceGuardOperationDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceGuardOperationDetail.DeserializeResourceGuardOperationDetail(item)); + } + resourceGuardOperationDetails = array; + continue; + } + if (property.NameEquals("lastUpdatedTime"u8)) + { + lastUpdatedTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + } + return new ResourceGuardProxyBase(resourceGuardResourceId.Value, Optional.ToList(resourceGuardOperationDetails), lastUpdatedTime.Value, description.Value); + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBase.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBase.cs new file mode 100644 index 0000000000000..3d891ee64afba --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBase.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + /// ResourceGuardProxyBase object, used in ResourceGuardProxyBaseResource. + public partial class ResourceGuardProxyBase + { + /// Initializes a new instance of ResourceGuardProxyBase. + public ResourceGuardProxyBase() + { + ResourceGuardOperationDetails = new ChangeTrackingList(); + } + + /// Initializes a new instance of ResourceGuardProxyBase. + /// + /// + /// + /// + internal ResourceGuardProxyBase(string resourceGuardResourceId, IList resourceGuardOperationDetails, string lastUpdatedTime, string description) + { + ResourceGuardResourceId = resourceGuardResourceId; + ResourceGuardOperationDetails = resourceGuardOperationDetails; + LastUpdatedTime = lastUpdatedTime; + Description = description; + } + + /// Gets or sets the resource guard resource id. + public string ResourceGuardResourceId { get; set; } + /// Gets the resource guard operation details. + public IList ResourceGuardOperationDetails { get; } + /// Gets or sets the last updated time. + public string LastUpdatedTime { get; set; } + /// Gets or sets the description. + public string Description { get; set; } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceData.Serialization.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceData.Serialization.cs new file mode 100644 index 0000000000000..9a4633435aece --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceData.Serialization.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DataProtectionBackup.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DataProtectionBackup +{ + public partial class ResourceGuardProxyBaseResourceData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties); + } + writer.WriteEndObject(); + } + + internal static ResourceGuardProxyBaseResourceData DeserializeResourceGuardProxyBaseResourceData(JsonElement element) + { + Optional properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + properties = ResourceGuardProxyBase.DeserializeResourceGuardProxyBase(property.Value); + 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) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + } + return new ResourceGuardProxyBaseResourceData(id, name, type, systemData.Value, properties.Value); + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceList.Serialization.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceList.Serialization.cs new file mode 100644 index 0000000000000..8ba85f06c5a53 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceList.Serialization.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DataProtectionBackup; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + internal partial class ResourceGuardProxyBaseResourceList + { + internal static ResourceGuardProxyBaseResourceList DeserializeResourceGuardProxyBaseResourceList(JsonElement element) + { + Optional> value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceGuardProxyBaseResourceData.DeserializeResourceGuardProxyBaseResourceData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new ResourceGuardProxyBaseResourceList(nextLink.Value, Optional.ToList(value)); + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceList.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceList.cs new file mode 100644 index 0000000000000..6d56ad8380adc --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/ResourceGuardProxyBaseResourceList.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.DataProtectionBackup; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + /// List of ResourceGuardProxyBase resources. + internal partial class ResourceGuardProxyBaseResourceList : DppResourceList + { + /// Initializes a new instance of ResourceGuardProxyBaseResourceList. + internal ResourceGuardProxyBaseResourceList() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of ResourceGuardProxyBaseResourceList. + /// The uri to fetch the next page of resources. Call ListNext() fetches next page of resources. + /// List of resources. + internal ResourceGuardProxyBaseResourceList(string nextLink, IReadOnlyList value) : base(nextLink) + { + Value = value; + } + + /// List of resources. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteContent.Serialization.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteContent.Serialization.cs new file mode 100644 index 0000000000000..0cf237e65f3d7 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteContent.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + public partial class UnlockDeleteContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(ResourceGuardOperationRequests)) + { + writer.WritePropertyName("resourceGuardOperationRequests"u8); + writer.WriteStartArray(); + foreach (var item in ResourceGuardOperationRequests) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ResourceToBeDeleted)) + { + writer.WritePropertyName("resourceToBeDeleted"u8); + writer.WriteStringValue(ResourceToBeDeleted); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteContent.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteContent.cs new file mode 100644 index 0000000000000..7ec3c1201fa84 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteContent.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + /// Request body of unlock delete API. + public partial class UnlockDeleteContent + { + /// Initializes a new instance of UnlockDeleteContent. + public UnlockDeleteContent() + { + ResourceGuardOperationRequests = new ChangeTrackingList(); + } + + /// Gets the resource guard operation requests. + public IList ResourceGuardOperationRequests { get; } + /// Gets or sets the resource to be deleted. + public string ResourceToBeDeleted { get; set; } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteResponse.Serialization.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteResponse.Serialization.cs new file mode 100644 index 0000000000000..2e9a82fc0e6ba --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteResponse.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + public partial class UnlockDeleteResponse + { + internal static UnlockDeleteResponse DeserializeUnlockDeleteResponse(JsonElement element) + { + Optional unlockDeleteExpiryTime = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("unlockDeleteExpiryTime"u8)) + { + unlockDeleteExpiryTime = property.Value.GetString(); + continue; + } + } + return new UnlockDeleteResponse(unlockDeleteExpiryTime.Value); + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteResponse.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteResponse.cs new file mode 100644 index 0000000000000..2edd3194249b2 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/Models/UnlockDeleteResponse.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.DataProtectionBackup.Models +{ + /// Response of Unlock Delete API. + public partial class UnlockDeleteResponse + { + /// Initializes a new instance of UnlockDeleteResponse. + internal UnlockDeleteResponse() + { + } + + /// Initializes a new instance of UnlockDeleteResponse. + /// This is the time when unlock delete privileges will get expired. + internal UnlockDeleteResponse(string unlockDeleteExpiryTime) + { + UnlockDeleteExpiryTime = unlockDeleteExpiryTime; + } + + /// This is the time when unlock delete privileges will get expired. + public string UnlockDeleteExpiryTime { get; } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResource.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResource.cs new file mode 100644 index 0000000000000..8deef07bfaa1e --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResource.cs @@ -0,0 +1,366 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.DataProtectionBackup.Models; + +namespace Azure.ResourceManager.DataProtectionBackup +{ + /// + /// A Class representing a ResourceGuardProxyBaseResource 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 GetResourceGuardProxyBaseResource method. + /// Otherwise you can get one from its parent resource using the GetResourceGuardProxyBaseResource method. + /// + public partial class ResourceGuardProxyBaseResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics; + private readonly DppResourceGuardProxyRestOperations _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient; + private readonly ResourceGuardProxyBaseResourceData _data; + + /// Initializes a new instance of the class for mocking. + protected ResourceGuardProxyBaseResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ResourceGuardProxyBaseResource(ArmClient client, ResourceGuardProxyBaseResourceData 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 ResourceGuardProxyBaseResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataProtectionBackup", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string resourceGuardProxyBaseResourceDppResourceGuardProxyApiVersion); + _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient = new DppResourceGuardProxyRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceGuardProxyBaseResourceDppResourceGuardProxyApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.DataProtection/backupVaults/backupResourceGuardProxies"; + + /// 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 ResourceGuardProxyBaseResourceData 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)); + } + + /// + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.Get"); + scope.Start(); + try + { + var response = await _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.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 ResourceGuardProxyBaseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.Get"); + scope.Start(); + try + { + var response = _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceGuardProxyBaseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the ResourceGuardProxy + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Delete + /// + /// + /// + /// 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 = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.Delete"); + scope.Start(); + try + { + var response = await _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new DataProtectionBackupArmOperation(response); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the ResourceGuardProxy + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Delete + /// + /// + /// + /// 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 = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.Delete"); + scope.Start(); + try + { + var response = _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new DataProtectionBackupArmOperation(response); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or Updates a ResourceGuardProxy + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_CreateOrUpdate + /// + /// + /// + /// 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. + /// Request body for operation. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ResourceGuardProxyBaseResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.Update"); + scope.Start(); + try + { + var response = await _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new DataProtectionBackupArmOperation(Response.FromValue(new ResourceGuardProxyBaseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or Updates a ResourceGuardProxy + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_CreateOrUpdate + /// + /// + /// + /// 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. + /// Request body for operation. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ResourceGuardProxyBaseResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.Update"); + scope.Start(); + try + { + var response = _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new DataProtectionBackupArmOperation(Response.FromValue(new ResourceGuardProxyBaseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// UnlockDelete call for ResourceGuardProxy, executed before one can delete it + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete + /// + /// + /// Operation Id + /// DppResourceGuardProxy_UnlockDelete + /// + /// + /// + /// Request body for operation. + /// The cancellation token to use. + /// is null. + public virtual async Task> UnlockDeleteAsync(UnlockDeleteContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.UnlockDelete"); + scope.Start(); + try + { + var response = await _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.UnlockDeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// UnlockDelete call for ResourceGuardProxy, executed before one can delete it + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete + /// + /// + /// Operation Id + /// DppResourceGuardProxy_UnlockDelete + /// + /// + /// + /// Request body for operation. + /// The cancellation token to use. + /// is null. + public virtual Response UnlockDelete(UnlockDeleteContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResource.UnlockDelete"); + scope.Start(); + try + { + var response = _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.UnlockDelete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResourceCollection.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResourceCollection.cs new file mode 100644 index 0000000000000..648d1be197351 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResourceCollection.cs @@ -0,0 +1,340 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.DataProtectionBackup +{ + /// + /// 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 GetResourceGuardProxyBaseResources method from an instance of . + /// + public partial class ResourceGuardProxyBaseResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics; + private readonly DppResourceGuardProxyRestOperations _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient; + + /// Initializes a new instance of the class for mocking. + protected ResourceGuardProxyBaseResourceCollection() + { + } + + /// 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 ResourceGuardProxyBaseResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DataProtectionBackup", ResourceGuardProxyBaseResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceGuardProxyBaseResource.ResourceType, out string resourceGuardProxyBaseResourceDppResourceGuardProxyApiVersion); + _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient = new DppResourceGuardProxyRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceGuardProxyBaseResourceDppResourceGuardProxyApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != DataProtectionBackupVaultResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DataProtectionBackupVaultResource.ResourceType), nameof(id)); + } + + /// + /// Creates or Updates a ResourceGuardProxy + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_CreateOrUpdate + /// + /// + /// + /// 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. + /// name of the resource guard proxy. + /// Request body for operation. + /// 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 resourceGuardProxyName, ResourceGuardProxyBaseResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, resourceGuardProxyName, data, cancellationToken).ConfigureAwait(false); + var operation = new DataProtectionBackupArmOperation(Response.FromValue(new ResourceGuardProxyBaseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or Updates a ResourceGuardProxy + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_CreateOrUpdate + /// + /// + /// + /// 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. + /// name of the resource guard proxy. + /// Request body for operation. + /// 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 resourceGuardProxyName, ResourceGuardProxyBaseResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, resourceGuardProxyName, data, cancellationToken); + var operation = new DataProtectionBackupArmOperation(Response.FromValue(new ResourceGuardProxyBaseResource(Client, response), response.GetRawResponse())); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// name of the resource guard proxy. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResourceCollection.Get"); + scope.Start(); + try + { + var response = await _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, resourceGuardProxyName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceGuardProxyBaseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// name of the resource guard proxy. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResourceCollection.Get"); + scope.Start(); + try + { + var response = _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, resourceGuardProxyName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceGuardProxyBaseResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the list of ResourceGuardProxies associated with the vault + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies + /// + /// + /// Operation Id + /// DppResourceGuardProxy_List + /// + /// + /// + /// 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) => _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceGuardProxyBaseResource(Client, ResourceGuardProxyBaseResourceData.DeserializeResourceGuardProxyBaseResourceData(e)), _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics, Pipeline, "ResourceGuardProxyBaseResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Returns the list of ResourceGuardProxies associated with the vault + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies + /// + /// + /// Operation Id + /// DppResourceGuardProxy_List + /// + /// + /// + /// 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) => _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceGuardProxyBaseResource(Client, ResourceGuardProxyBaseResourceData.DeserializeResourceGuardProxyBaseResourceData(e)), _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics, Pipeline, "ResourceGuardProxyBaseResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// name of the resource guard proxy. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, resourceGuardProxyName, 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.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName} + /// + /// + /// Operation Id + /// DppResourceGuardProxy_Get + /// + /// + /// + /// name of the resource guard proxy. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var scope = _resourceGuardProxyBaseResourceDppResourceGuardProxyClientDiagnostics.CreateScope("ResourceGuardProxyBaseResourceCollection.Exists"); + scope.Start(); + try + { + var response = _resourceGuardProxyBaseResourceDppResourceGuardProxyRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, resourceGuardProxyName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResourceData.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResourceData.cs new file mode 100644 index 0000000000000..071aa6fa91edf --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/ResourceGuardProxyBaseResourceData.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.DataProtectionBackup.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DataProtectionBackup +{ + /// A class representing the ResourceGuardProxyBaseResource data model. + public partial class ResourceGuardProxyBaseResourceData : ResourceData + { + /// Initializes a new instance of ResourceGuardProxyBaseResourceData. + public ResourceGuardProxyBaseResourceData() + { + } + + /// Initializes a new instance of ResourceGuardProxyBaseResourceData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// ResourceGuardProxyBaseResource properties. + internal ResourceGuardProxyBaseResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ResourceGuardProxyBase properties) : base(id, name, resourceType, systemData) + { + Properties = properties; + } + + /// ResourceGuardProxyBaseResource properties. + public ResourceGuardProxyBase Properties { get; set; } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/RestOperations/DppResourceGuardProxyRestOperations.cs b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/RestOperations/DppResourceGuardProxyRestOperations.cs new file mode 100644 index 0000000000000..ffc57c3506034 --- /dev/null +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/Generated/RestOperations/DppResourceGuardProxyRestOperations.cs @@ -0,0 +1,544 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DataProtectionBackup.Models; + +namespace Azure.ResourceManager.DataProtectionBackup +{ + internal partial class DppResourceGuardProxyRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DppResourceGuardProxyRestOperations. + /// 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 DppResourceGuardProxyRestOperations(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 ?? "2023-01-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string vaultName) + { + 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.DataProtection/backupVaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/backupResourceGuardProxies", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Returns the list of ResourceGuardProxies associated with the vault. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// 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 vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, vaultName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ResourceGuardProxyBaseResourceList.DeserializeResourceGuardProxyBaseResourceList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Returns the list of ResourceGuardProxies associated with the vault. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// 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 vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, vaultName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ResourceGuardProxyBaseResourceList.DeserializeResourceGuardProxyBaseResourceList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName) + { + 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.DataProtection/backupVaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/backupResourceGuardProxies/", false); + uri.AppendPath(resourceGuardProxyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// 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 vaultName, string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ResourceGuardProxyBaseResourceData.DeserializeResourceGuardProxyBaseResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ResourceGuardProxyBaseResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// 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 vaultName, string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ResourceGuardProxyBaseResourceData.DeserializeResourceGuardProxyBaseResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ResourceGuardProxyBaseResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName, ResourceGuardProxyBaseResourceData 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.DataProtection/backupVaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/backupResourceGuardProxies/", false); + uri.AppendPath(resourceGuardProxyName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or Updates a ResourceGuardProxy. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// Request body for operation. + /// 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 vaultName, string resourceGuardProxyName, ResourceGuardProxyBaseResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ResourceGuardProxyBaseResourceData.DeserializeResourceGuardProxyBaseResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or Updates a ResourceGuardProxy. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// Request body for operation. + /// 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 vaultName, string resourceGuardProxyName, ResourceGuardProxyBaseResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ResourceGuardProxyBaseResourceData.DeserializeResourceGuardProxyBaseResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName) + { + 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.DataProtection/backupVaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/backupResourceGuardProxies/", false); + uri.AppendPath(resourceGuardProxyName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes the ResourceGuardProxy. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// 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 vaultName, string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes the ResourceGuardProxy. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// 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 vaultName, string resourceGuardProxyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUnlockDeleteRequest(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName, UnlockDeleteContent 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.DataProtection/backupVaults/", false); + uri.AppendPath(vaultName, true); + uri.AppendPath("/backupResourceGuardProxies/", false); + uri.AppendPath(resourceGuardProxyName, true); + uri.AppendPath("/unlockDelete", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// Request body for operation. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> UnlockDeleteAsync(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName, UnlockDeleteContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateUnlockDeleteRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + UnlockDeleteResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = UnlockDeleteResponse.DeserializeUnlockDeleteResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// UnlockDelete call for ResourceGuardProxy, executed before one can delete it. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// name of the resource guard proxy. + /// Request body for operation. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response UnlockDelete(string subscriptionId, string resourceGroupName, string vaultName, string resourceGuardProxyName, UnlockDeleteContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + Argument.AssertNotNullOrEmpty(resourceGuardProxyName, nameof(resourceGuardProxyName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateUnlockDeleteRequest(subscriptionId, resourceGroupName, vaultName, resourceGuardProxyName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + UnlockDeleteResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = UnlockDeleteResponse.DeserializeUnlockDeleteResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string vaultName) + { + 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; + } + + /// Returns the list of ResourceGuardProxies associated with the vault. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// 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 vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceList value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ResourceGuardProxyBaseResourceList.DeserializeResourceGuardProxyBaseResourceList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Returns the list of ResourceGuardProxies associated with the vault. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the backup vault. + /// 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 vaultName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(vaultName, nameof(vaultName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, vaultName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceGuardProxyBaseResourceList value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ResourceGuardProxyBaseResourceList.DeserializeResourceGuardProxyBaseResourceList(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/autorest.md b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/autorest.md index bd6681599fd28..e3ea5244c2698 100644 --- a/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/autorest.md +++ b/sdk/dataprotection/Azure.ResourceManager.DataProtectionBackup/src/autorest.md @@ -9,7 +9,7 @@ generate-model-factory: false csharp: true library-name: DataProtectionBackup namespace: Azure.ResourceManager.DataProtectionBackup -require: https://github.com/Azure/azure-rest-api-specs/blob/42e62bef21fca828da9a9a81d845d00aae466877/specification/dataprotection/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dataprotection/resource-manager/readme.md output-folder: $(this-folder)/Generated clear-output-folder: true skip-csproj: true