Search in sources :

Example 1 with KeyRestoreParameters

use of com.microsoft.azure.keyvault.models.KeyRestoreParameters in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method restoreKeyWithServiceResponseAsync.

/**
     * Restores a backed up key to a vault.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyBundleBackup The backup blob associated with a key bundle.
     * @return the observable to the KeyBundle object
     */
public Observable<ServiceResponse<KeyBundle>> restoreKeyWithServiceResponseAsync(String vaultBaseUrl, byte[] keyBundleBackup) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (keyBundleBackup == null) {
        throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null.");
    }
    KeyRestoreParameters parameters = new KeyRestoreParameters();
    parameters.withKeyBundleBackup(keyBundleBackup);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyBundle>>>() {

        @Override
        public Observable<ServiceResponse<KeyBundle>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<KeyBundle> clientResponse = restoreKeyDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyRestoreParameters(com.microsoft.azure.keyvault.models.KeyRestoreParameters) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyBundle(com.microsoft.azure.keyvault.models.KeyBundle) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

KeyBundle (com.microsoft.azure.keyvault.models.KeyBundle)1 KeyRestoreParameters (com.microsoft.azure.keyvault.models.KeyRestoreParameters)1 ServiceResponse (com.microsoft.rest.ServiceResponse)1 ResponseBody (okhttp3.ResponseBody)1 Response (retrofit2.Response)1 Observable (rx.Observable)1