diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationFullBackupHeaders.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationFullBackupHeaders.cs
deleted file mode 100644
index 541632c0807f..000000000000
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationFullBackupHeaders.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using Azure.Core;
-
-namespace Azure.Security.KeyVault.Administration
-{
- internal partial class AzureSecurityKeyVaultAdministrationFullBackupHeaders
- {
- private readonly Response _response;
- public AzureSecurityKeyVaultAdministrationFullBackupHeaders(Response response)
- {
- _response = response;
- }
- /// The recommended number of seconds to wait before calling the URI specified in Azure-AsyncOperation.
- public int? RetryAfter => _response.Headers.TryGetValue("Retry-After", out int? value) ? value : null;
- /// The URI to poll for completion status.
- public string AzureAsyncOperation => _response.Headers.TryGetValue("Azure-AsyncOperation", out string value) ? value : null;
- }
-}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders.cs
deleted file mode 100644
index ed710c7534ec..000000000000
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using Azure.Core;
-
-namespace Azure.Security.KeyVault.Administration
-{
- internal partial class AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders
- {
- private readonly Response _response;
- public AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders(Response response)
- {
- _response = response;
- }
- /// The recommended number of seconds to wait before calling the URI specified in Azure-AsyncOperation.
- public int? RetryAfter => _response.Headers.TryGetValue("Retry-After", out int? value) ? value : null;
- /// The URI to poll for completion status.
- public string AzureAsyncOperation => _response.Headers.TryGetValue("Azure-AsyncOperation", out string value) ? value : null;
- }
-}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationSelectiveKeyRestoreOperationHeaders.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationSelectiveKeyRestoreOperationHeaders.cs
deleted file mode 100644
index 80dfb65bef95..000000000000
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationSelectiveKeyRestoreOperationHeaders.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using Azure.Core;
-
-namespace Azure.Security.KeyVault.Administration
-{
- internal partial class AzureSecurityKeyVaultAdministrationSelectiveKeyRestoreOperationHeaders
- {
- private readonly Response _response;
- public AzureSecurityKeyVaultAdministrationSelectiveKeyRestoreOperationHeaders(Response response)
- {
- _response = response;
- }
- /// The recommended number of seconds to wait before calling the URI specified in Azure-AsyncOperation.
- public int? RetryAfter => _response.Headers.TryGetValue("Retry-After", out int? value) ? value : null;
- /// The URI to poll for completion status.
- public string AzureAsyncOperation => _response.Headers.TryGetValue("Azure-AsyncOperation", out string value) ? value : null;
- }
-}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/BackupRestoreRestClient.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/BackupRestoreRestClient.cs
deleted file mode 100644
index b30181ba2e98..000000000000
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/BackupRestoreRestClient.cs
+++ /dev/null
@@ -1,417 +0,0 @@
-// 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.Security.KeyVault.Administration.Models;
-
-namespace Azure.Security.KeyVault.Administration
-{
- internal partial class BackupRestoreRestClient
- {
- private readonly HttpPipeline _pipeline;
- private readonly string _apiVersion;
-
- /// The ClientDiagnostics is used to provide tracing support for the client library.
- internal ClientDiagnostics ClientDiagnostics { get; }
-
- /// Initializes a new instance of BackupRestoreRestClient.
- /// The handler for diagnostic messaging in the client.
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- /// Api Version.
- /// , or is null.
- public BackupRestoreRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string apiVersion = "7.5")
- {
- ClientDiagnostics = clientDiagnostics ?? throw new ArgumentNullException(nameof(clientDiagnostics));
- _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));
- _apiVersion = apiVersion ?? throw new ArgumentNullException(nameof(apiVersion));
- }
-
- internal HttpMessage CreateFullBackupRequest(string vaultBaseUrl, SASTokenParameter azureStorageBlobContainerUri)
- {
- var message = _pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Post;
- var uri = new RawRequestUriBuilder();
- uri.AppendRaw(vaultBaseUrl, false);
- uri.AppendPath("/backup", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- request.Headers.Add("Accept", "application/json");
- if (azureStorageBlobContainerUri != null)
- {
- request.Headers.Add("Content-Type", "application/json");
- var content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteObjectValue(azureStorageBlobContainerUri);
- request.Content = content;
- }
- return message;
- }
-
- /// Creates a full backup using a user-provided SAS token to an Azure blob storage container.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// Azure blob shared access signature token pointing to a valid Azure blob container where full backup needs to be stored. This token needs to be valid for at least next 24 hours from the time of making this call.
- /// The cancellation token to use.
- /// is null.
- public async Task> FullBackupAsync(string vaultBaseUrl, SASTokenParameter azureStorageBlobContainerUri = null, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
-
- using var message = CreateFullBackupRequest(vaultBaseUrl, azureStorageBlobContainerUri);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- var headers = new AzureSecurityKeyVaultAdministrationFullBackupHeaders(message.Response);
- switch (message.Response.Status)
- {
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- /// Creates a full backup using a user-provided SAS token to an Azure blob storage container.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// Azure blob shared access signature token pointing to a valid Azure blob container where full backup needs to be stored. This token needs to be valid for at least next 24 hours from the time of making this call.
- /// The cancellation token to use.
- /// is null.
- public ResponseWithHeaders FullBackup(string vaultBaseUrl, SASTokenParameter azureStorageBlobContainerUri = null, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
-
- using var message = CreateFullBackupRequest(vaultBaseUrl, azureStorageBlobContainerUri);
- _pipeline.Send(message, cancellationToken);
- var headers = new AzureSecurityKeyVaultAdministrationFullBackupHeaders(message.Response);
- switch (message.Response.Status)
- {
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- internal HttpMessage CreateFullBackupStatusRequest(string vaultBaseUrl, string jobId)
- {
- var message = _pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Get;
- var uri = new RawRequestUriBuilder();
- uri.AppendRaw(vaultBaseUrl, false);
- uri.AppendPath("/backup/", false);
- uri.AppendPath(jobId, true);
- uri.AppendPath("/pending", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- request.Headers.Add("Accept", "application/json");
- return message;
- }
-
- /// Returns the status of full backup operation.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The id returned as part of the backup request.
- /// The cancellation token to use.
- /// or is null.
- public async Task> FullBackupStatusAsync(string vaultBaseUrl, string jobId, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (jobId == null)
- {
- throw new ArgumentNullException(nameof(jobId));
- }
-
- using var message = CreateFullBackupStatusRequest(vaultBaseUrl, jobId);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- switch (message.Response.Status)
- {
- case 200:
- {
- FullBackupDetailsInternal value = default;
- using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
- value = FullBackupDetailsInternal.DeserializeFullBackupDetailsInternal(document.RootElement);
- return Response.FromValue(value, message.Response);
- }
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- /// Returns the status of full backup operation.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The id returned as part of the backup request.
- /// The cancellation token to use.
- /// or is null.
- public Response FullBackupStatus(string vaultBaseUrl, string jobId, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (jobId == null)
- {
- throw new ArgumentNullException(nameof(jobId));
- }
-
- using var message = CreateFullBackupStatusRequest(vaultBaseUrl, jobId);
- _pipeline.Send(message, cancellationToken);
- switch (message.Response.Status)
- {
- case 200:
- {
- FullBackupDetailsInternal value = default;
- using var document = JsonDocument.Parse(message.Response.ContentStream);
- value = FullBackupDetailsInternal.DeserializeFullBackupDetailsInternal(document.RootElement);
- return Response.FromValue(value, message.Response);
- }
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- internal HttpMessage CreateFullRestoreOperationRequest(string vaultBaseUrl, RestoreOperationParameters restoreBlobDetails)
- {
- var message = _pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Put;
- var uri = new RawRequestUriBuilder();
- uri.AppendRaw(vaultBaseUrl, false);
- uri.AppendPath("/restore", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- request.Headers.Add("Accept", "application/json");
- if (restoreBlobDetails != null)
- {
- request.Headers.Add("Content-Type", "application/json");
- var content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteObjectValue(restoreBlobDetails);
- request.Content = content;
- }
- return message;
- }
-
- /// Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage backup folder.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The Azure blob SAS token pointing to a folder where the previous successful full backup was stored.
- /// The cancellation token to use.
- /// is null.
- public async Task> FullRestoreOperationAsync(string vaultBaseUrl, RestoreOperationParameters restoreBlobDetails = null, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
-
- using var message = CreateFullRestoreOperationRequest(vaultBaseUrl, restoreBlobDetails);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- var headers = new AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders(message.Response);
- switch (message.Response.Status)
- {
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- /// Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage backup folder.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The Azure blob SAS token pointing to a folder where the previous successful full backup was stored.
- /// The cancellation token to use.
- /// is null.
- public ResponseWithHeaders FullRestoreOperation(string vaultBaseUrl, RestoreOperationParameters restoreBlobDetails = null, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
-
- using var message = CreateFullRestoreOperationRequest(vaultBaseUrl, restoreBlobDetails);
- _pipeline.Send(message, cancellationToken);
- var headers = new AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders(message.Response);
- switch (message.Response.Status)
- {
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- internal HttpMessage CreateRestoreStatusRequest(string vaultBaseUrl, string jobId)
- {
- var message = _pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Get;
- var uri = new RawRequestUriBuilder();
- uri.AppendRaw(vaultBaseUrl, false);
- uri.AppendPath("/restore/", false);
- uri.AppendPath(jobId, true);
- uri.AppendPath("/pending", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- request.Headers.Add("Accept", "application/json");
- return message;
- }
-
- /// Returns the status of restore operation.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The Job Id returned part of the restore operation.
- /// The cancellation token to use.
- /// or is null.
- public async Task> RestoreStatusAsync(string vaultBaseUrl, string jobId, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (jobId == null)
- {
- throw new ArgumentNullException(nameof(jobId));
- }
-
- using var message = CreateRestoreStatusRequest(vaultBaseUrl, jobId);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- switch (message.Response.Status)
- {
- case 200:
- {
- RestoreDetailsInternal value = default;
- using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
- value = RestoreDetailsInternal.DeserializeRestoreDetailsInternal(document.RootElement);
- return Response.FromValue(value, message.Response);
- }
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- /// Returns the status of restore operation.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The Job Id returned part of the restore operation.
- /// The cancellation token to use.
- /// or is null.
- public Response RestoreStatus(string vaultBaseUrl, string jobId, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (jobId == null)
- {
- throw new ArgumentNullException(nameof(jobId));
- }
-
- using var message = CreateRestoreStatusRequest(vaultBaseUrl, jobId);
- _pipeline.Send(message, cancellationToken);
- switch (message.Response.Status)
- {
- case 200:
- {
- RestoreDetailsInternal value = default;
- using var document = JsonDocument.Parse(message.Response.ContentStream);
- value = RestoreDetailsInternal.DeserializeRestoreDetailsInternal(document.RootElement);
- return Response.FromValue(value, message.Response);
- }
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- internal HttpMessage CreateSelectiveKeyRestoreOperationRequest(string vaultBaseUrl, string keyName, SelectiveKeyRestoreOperationParameters restoreBlobDetails)
- {
- var message = _pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Put;
- var uri = new RawRequestUriBuilder();
- uri.AppendRaw(vaultBaseUrl, false);
- uri.AppendPath("/keys/", false);
- uri.AppendPath(keyName, true);
- uri.AppendPath("/restore", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- request.Headers.Add("Accept", "application/json");
- if (restoreBlobDetails != null)
- {
- request.Headers.Add("Content-Type", "application/json");
- var content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteObjectValue(restoreBlobDetails);
- request.Content = content;
- }
- return message;
- }
-
- /// Restores all key versions of a given key using user supplied SAS token pointing to a previously stored Azure Blob storage backup folder.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The name of the key to be restored from the user supplied backup.
- /// The Azure blob SAS token pointing to a folder where the previous successful full backup was stored.
- /// The cancellation token to use.
- /// or is null.
- public async Task> SelectiveKeyRestoreOperationAsync(string vaultBaseUrl, string keyName, SelectiveKeyRestoreOperationParameters restoreBlobDetails = null, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (keyName == null)
- {
- throw new ArgumentNullException(nameof(keyName));
- }
-
- using var message = CreateSelectiveKeyRestoreOperationRequest(vaultBaseUrl, keyName, restoreBlobDetails);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- var headers = new AzureSecurityKeyVaultAdministrationSelectiveKeyRestoreOperationHeaders(message.Response);
- switch (message.Response.Status)
- {
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
- }
- }
-
- /// Restores all key versions of a given key using user supplied SAS token pointing to a previously stored Azure Blob storage backup folder.
- /// The vault name, for example https://myvault.vault.azure.net.
- /// The name of the key to be restored from the user supplied backup.
- /// The Azure blob SAS token pointing to a folder where the previous successful full backup was stored.
- /// The cancellation token to use.
- /// or is null.
- public ResponseWithHeaders SelectiveKeyRestoreOperation(string vaultBaseUrl, string keyName, SelectiveKeyRestoreOperationParameters restoreBlobDetails = null, CancellationToken cancellationToken = default)
- {
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (keyName == null)
- {
- throw new ArgumentNullException(nameof(keyName));
- }
-
- using var message = CreateSelectiveKeyRestoreOperationRequest(vaultBaseUrl, keyName, restoreBlobDetails);
- _pipeline.Send(message, cancellationToken);
- var headers = new AzureSecurityKeyVaultAdministrationSelectiveKeyRestoreOperationHeaders(message.Response);
- switch (message.Response.Status)
- {
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
- }
- }
- }
-}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/MultipartFormDataRequestContent.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/MultipartFormDataRequestContent.cs
deleted file mode 100644
index ad07cca72ac7..000000000000
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/MultipartFormDataRequestContent.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Globalization;
-using System.IO;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Threading;
-using System.Threading.Tasks;
-using Azure.Core;
-using Azure.Core.Pipeline;
-
-namespace Azure.Security.KeyVault.Administration
-{
- internal class MultipartFormDataRequestContent : RequestContent
- {
- private readonly System.Net.Http.MultipartFormDataContent _multipartContent;
- private static readonly Random _random = new Random();
- private static readonly char[] _boundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".ToCharArray();
-
- public MultipartFormDataRequestContent()
- {
- _multipartContent = new System.Net.Http.MultipartFormDataContent(CreateBoundary());
- }
-
- public string ContentType
- {
- get
- {
- return _multipartContent.Headers.ContentType.ToString();
- }
- }
-
- internal HttpContent HttpContent => _multipartContent;
-
- private static string CreateBoundary()
- {
- Span chars = new char[70];
- byte[] random = new byte[70];
- _random.NextBytes(random);
- int mask = 255 >> 2;
- for (int i = 0; i < 70; i++)
- {
- chars[i] = _boundaryValues[random[i] & mask];
- }
- return chars.ToString();
- }
-
- public void Add(string content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- Add(new StringContent(content), name, filename, contentType);
- }
-
- public void Add(int content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- string value = content.ToString("G", CultureInfo.InvariantCulture);
- Add(new StringContent(value), name, filename, contentType);
- }
-
- public void Add(long content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- string value = content.ToString("G", CultureInfo.InvariantCulture);
- Add(new StringContent(value), name, filename, contentType);
- }
-
- public void Add(float content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- string value = content.ToString("G", CultureInfo.InvariantCulture);
- Add(new StringContent(value), name, filename, contentType);
- }
-
- public void Add(double content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- string value = content.ToString("G", CultureInfo.InvariantCulture);
- Add(new StringContent(value), name, filename, contentType);
- }
-
- public void Add(decimal content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- string value = content.ToString("G", CultureInfo.InvariantCulture);
- Add(new StringContent(value), name, filename, contentType);
- }
-
- public void Add(bool content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- string value = content ? "true" : "false";
- Add(new StringContent(value), name, filename, contentType);
- }
-
- public void Add(Stream content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- Add(new StreamContent(content), name, filename, contentType);
- }
-
- public void Add(byte[] content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- Add(new ByteArrayContent(content), name, filename, contentType);
- }
-
- public void Add(BinaryData content, string name, string filename = null, string contentType = null)
- {
- Argument.AssertNotNull(content, nameof(content));
- Argument.AssertNotNullOrEmpty(name, nameof(name));
-
- Add(new ByteArrayContent(content.ToArray()), name, filename, contentType);
- }
-
- private void Add(HttpContent content, string name, string filename, string contentType)
- {
- if (filename != null)
- {
- Argument.AssertNotNullOrEmpty(filename, nameof(filename));
- AddFilenameHeader(content, name, filename);
- }
- if (contentType != null)
- {
- Argument.AssertNotNullOrEmpty(contentType, nameof(contentType));
- AddContentTypeHeader(content, contentType);
- }
- _multipartContent.Add(content, name);
- }
-
- public static void AddFilenameHeader(HttpContent content, string name, string filename)
- {
- ContentDispositionHeaderValue header = new ContentDispositionHeaderValue("form-data") { Name = name, FileName = filename };
- content.Headers.ContentDisposition = header;
- }
-
- public static void AddContentTypeHeader(HttpContent content, string contentType)
- {
- MediaTypeHeaderValue header = new MediaTypeHeaderValue(contentType);
- content.Headers.ContentType = header;
- }
-
- public override bool TryComputeLength(out long length)
- {
- if (_multipartContent.Headers.ContentLength is long contentLength)
- {
- length = contentLength;
- return true;
- }
- length = 0;
- return false;
- }
-
- public override void WriteTo(Stream stream, CancellationToken cancellationToken = default)
- {
-#if NET6_0_OR_GREATER
- _multipartContent.CopyTo(stream, default, cancellationToken);
-#else
-#pragma warning disable AZC0107
- _multipartContent.CopyToAsync(stream).EnsureCompleted();
-#pragma warning restore AZC0107
-#endif
- }
-
- public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default)
- {
-#if NET6_0_OR_GREATER
- await _multipartContent.CopyToAsync(stream, cancellationToken).ConfigureAwait(false);
-#else
- await _multipartContent.CopyToAsync(stream).ConfigureAwait(false);
-#endif
- }
-
- public override void Dispose()
- {
- _multipartContent.Dispose();
- }
- }
-}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/RequestContentHelper.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/RequestContentHelper.cs
deleted file mode 100644
index 482217bba2c2..000000000000
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/RequestContentHelper.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-// 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 Azure.Core;
-
-namespace Azure.Security.KeyVault.Administration
-{
- internal static class RequestContentHelper
- {
- public static RequestContent FromEnumerable(IEnumerable enumerable)
- where T : notnull
- {
- Utf8JsonRequestContent content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteStartArray();
- foreach (var item in enumerable)
- {
- content.JsonWriter.WriteObjectValue(item);
- }
- content.JsonWriter.WriteEndArray();
-
- return content;
- }
-
- public static RequestContent FromEnumerable(IEnumerable enumerable)
- {
- Utf8JsonRequestContent content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteStartArray();
- foreach (var item in enumerable)
- {
- if (item == null)
- {
- content.JsonWriter.WriteNullValue();
- }
- else
- {
-#if NET6_0_OR_GREATER
- content.JsonWriter.WriteRawValue(item);
-#else
- using (JsonDocument document = JsonDocument.Parse(item))
- {
- JsonSerializer.Serialize(content.JsonWriter, document.RootElement);
- }
-#endif
- }
- }
- content.JsonWriter.WriteEndArray();
-
- return content;
- }
-
- public static RequestContent FromEnumerable(ReadOnlySpan span)
- where T : notnull
- {
- Utf8JsonRequestContent content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteStartArray();
- for (int i = 0; i < span.Length; i++)
- {
- content.JsonWriter.WriteObjectValue(span[i]);
- }
- content.JsonWriter.WriteEndArray();
-
- return content;
- }
-
- public static RequestContent FromDictionary(IDictionary dictionary)
- where TValue : notnull
- {
- Utf8JsonRequestContent content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteStartObject();
- foreach (var item in dictionary)
- {
- content.JsonWriter.WritePropertyName(item.Key);
- content.JsonWriter.WriteObjectValue(item.Value);
- }
- content.JsonWriter.WriteEndObject();
-
- return content;
- }
-
- public static RequestContent FromDictionary(IDictionary dictionary)
- {
- Utf8JsonRequestContent content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteStartObject();
- foreach (var item in dictionary)
- {
- content.JsonWriter.WritePropertyName(item.Key);
- if (item.Value == null)
- {
- content.JsonWriter.WriteNullValue();
- }
- else
- {
-#if NET6_0_OR_GREATER
- content.JsonWriter.WriteRawValue(item.Value);
-#else
- using (JsonDocument document = JsonDocument.Parse(item.Value))
- {
- JsonSerializer.Serialize(content.JsonWriter, document.RootElement);
- }
-#endif
- }
- }
- content.JsonWriter.WriteEndObject();
-
- return content;
- }
-
- public static RequestContent FromObject(object value)
- {
- Utf8JsonRequestContent content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteObjectValue