Beispiel #1
0
        /// <summary>
        /// Creates an instance of a RestoreOperation from a previously started operation. <see cref="UpdateStatus(CancellationToken)"/>, <see cref="UpdateStatusAsync(CancellationToken)"/>,
        ///  <see cref="WaitForCompletionAsync(CancellationToken)"/>, or <see cref="WaitForCompletionAsync(TimeSpan, CancellationToken)"/> must be called
        /// to re-populate the details of this operation.
        /// </summary>
        /// <param name="id">The <see cref="Id" /> from a previous <see cref="BackupOperation" />.</param>
        /// <param name="client">An instance of <see cref="KeyVaultBackupClient" />.</param>
        /// <exception cref="ArgumentNullException"><paramref name="id"/> or <paramref name="client"/> is null.</exception>
        public RestoreOperation(string id, KeyVaultBackupClient client)
        {
            Argument.AssertNotNull(id, nameof(id));
            Argument.AssertNotNull(client, nameof(client));

            _client = client;
            _value  = new FullRestoreDetailsInternal(string.Empty, string.Empty, null, id, null, null);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of a RestoreOperation for mocking purposes.
        /// </summary>
        /// <param name="value">The <see cref="FullRestoreDetailsInternal" /> that will be used to populate various properties.</param>
        /// <param name="response">The <see cref="Response" /> that will be returned from <see cref="GetRawResponse" />.</param>
        /// <param name="client">An instance of <see cref="KeyVaultBackupClient" />.</param>
        internal RestoreOperation(FullRestoreDetailsInternal value, Response response, KeyVaultBackupClient client)
        {
            Argument.AssertNotNull(value, nameof(value));
            Argument.AssertNotNull(response, nameof(response));
            Argument.AssertNotNull(client, nameof(client));

            _client   = client;
            _response = response;
            _value    = value;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of a RestoreOperation.
        /// </summary>
        /// <param name="client">An instance of <see cref="KeyVaultBackupClient" />.</param>
        /// <param name="response">The <see cref="ResponseWithHeaders{T, THeaders}" /> returned from <see cref="KeyVaultBackupClient.StartRestore(Uri, string, string, CancellationToken)"/> or <see cref="KeyVaultBackupClient.StartRestoreAsync(Uri, string, string, CancellationToken)"/>.</param>
        internal RestoreOperation(KeyVaultBackupClient client, ResponseWithHeaders <FullRestoreDetailsInternal, ServiceFullRestoreOperationHeaders> response)
        {
            Argument.AssertNotNull(client, nameof(client));
            Argument.AssertNotNull(response, nameof(response));

            _value             = response.Value ?? throw new InvalidOperationException("The response does not contain a value.");
            _client            = client;
            _response          = response.GetRawResponse();
            _retryAfterSeconds = response.Headers.RetryAfter;
        }
Beispiel #4
0
        /// <inheritdoc/>
        public override Response UpdateStatus(CancellationToken cancellationToken = default)
        {
            if (!HasCompleted)
            {
                Response <FullRestoreDetailsInternal> response = _client.GetRestoreDetails(Id, cancellationToken);
                _value    = response.Value;
                _response = response.GetRawResponse();
            }

            return(GetRawResponse());
        }
Beispiel #5
0
        /// <inheritdoc/>
        public override async ValueTask <Response> UpdateStatusAsync(CancellationToken cancellationToken = default)
        {
            if (!HasCompleted)
            {
                Response <FullRestoreDetailsInternal> response = await _client.GetRestoreDetailsAsync(Id, cancellationToken).ConfigureAwait(false);

                _value    = response.Value;
                _response = response.GetRawResponse();
            }

            return(GetRawResponse());
        }