diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationClientOptions.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationClientOptions.cs
new file mode 100644
index 000000000000..18762c0d5b6d
--- /dev/null
+++ b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/AzureSecurityKeyVaultAdministrationClientOptions.cs
@@ -0,0 +1,40 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.Security.KeyVault.Administration
+{
+ /// Client options for Azure.Security.KeyVault.Administration library clients.
+ public partial class AzureSecurityKeyVaultAdministrationClientOptions : ClientOptions
+ {
+ private const ServiceVersion LatestVersion = ServiceVersion.V7_6_Preview_2;
+
+ /// The version of the service to use.
+ public enum ServiceVersion
+ {
+ /// Service version "7.5".
+ V7_5 = 1,
+ /// Service version "7.6-preview.2".
+ V7_6_Preview_2 = 2,
+ }
+
+ internal string Version { get; }
+
+ /// Initializes new instance of AzureSecurityKeyVaultAdministrationClientOptions.
+ public AzureSecurityKeyVaultAdministrationClientOptions(ServiceVersion version = LatestVersion)
+ {
+ Version = version switch
+ {
+ ServiceVersion.V7_5 => "7.5",
+ ServiceVersion.V7_6_Preview_2 => "7.6-preview.2",
+ _ => throw new NotSupportedException()
+ };
+ }
+ }
+}
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
index b30181ba2e98..64b67aef6bbc 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/BackupRestoreRestClient.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/BackupRestoreRestClient.cs
@@ -6,7 +6,6 @@
#nullable disable
using System;
-using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
@@ -15,252 +14,869 @@
namespace Azure.Security.KeyVault.Administration
{
+ // Data plane generated client.
+ /// The BackupRestoreRest service client.
internal partial class BackupRestoreRestClient
{
+ private static readonly string[] AuthorizationScopes = new string[] { "https://vault.azure.net/.default" };
+ private readonly TokenCredential _tokenCredential;
private readonly HttpPipeline _pipeline;
+ private readonly Uri _endpoint;
private readonly string _apiVersion;
/// The ClientDiagnostics is used to provide tracing support for the client library.
internal ClientDiagnostics ClientDiagnostics { get; }
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ public virtual HttpPipeline Pipeline => _pipeline;
+
+ /// Initializes a new instance of BackupRestoreRestClient for mocking.
+ protected BackupRestoreRestClient()
+ {
+ }
+
/// 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")
+ /// The to use.
+ /// A credential used to authenticate to an Azure Service.
+ /// or is null.
+ public BackupRestoreRestClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureSecurityKeyVaultAdministrationClientOptions())
{
- 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)
+ /// Initializes a new instance of BackupRestoreRestClient.
+ /// The to use.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// or is null.
+ public BackupRestoreRestClient(Uri endpoint, TokenCredential credential, AzureSecurityKeyVaultAdministrationClientOptions options)
{
- 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)
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new AzureSecurityKeyVaultAdministrationClientOptions();
+
+ ClientDiagnostics = new ClientDiagnostics(options, true);
+ _tokenCredential = credential;
+ _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
+ _endpoint = endpoint;
+ _apiVersion = options.Version;
+ }
+
+ /// Returns the status of full backup operation.
+ /// The id returned as part of the backup request.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> FullBackupStatusAsync(string jobId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await FullBackupStatusAsync(jobId, context).ConfigureAwait(false);
+ return Response.FromValue(FullBackupDetailsInternal.FromResponse(response), response);
+ }
+
+ /// Returns the status of full backup operation.
+ /// The id returned as part of the backup request.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response FullBackupStatus(string jobId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = FullBackupStatus(jobId, context);
+ return Response.FromValue(FullBackupDetailsInternal.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Returns the status of full backup operation
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The id returned as part of the backup request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task FullBackupStatusAsync(string jobId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.FullBackupStatus");
+ scope.Start();
+ try
{
- request.Headers.Add("Content-Type", "application/json");
- var content = new Utf8JsonRequestContent();
- content.JsonWriter.WriteObjectValue(azureStorageBlobContainerUri);
- request.Content = content;
+ using HttpMessage message = CreateFullBackupStatusRequest(jobId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
}
- 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.
+ ///
+ /// [Protocol Method] Returns the status of full backup operation
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The id returned as part of the backup request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response FullBackupStatus(string jobId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.FullBackupStatus");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateFullBackupStatusRequest(jobId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Returns the status of restore operation.
+ /// The Job Id returned part of the restore operation.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> RestoreStatusAsync(string jobId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await RestoreStatusAsync(jobId, context).ConfigureAwait(false);
+ return Response.FromValue(RestoreDetailsInternal.FromResponse(response), response);
+ }
+
+ /// Returns the status of restore operation.
+ /// The Job Id returned part of the restore operation.
/// The cancellation token to use.
- /// is null.
- public async Task> FullBackupAsync(string vaultBaseUrl, SASTokenParameter azureStorageBlobContainerUri = null, CancellationToken cancellationToken = default)
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response RestoreStatus(string jobId, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = RestoreStatus(jobId, context);
+ return Response.FromValue(RestoreDetailsInternal.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Returns the status of restore operation
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The Job Id returned part of the restore operation.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual async Task RestoreStatusAsync(string jobId, RequestContext context)
{
- if (vaultBaseUrl == null)
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.RestoreStatus");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRestoreStatusRequest(jobId, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
{
- throw new ArgumentNullException(nameof(vaultBaseUrl));
+ scope.Failed(e);
+ throw;
}
+ }
- using var message = CreateFullBackupRequest(vaultBaseUrl, azureStorageBlobContainerUri);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- var headers = new AzureSecurityKeyVaultAdministrationFullBackupHeaders(message.Response);
- switch (message.Response.Status)
+ ///
+ /// [Protocol Method] Returns the status of restore operation
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// The Job Id returned part of the restore operation.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ ///
+ public virtual Response RestoreStatus(string jobId, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(jobId, nameof(jobId));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.RestoreStatus");
+ scope.Start();
+ try
{
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
+ using HttpMessage message = CreateRestoreStatusRequest(jobId, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
}
}
/// 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.
+ /// 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.
/// 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)
+ /// is null.
+ ///
+ public virtual async Task> FullBackupAsync(WaitUntil waitUntil, SASTokenParameter azureStorageBlobContainerUri, CancellationToken cancellationToken = default)
{
- if (vaultBaseUrl == null)
+ Argument.AssertNotNull(azureStorageBlobContainerUri, nameof(azureStorageBlobContainerUri));
+
+ using RequestContent content = azureStorageBlobContainerUri.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = await FullBackupAsync(waitUntil, content, context).ConfigureAwait(false);
+ return ProtocolOperationHelpers.Convert(response, FullBackupDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.FullBackup");
+ }
+
+ /// Creates a full backup using a user-provided SAS token to an Azure blob storage container.
+ /// 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.
+ /// 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 virtual Operation FullBackup(WaitUntil waitUntil, SASTokenParameter azureStorageBlobContainerUri, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(azureStorageBlobContainerUri, nameof(azureStorageBlobContainerUri));
+
+ using RequestContent content = azureStorageBlobContainerUri.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = FullBackup(waitUntil, content, context);
+ return ProtocolOperationHelpers.Convert(response, FullBackupDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.FullBackup");
+ }
+
+ ///
+ /// [Protocol Method] Creates a full backup using a user-provided SAS token to an Azure blob storage container.
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual async Task> FullBackupAsync(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.FullBackup");
+ scope.Start();
+ try
{
- throw new ArgumentNullException(nameof(vaultBaseUrl));
+ using HttpMessage message = CreateFullBackupRequest(content, context);
+ return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.FullBackup", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil).ConfigureAwait(false);
}
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Creates a full backup using a user-provided SAS token to an Azure blob storage container.
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual Operation FullBackup(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
- using var message = CreateFullBackupRequest(vaultBaseUrl, azureStorageBlobContainerUri);
- _pipeline.Send(message, cancellationToken);
- var headers = new AzureSecurityKeyVaultAdministrationFullBackupHeaders(message.Response);
- switch (message.Response.Status)
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.FullBackup");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateFullBackupRequest(content, context);
+ return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.FullBackup", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil);
+ }
+ catch (Exception e)
{
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
+ scope.Failed(e);
+ throw;
}
}
- internal HttpMessage CreateFullBackupStatusRequest(string vaultBaseUrl, string jobId)
+ /// Pre-backup operation for checking whether the customer can perform a full backup operation.
+ /// 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.
+ /// Optional parameters to validate prior to performing a full backup operation.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual async Task> PreFullBackupAsync(WaitUntil waitUntil, PreBackupOperationParameters preBackupOperationParameters, CancellationToken cancellationToken = default)
{
- 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;
+ Argument.AssertNotNull(preBackupOperationParameters, nameof(preBackupOperationParameters));
+
+ using RequestContent content = preBackupOperationParameters.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = await PreFullBackupAsync(waitUntil, content, context).ConfigureAwait(false);
+ return ProtocolOperationHelpers.Convert(response, FullBackupDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.PreFullBackup");
}
- /// 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.
+ /// Pre-backup operation for checking whether the customer can perform a full backup operation.
+ /// 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.
+ /// Optional parameters to validate prior to performing a full backup operation.
/// The cancellation token to use.
- /// or is null.
- public async Task> FullBackupStatusAsync(string vaultBaseUrl, string jobId, CancellationToken cancellationToken = default)
+ /// is null.
+ ///
+ public virtual Operation PreFullBackup(WaitUntil waitUntil, PreBackupOperationParameters preBackupOperationParameters, CancellationToken cancellationToken = default)
{
- if (vaultBaseUrl == null)
+ Argument.AssertNotNull(preBackupOperationParameters, nameof(preBackupOperationParameters));
+
+ using RequestContent content = preBackupOperationParameters.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = PreFullBackup(waitUntil, content, context);
+ return ProtocolOperationHelpers.Convert(response, FullBackupDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.PreFullBackup");
+ }
+
+ ///
+ /// [Protocol Method] Pre-backup operation for checking whether the customer can perform a full backup operation.
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual async Task> PreFullBackupAsync(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.PreFullBackup");
+ scope.Start();
+ try
{
- throw new ArgumentNullException(nameof(vaultBaseUrl));
+ using HttpMessage message = CreatePreFullBackupRequest(content, context);
+ return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.PreFullBackup", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil).ConfigureAwait(false);
}
- if (jobId == null)
+ catch (Exception e)
{
- throw new ArgumentNullException(nameof(jobId));
+ scope.Failed(e);
+ throw;
}
+ }
+
+ ///
+ /// [Protocol Method] Pre-backup operation for checking whether the customer can perform a full backup operation.
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual Operation PreFullBackup(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
- using var message = CreateFullBackupStatusRequest(vaultBaseUrl, jobId);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- switch (message.Response.Status)
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.PreFullBackup");
+ scope.Start();
+ try
{
- 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);
+ using HttpMessage message = CreatePreFullBackupRequest(content, context);
+ return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.PreFullBackup", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
}
}
- /// 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.
+ /// Pre-restore operation for checking whether the customer can perform a full restore operation.
+ /// 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.
+ /// Optional pre restore parameters to validate prior to performing a full restore operation.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual async Task> PreFullRestoreOperationAsync(WaitUntil waitUntil, PreRestoreOperationParameters preRestoreOperationParameters, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(preRestoreOperationParameters, nameof(preRestoreOperationParameters));
+
+ using RequestContent content = preRestoreOperationParameters.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = await PreFullRestoreOperationAsync(waitUntil, content, context).ConfigureAwait(false);
+ return ProtocolOperationHelpers.Convert(response, RestoreDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.PreFullRestoreOperation");
+ }
+
+ /// Pre-restore operation for checking whether the customer can perform a full restore operation.
+ /// 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.
+ /// Optional pre restore parameters to validate prior to performing a full restore operation.
/// The cancellation token to use.
- /// or is null.
- public Response FullBackupStatus(string vaultBaseUrl, string jobId, CancellationToken cancellationToken = default)
+ /// is null.
+ ///
+ public virtual Operation PreFullRestoreOperation(WaitUntil waitUntil, PreRestoreOperationParameters preRestoreOperationParameters, CancellationToken cancellationToken = default)
{
- if (vaultBaseUrl == null)
+ Argument.AssertNotNull(preRestoreOperationParameters, nameof(preRestoreOperationParameters));
+
+ using RequestContent content = preRestoreOperationParameters.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = PreFullRestoreOperation(waitUntil, content, context);
+ return ProtocolOperationHelpers.Convert(response, RestoreDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.PreFullRestoreOperation");
+ }
+
+ ///
+ /// [Protocol Method] Pre-restore operation for checking whether the customer can perform a full restore operation.
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual async Task> PreFullRestoreOperationAsync(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.PreFullRestoreOperation");
+ scope.Start();
+ try
{
- throw new ArgumentNullException(nameof(vaultBaseUrl));
+ using HttpMessage message = CreatePreFullRestoreOperationRequest(content, context);
+ return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.PreFullRestoreOperation", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil).ConfigureAwait(false);
}
- if (jobId == null)
+ catch (Exception e)
{
- throw new ArgumentNullException(nameof(jobId));
+ scope.Failed(e);
+ throw;
}
+ }
+
+ ///
+ /// [Protocol Method] Pre-restore operation for checking whether the customer can perform a full restore operation.
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual Operation PreFullRestoreOperation(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
- using var message = CreateFullBackupStatusRequest(vaultBaseUrl, jobId);
- _pipeline.Send(message, cancellationToken);
- switch (message.Response.Status)
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.PreFullRestoreOperation");
+ scope.Start();
+ try
{
- 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);
+ using HttpMessage message = CreatePreFullRestoreOperationRequest(content, context);
+ return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.PreFullRestoreOperation", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
}
}
- internal HttpMessage CreateFullRestoreOperationRequest(string vaultBaseUrl, RestoreOperationParameters restoreBlobDetails)
+ /// Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage backup folder.
+ /// 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 Azure blob SAS token pointing to a folder where the previous successful full backup was stored.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ public virtual async Task> FullRestoreOperationAsync(WaitUntil waitUntil, RestoreOperationParameters restoreBlobDetails, CancellationToken cancellationToken = default)
{
- 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;
+ Argument.AssertNotNull(restoreBlobDetails, nameof(restoreBlobDetails));
+
+ using RequestContent content = restoreBlobDetails.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = await FullRestoreOperationAsync(waitUntil, content, context).ConfigureAwait(false);
+ return ProtocolOperationHelpers.Convert(response, RestoreDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.FullRestoreOperation");
}
/// 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.
+ /// 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 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)
+ /// is null.
+ ///
+ public virtual Operation FullRestoreOperation(WaitUntil waitUntil, RestoreOperationParameters restoreBlobDetails, CancellationToken cancellationToken = default)
{
- if (vaultBaseUrl == null)
+ Argument.AssertNotNull(restoreBlobDetails, nameof(restoreBlobDetails));
+
+ using RequestContent content = restoreBlobDetails.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = FullRestoreOperation(waitUntil, content, context);
+ return ProtocolOperationHelpers.Convert(response, RestoreDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.FullRestoreOperation");
+ }
+
+ ///
+ /// [Protocol Method] Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage backup folder
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual async Task> FullRestoreOperationAsync(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.FullRestoreOperation");
+ scope.Start();
+ try
{
- throw new ArgumentNullException(nameof(vaultBaseUrl));
+ using HttpMessage message = CreateFullRestoreOperationRequest(content, context);
+ return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.FullRestoreOperation", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil).ConfigureAwait(false);
}
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Restores all key materials using the SAS token pointing to a previously stored Azure Blob storage backup folder
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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 content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual Operation FullRestoreOperation(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
- using var message = CreateFullRestoreOperationRequest(vaultBaseUrl, restoreBlobDetails);
- await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
- var headers = new AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders(message.Response);
- switch (message.Response.Status)
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.FullRestoreOperation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateFullRestoreOperationRequest(content, context);
+ return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.FullRestoreOperation", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil);
+ }
+ catch (Exception e)
{
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
+ scope.Failed(e);
+ throw;
}
}
- /// 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.
+ /// Restores all key versions of a given key using user supplied SAS token pointing to a previously stored Azure Blob storage backup folder.
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The name of the 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.
- /// is null.
- public ResponseWithHeaders FullRestoreOperation(string vaultBaseUrl, RestoreOperationParameters restoreBlobDetails = null, CancellationToken cancellationToken = default)
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> SelectiveKeyRestoreOperationAsync(WaitUntil waitUntil, string keyName, SelectiveKeyRestoreOperationParameters restoreBlobDetails, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
+ Argument.AssertNotNull(restoreBlobDetails, nameof(restoreBlobDetails));
+
+ using RequestContent content = restoreBlobDetails.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = await SelectiveKeyRestoreOperationAsync(waitUntil, keyName, content, context).ConfigureAwait(false);
+ return ProtocolOperationHelpers.Convert(response, SelectiveKeyRestoreDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.SelectiveKeyRestoreOperation");
+ }
+
+ /// Restores all key versions of a given key using user supplied SAS token pointing to a previously stored Azure Blob storage backup folder.
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The name of the 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.
+ /// is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Operation SelectiveKeyRestoreOperation(WaitUntil waitUntil, string keyName, SelectiveKeyRestoreOperationParameters restoreBlobDetails, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
+ Argument.AssertNotNull(restoreBlobDetails, nameof(restoreBlobDetails));
+
+ using RequestContent content = restoreBlobDetails.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = SelectiveKeyRestoreOperation(waitUntil, keyName, content, context);
+ return ProtocolOperationHelpers.Convert(response, SelectiveKeyRestoreDetailsInternal.FromResponse, ClientDiagnostics, "BackupRestoreRestClient.SelectiveKeyRestoreOperation");
+ }
+
+ ///
+ /// [Protocol Method] Restores all key versions of a given key using user supplied SAS token pointing to a previously stored Azure Blob storage backup folder
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The name of the key to be restored from the user supplied backup.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual async Task> SelectiveKeyRestoreOperationAsync(WaitUntil waitUntil, string keyName, RequestContent content, RequestContext context = null)
{
- if (vaultBaseUrl == null)
+ Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.SelectiveKeyRestoreOperation");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateSelectiveKeyRestoreOperationRequest(keyName, content, context);
+ return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.SelectiveKeyRestoreOperation", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil).ConfigureAwait(false);
+ }
+ catch (Exception e)
{
- throw new ArgumentNullException(nameof(vaultBaseUrl));
+ scope.Failed(e);
+ throw;
}
+ }
+
+ ///
+ /// [Protocol Method] Restores all key versions of a given key using user supplied SAS token pointing to a previously stored Azure Blob storage backup folder
+ ///
+ ///
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ ///
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The name of the key to be restored from the user supplied backup.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ public virtual Operation SelectiveKeyRestoreOperation(WaitUntil waitUntil, string keyName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
+ Argument.AssertNotNull(content, nameof(content));
- using var message = CreateFullRestoreOperationRequest(vaultBaseUrl, restoreBlobDetails);
- _pipeline.Send(message, cancellationToken);
- var headers = new AzureSecurityKeyVaultAdministrationFullRestoreOperationHeaders(message.Response);
- switch (message.Response.Status)
+ using var scope = ClientDiagnostics.CreateScope("BackupRestoreRestClient.SelectiveKeyRestoreOperation");
+ scope.Start();
+ try
{
- case 202:
- return ResponseWithHeaders.FromValue(headers, message.Response);
- default:
- throw new RequestFailedException(message.Response);
+ using HttpMessage message = CreateSelectiveKeyRestoreOperationRequest(keyName, content, context);
+ return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "BackupRestoreRestClient.SelectiveKeyRestoreOperation", OperationFinalStateVia.AzureAsyncOperation, context, waitUntil);
}
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ internal HttpMessage CreateFullBackupRequest(RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier202);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/backup", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
}
- internal HttpMessage CreateRestoreStatusRequest(string vaultBaseUrl, string jobId)
+ internal HttpMessage CreateFullBackupStatusRequest(string jobId, RequestContext context)
{
- var message = _pipeline.CreateMessage();
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
var request = message.Request;
request.Method = RequestMethod.Get;
var uri = new RawRequestUriBuilder();
- uri.AppendRaw(vaultBaseUrl, false);
- uri.AppendPath("/restore/", false);
+ uri.Reset(_endpoint);
+ uri.AppendPath("/backup/", false);
uri.AppendPath(jobId, true);
uri.AppendPath("/pending", false);
uri.AppendQuery("api-version", _apiVersion, true);
@@ -269,149 +885,102 @@ internal HttpMessage CreateRestoreStatusRequest(string vaultBaseUrl, string jobI
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)
+ internal HttpMessage CreatePreFullBackupRequest(RequestContent content, RequestContext context)
{
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (jobId == null)
- {
- throw new ArgumentNullException(nameof(jobId));
- }
+ var message = _pipeline.CreateMessage(context, ResponseClassifier202);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/prebackup", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
- 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);
- }
+ internal HttpMessage CreateRestoreStatusRequest(string jobId, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Get;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ 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 Response RestoreStatus(string vaultBaseUrl, string jobId, CancellationToken cancellationToken = default)
+ internal HttpMessage CreatePreFullRestoreOperationRequest(RequestContent content, RequestContext context)
{
- if (vaultBaseUrl == null)
- {
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (jobId == null)
- {
- throw new ArgumentNullException(nameof(jobId));
- }
+ var message = _pipeline.CreateMessage(context, ResponseClassifier202);
+ var request = message.Request;
+ request.Method = RequestMethod.Put;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/prerestore", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
- 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 CreateFullRestoreOperationRequest(RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier202);
+ var request = message.Request;
+ request.Method = RequestMethod.Put;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/restore", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
}
- internal HttpMessage CreateSelectiveKeyRestoreOperationRequest(string vaultBaseUrl, string keyName, SelectiveKeyRestoreOperationParameters restoreBlobDetails)
+ internal HttpMessage CreateSelectiveKeyRestoreOperationRequest(string keyName, RequestContent content, RequestContext context)
{
- var message = _pipeline.CreateMessage();
+ var message = _pipeline.CreateMessage(context, ResponseClassifier202);
var request = message.Request;
request.Method = RequestMethod.Put;
var uri = new RawRequestUriBuilder();
- uri.AppendRaw(vaultBaseUrl, false);
+ uri.Reset(_endpoint);
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;
- }
+ request.Headers.Add("Content-Type", "application/json");
+ 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)
+ private static RequestContext DefaultRequestContext = new RequestContext();
+ internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default)
{
- if (vaultBaseUrl == null)
+ if (!cancellationToken.CanBeCanceled)
{
- throw new ArgumentNullException(nameof(vaultBaseUrl));
- }
- if (keyName == null)
- {
- throw new ArgumentNullException(nameof(keyName));
+ return DefaultRequestContext;
}
- 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);
- }
+ return new RequestContext() { CancellationToken = cancellationToken };
}
- /// 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);
- }
- }
+ private static ResponseClassifier _responseClassifier202;
+ private static ResponseClassifier ResponseClassifier202 => _responseClassifier202 ??= new StatusCodeClassifier(stackalloc ushort[] { 202 });
+ private static ResponseClassifier _responseClassifier200;
+ private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 });
}
}
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/BackupRestoreRestClient.xml b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/BackupRestoreRestClient.xml
new file mode 100644
index 000000000000..97e20544fb77
--- /dev/null
+++ b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/BackupRestoreRestClient.xml
@@ -0,0 +1,499 @@
+
+
+
+
+
+This sample shows how to call FullBackupStatusAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = await client.FullBackupStatusAsync("45aacd568ab049a2803861e8dd3ae21f");
+]]>
+
+
+
+This sample shows how to call FullBackupStatus.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = client.FullBackupStatus("45aacd568ab049a2803861e8dd3ae21f");
+]]>
+
+
+
+This sample shows how to call FullBackupStatusAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = await client.FullBackupStatusAsync("45aacd568ab049a2803861e8dd3ae21f", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call FullBackupStatus and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = client.FullBackupStatus("45aacd568ab049a2803861e8dd3ae21f", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call RestoreStatusAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = await client.RestoreStatusAsync("45aacd568ab049a2803861e8dd3ae21f");
+]]>
+
+
+
+This sample shows how to call RestoreStatus.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = client.RestoreStatus("45aacd568ab049a2803861e8dd3ae21f");
+]]>
+
+
+
+This sample shows how to call RestoreStatusAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = await client.RestoreStatusAsync("45aacd568ab049a2803861e8dd3ae21f", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call RestoreStatus and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+Response response = client.RestoreStatus("45aacd568ab049a2803861e8dd3ae21f", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call FullBackupAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+SASTokenParameter azureStorageBlobContainerUri = new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+{
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+};
+Operation operation = await client.FullBackupAsync(WaitUntil.Completed, azureStorageBlobContainerUri);
+FullBackupDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call FullBackup.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+SASTokenParameter azureStorageBlobContainerUri = new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+{
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+};
+Operation operation = client.FullBackup(WaitUntil.Completed, azureStorageBlobContainerUri);
+FullBackupDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call FullBackupAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+});
+Operation operation = await client.FullBackupAsync(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call FullBackup and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+});
+Operation operation = client.FullBackup(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call PreFullBackupAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+PreBackupOperationParameters preBackupOperationParameters = new PreBackupOperationParameters
+{
+ StorageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+};
+Operation operation = await client.PreFullBackupAsync(WaitUntil.Completed, preBackupOperationParameters);
+FullBackupDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call PreFullBackup.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+PreBackupOperationParameters preBackupOperationParameters = new PreBackupOperationParameters
+{
+ StorageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+};
+Operation operation = client.PreFullBackup(WaitUntil.Completed, preBackupOperationParameters);
+FullBackupDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call PreFullBackupAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+});
+Operation operation = await client.PreFullBackupAsync(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call PreFullBackup and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+});
+Operation operation = client.PreFullBackup(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call PreFullRestoreOperationAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+PreRestoreOperationParameters preRestoreOperationParameters = new PreRestoreOperationParameters
+{
+ SasTokenParameters = new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+ {
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ FolderToRestore = "mhsm-mypool-20200303062926785",
+};
+Operation operation = await client.PreFullRestoreOperationAsync(WaitUntil.Completed, preRestoreOperationParameters);
+RestoreDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call PreFullRestoreOperation.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+PreRestoreOperationParameters preRestoreOperationParameters = new PreRestoreOperationParameters
+{
+ SasTokenParameters = new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+ {
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ FolderToRestore = "mhsm-mypool-20200303062926785",
+};
+Operation operation = client.PreFullRestoreOperation(WaitUntil.Completed, preRestoreOperationParameters);
+RestoreDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call PreFullRestoreOperationAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ sasTokenParameters = new
+ {
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ folderToRestore = "mhsm-mypool-20200303062926785",
+});
+Operation operation = await client.PreFullRestoreOperationAsync(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call PreFullRestoreOperation and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ sasTokenParameters = new
+ {
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ folderToRestore = "mhsm-mypool-20200303062926785",
+});
+Operation operation = client.PreFullRestoreOperation(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call FullRestoreOperationAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+RestoreOperationParameters restoreBlobDetails = new RestoreOperationParameters(new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+{
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+}, "mhsm-mypool-20200303062926785");
+Operation operation = await client.FullRestoreOperationAsync(WaitUntil.Completed, restoreBlobDetails);
+RestoreDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call FullRestoreOperation.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+RestoreOperationParameters restoreBlobDetails = new RestoreOperationParameters(new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+{
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+}, "mhsm-mypool-20200303062926785");
+Operation operation = client.FullRestoreOperation(WaitUntil.Completed, restoreBlobDetails);
+RestoreDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call FullRestoreOperationAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ sasTokenParameters = new
+ {
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ folderToRestore = "mhsm-mypool-20200303062926785",
+});
+Operation operation = await client.FullRestoreOperationAsync(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call FullRestoreOperation and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ sasTokenParameters = new
+ {
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ folderToRestore = "mhsm-mypool-20200303062926785",
+});
+Operation operation = client.FullRestoreOperation(WaitUntil.Completed, content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call SelectiveKeyRestoreOperationAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+SelectiveKeyRestoreOperationParameters restoreBlobDetails = new SelectiveKeyRestoreOperationParameters(new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+{
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+}, "mhsm-mypool-20200303062926785");
+Operation operation = await client.SelectiveKeyRestoreOperationAsync(WaitUntil.Completed, "hsm-mail-key", restoreBlobDetails);
+SelectiveKeyRestoreDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call SelectiveKeyRestoreOperation.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+SelectiveKeyRestoreOperationParameters restoreBlobDetails = new SelectiveKeyRestoreOperationParameters(new SASTokenParameter("https://myaccount.blob.core.windows.net/sascontainer/sasContainer")
+{
+ Token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+}, "mhsm-mypool-20200303062926785");
+Operation operation = client.SelectiveKeyRestoreOperation(WaitUntil.Completed, "hsm-mail-key", restoreBlobDetails);
+SelectiveKeyRestoreDetailsInternal responseData = operation.Value;
+]]>
+
+
+
+This sample shows how to call SelectiveKeyRestoreOperationAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ sasTokenParameters = new
+ {
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ folder = "mhsm-mypool-20200303062926785",
+});
+Operation operation = await client.SelectiveKeyRestoreOperationAsync(WaitUntil.Completed, "hsm-mail-key", content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call SelectiveKeyRestoreOperation and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+BackupRestoreRestClient client = new BackupRestoreRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ sasTokenParameters = new
+ {
+ storageResourceUri = "https://myaccount.blob.core.windows.net/sascontainer/sasContainer",
+ token = "se=2018-02-01T00%3A00Z&spr=https&sv=2017-04-17&sr=b&sig=REDACTED",
+ },
+ folder = "mhsm-mypool-20200303062926785",
+});
+Operation operation = client.SelectiveKeyRestoreOperation(WaitUntil.Completed, "hsm-mail-key", content);
+BinaryData responseData = operation.Value;
+
+JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
\ No newline at end of file
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/RoleAssignmentsRestClient.xml b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/RoleAssignmentsRestClient.xml
new file mode 100644
index 000000000000..38fe33126fae
--- /dev/null
+++ b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/RoleAssignmentsRestClient.xml
@@ -0,0 +1,229 @@
+
+
+
+
+
+This sample shows how to call DeleteAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = await client.DeleteAsync("keys", "roleAssignmentName");
+]]>
+
+
+
+This sample shows how to call Delete.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = client.Delete("keys", "roleAssignmentName");
+]]>
+
+
+
+This sample shows how to call DeleteAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = await client.DeleteAsync("keys", "roleAssignmentName", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call Delete and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = client.Delete("keys", "roleAssignmentName", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call CreateAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters(new KeyVaultRoleAssignmentPropertiesInternal("/keys/providers/Microsoft.Authorization/roleDefinitions/roleDefinitionId", "principalId"));
+Response response = await client.CreateAsync("keys", "roleAssignmentName", parameters);
+]]>
+
+
+
+This sample shows how to call Create.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+RoleAssignmentCreateParameters parameters = new RoleAssignmentCreateParameters(new KeyVaultRoleAssignmentPropertiesInternal("/keys/providers/Microsoft.Authorization/roleDefinitions/roleDefinitionId", "principalId"));
+Response response = client.Create("keys", "roleAssignmentName", parameters);
+]]>
+
+
+
+This sample shows how to call CreateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ properties = new
+ {
+ roleDefinitionId = "/keys/providers/Microsoft.Authorization/roleDefinitions/roleDefinitionId",
+ principalId = "principalId",
+ },
+});
+Response response = await client.CreateAsync("keys", "roleAssignmentName", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call Create and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ properties = new
+ {
+ roleDefinitionId = "/keys/providers/Microsoft.Authorization/roleDefinitions/roleDefinitionId",
+ principalId = "principalId",
+ },
+});
+Response response = client.Create("keys", "roleAssignmentName", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call GetRoleAssignmentsRestClientAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = await client.GetRoleAssignmentsRestClientAsync("keys", "roleAssignmentName");
+]]>
+
+
+
+This sample shows how to call GetRoleAssignmentsRestClient.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = client.GetRoleAssignmentsRestClient("keys", "roleAssignmentName");
+]]>
+
+
+
+This sample shows how to call GetRoleAssignmentsRestClientAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = await client.GetRoleAssignmentsRestClientAsync("keys", "roleAssignmentName", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call GetRoleAssignmentsRestClient and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+Response response = client.GetRoleAssignmentsRestClient("keys", "roleAssignmentName", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call GetForScopesAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+await foreach (Models.KeyVaultRoleAssignment item in client.GetForScopesAsync("keys"))
+{
+}
+]]>
+
+
+
+This sample shows how to call GetForScopes.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+foreach (Models.KeyVaultRoleAssignment item in client.GetForScopes("keys"))
+{
+}
+]]>
+
+
+
+This sample shows how to call GetForScopesAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+await foreach (BinaryData item in client.GetForScopesAsync("keys", null, null))
+{
+ JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
+ Console.WriteLine(result.ToString());
+}
+]]>
+
+
+
+This sample shows how to call GetForScopes and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleAssignmentsRestClient client = new RoleAssignmentsRestClient(endpoint, credential);
+
+foreach (BinaryData item in client.GetForScopes("keys", null, null))
+{
+ JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
+ Console.WriteLine(result.ToString());
+}
+]]>
+
+
+
\ No newline at end of file
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/RoleDefinitionsRestClient.xml b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/RoleDefinitionsRestClient.xml
new file mode 100644
index 000000000000..f61d1467c73b
--- /dev/null
+++ b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/RoleDefinitionsRestClient.xml
@@ -0,0 +1,269 @@
+
+
+
+
+
+This sample shows how to call DeleteAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = await client.DeleteAsync("/", "00000000-0000-0000-0000-000000000000");
+]]>
+
+
+
+This sample shows how to call Delete.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = client.Delete("/", "00000000-0000-0000-0000-000000000000");
+]]>
+
+
+
+This sample shows how to call DeleteAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = await client.DeleteAsync("/", "00000000-0000-0000-0000-000000000000", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call Delete and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = client.Delete("/", "00000000-0000-0000-0000-000000000000", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call CreateOrUpdateAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+RoleDefinitionCreateParameters parameters = new RoleDefinitionCreateParameters(new RoleDefinitionProperties
+{
+ RoleName = "My custom role",
+ Description = "Role description",
+ RoleType = Models.KeyVaultRoleType.CustomRole,
+ Permissions = {new Models.KeyVaultPermission
+ {
+ DataActions = {Models.KeyVaultDataAction.SignHsmKey},
+ }},
+});
+Response response = await client.CreateOrUpdateAsync("keys", "00000000-0000-0000-0000-000000000000", parameters);
+]]>
+
+
+
+This sample shows how to call CreateOrUpdate.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+RoleDefinitionCreateParameters parameters = new RoleDefinitionCreateParameters(new RoleDefinitionProperties
+{
+ RoleName = "My custom role",
+ Description = "Role description",
+ RoleType = Models.KeyVaultRoleType.CustomRole,
+ Permissions = {new Models.KeyVaultPermission
+ {
+ DataActions = {Models.KeyVaultDataAction.SignHsmKey},
+ }},
+});
+Response response = client.CreateOrUpdate("keys", "00000000-0000-0000-0000-000000000000", parameters);
+]]>
+
+
+
+This sample shows how to call CreateOrUpdateAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ properties = new
+ {
+ roleName = "My custom role",
+ type = "CustomRole",
+ description = "Role description",
+ permissions = new object[]
+ {
+ new
+ {
+ dataActions = new object[]
+ {
+ "Microsoft.KeyVault/managedHsm/keys/sign/action"
+ },
+ }
+ },
+ },
+});
+Response response = await client.CreateOrUpdateAsync("keys", "00000000-0000-0000-0000-000000000000", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call CreateOrUpdate and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ properties = new
+ {
+ roleName = "My custom role",
+ type = "CustomRole",
+ description = "Role description",
+ permissions = new object[]
+ {
+ new
+ {
+ dataActions = new object[]
+ {
+ "Microsoft.KeyVault/managedHsm/keys/sign/action"
+ },
+ }
+ },
+ },
+});
+Response response = client.CreateOrUpdate("keys", "00000000-0000-0000-0000-000000000000", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClientAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = await client.GetRoleDefinitionsRestClientAsync("/", "00000000-0000-0000-0000-000000000000");
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClient.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = client.GetRoleDefinitionsRestClient("/", "00000000-0000-0000-0000-000000000000");
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClientAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = await client.GetRoleDefinitionsRestClientAsync("/", "00000000-0000-0000-0000-000000000000", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClient and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+Response response = client.GetRoleDefinitionsRestClient("/", "00000000-0000-0000-0000-000000000000", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClientsAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+await foreach (KeyVaultRoleDefinition item in client.GetRoleDefinitionsRestClientsAsync("keys"))
+{
+}
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClients.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+foreach (KeyVaultRoleDefinition item in client.GetRoleDefinitionsRestClients("keys"))
+{
+}
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClientsAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+await foreach (BinaryData item in client.GetRoleDefinitionsRestClientsAsync("keys", null, null))
+{
+ JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
+ Console.WriteLine(result.ToString());
+}
+]]>
+
+
+
+This sample shows how to call GetRoleDefinitionsRestClients and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+RoleDefinitionsRestClient client = new RoleDefinitionsRestClient(endpoint, credential);
+
+foreach (BinaryData item in client.GetRoleDefinitionsRestClients("keys", null, null))
+{
+ JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
+ Console.WriteLine(result.ToString());
+}
+]]>
+
+
+
\ No newline at end of file
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/SettingsRestClient.xml b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/SettingsRestClient.xml
new file mode 100644
index 000000000000..fdb35776fd12
--- /dev/null
+++ b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Docs/SettingsRestClient.xml
@@ -0,0 +1,187 @@
+
+
+
+
+
+This sample shows how to call UpdateSettingAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ value = "true",
+});
+Response response = await client.UpdateSettingAsync("AllowKeyManagementOperationsThroughARM", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("name").ToString());
+Console.WriteLine(result.GetProperty("value").ToString());
+]]>
+
+
+
+This sample shows how to call UpdateSetting and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ value = "true",
+});
+Response response = client.UpdateSetting("AllowKeyManagementOperationsThroughARM", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("name").ToString());
+Console.WriteLine(result.GetProperty("value").ToString());
+]]>
+
+
+
+This sample shows how to call GetSettingAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = await client.GetSettingAsync("");
+]]>
+This sample shows how to call GetSettingAsync with all parameters.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = await client.GetSettingAsync("");
+]]>
+
+
+
+This sample shows how to call GetSetting.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = client.GetSetting("");
+]]>
+This sample shows how to call GetSetting with all parameters.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = client.GetSetting("");
+]]>
+
+
+
+This sample shows how to call GetSettingAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = await client.GetSettingAsync("", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("name").ToString());
+Console.WriteLine(result.GetProperty("value").ToString());
+]]>
+This sample shows how to call GetSettingAsync with all parameters and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = await client.GetSettingAsync("", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("name").ToString());
+Console.WriteLine(result.GetProperty("value").ToString());
+Console.WriteLine(result.GetProperty("type").ToString());
+]]>
+
+
+
+This sample shows how to call GetSetting and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = client.GetSetting("", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("name").ToString());
+Console.WriteLine(result.GetProperty("value").ToString());
+]]>
+This sample shows how to call GetSetting with all parameters and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = client.GetSetting("", null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("name").ToString());
+Console.WriteLine(result.GetProperty("value").ToString());
+Console.WriteLine(result.GetProperty("type").ToString());
+]]>
+
+
+
+This sample shows how to call GetSettingsAsync.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = await client.GetSettingsAsync();
+]]>
+
+
+
+This sample shows how to call GetSettings.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = client.GetSettings();
+]]>
+
+
+
+This sample shows how to call GetSettingsAsync and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = await client.GetSettingsAsync(null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
+This sample shows how to call GetSettings and parse the result.
+");
+TokenCredential credential = new DefaultAzureCredential();
+SettingsRestClient client = new SettingsRestClient(endpoint, credential);
+
+Response response = client.GetSettings(null);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.ToString());
+]]>
+
+
+
\ No newline at end of file
diff --git a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/ModelSerializationExtensions.cs
index 796908fd5bd5..9467bd96eb1d 100644
--- a/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/ModelSerializationExtensions.cs
+++ b/sdk/keyvault/Azure.Security.KeyVault.Administration/src/Generated/Internal/ModelSerializationExtensions.cs
@@ -167,13 +167,16 @@ public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset v
writer.WriteNumberValue(value.ToUnixTimeSeconds());
}
- public static void WriteObjectValue(this Utf8JsonWriter writer, T value)
+ public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null)
{
switch (value)
{
case null:
writer.WriteNullValue();
break;
+ case IJsonModel jsonModel:
+ jsonModel.Write(writer, options ?? WireOptions);
+ break;
case IUtf8JsonSerializable serializable:
serializable.Write(writer);
break;
@@ -228,7 +231,7 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value)
foreach (var pair in enumerable)
{
writer.WritePropertyName(pair.Key);
- writer.WriteObjectValue