Search in sources :

Example 1 with ServiceResponse

use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method decryptWithServiceResponseAsync.

/**
     * Decrypts a single block of encrypted data.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name of the key.
     * @param keyVersion The version of the key.
     * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'
     * @param value the Base64Url value
     * @return the observable to the KeyOperationResult object
     */
public Observable<ServiceResponse<KeyOperationResult>> decryptWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (keyName == null) {
        throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
    }
    if (keyVersion == null) {
        throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (algorithm == null) {
        throw new IllegalArgumentException("Parameter algorithm is required and cannot be null.");
    }
    if (value == null) {
        throw new IllegalArgumentException("Parameter value is required and cannot be null.");
    }
    KeyOperationsParameters parameters = new KeyOperationsParameters();
    parameters.withAlgorithm(algorithm);
    parameters.withValue(value);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<KeyOperationResult>>>() {

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

Example 2 with ServiceResponse

use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method setSecretWithServiceResponseAsync.

/**
     * Sets a secret in a specified key vault.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param secretName The name of the secret.
     * @param value The value of the secret.
     * @param tags Application specific metadata in the form of key-value pairs.
     * @param contentType Type of the secret value such as a password.
     * @param secretAttributes The secret management attributes.
     * @return the observable to the SecretBundle object
     */
public Observable<ServiceResponse<SecretBundle>> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value, Map<String, String> tags, String contentType, SecretAttributes secretAttributes) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (secretName == null) {
        throw new IllegalArgumentException("Parameter secretName is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (value == null) {
        throw new IllegalArgumentException("Parameter value is required and cannot be null.");
    }
    Validator.validate(tags);
    Validator.validate(secretAttributes);
    SecretSetParameters parameters = new SecretSetParameters();
    parameters.withValue(value);
    parameters.withTags(tags);
    parameters.withContentType(contentType);
    parameters.withSecretAttributes(secretAttributes);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<SecretBundle>>>() {

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

Example 3 with ServiceResponse

use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method importKeyWithServiceResponseAsync.

/**
     * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName Name for the imported key.
     * @param key The Json web key
     * @param hsm Whether to import as a hardware key (HSM) or software key.
     * @param keyAttributes The key management attributes.
     * @param tags Application specific metadata in the form of key-value pairs.
     * @return the observable to the KeyBundle object
     */
public Observable<ServiceResponse<KeyBundle>> importKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map<String, String> tags) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (keyName == null) {
        throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    if (key == null) {
        throw new IllegalArgumentException("Parameter key is required and cannot be null.");
    }
    Validator.validate(key);
    Validator.validate(keyAttributes);
    Validator.validate(tags);
    KeyImportParameters parameters = new KeyImportParameters();
    parameters.withHsm(hsm);
    parameters.withKey(key);
    parameters.withKeyAttributes(keyAttributes);
    parameters.withTags(tags);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.importKey(keyName, 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 = importKeyDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyBundle(com.microsoft.azure.keyvault.models.KeyBundle) KeyImportParameters(com.microsoft.azure.keyvault.models.KeyImportParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 4 with ServiceResponse

use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method updateKeyWithServiceResponseAsync.

/**
     * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param keyName The name of key to update.
     * @param keyVersion The version of the key to update.
     * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation.
     * @param keyAttributes the KeyAttributes value
     * @param tags Application specific metadata in the form of key-value pairs.
     * @return the observable to the KeyBundle object
     */
public Observable<ServiceResponse<KeyBundle>> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, List<JsonWebKeyOperation> keyOps, KeyAttributes keyAttributes, Map<String, String> tags) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (keyName == null) {
        throw new IllegalArgumentException("Parameter keyName is required and cannot be null.");
    }
    if (keyVersion == null) {
        throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    Validator.validate(keyOps);
    Validator.validate(keyAttributes);
    Validator.validate(tags);
    KeyUpdateParameters parameters = new KeyUpdateParameters();
    parameters.withKeyOps(keyOps);
    parameters.withKeyAttributes(keyAttributes);
    parameters.withTags(tags);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.updateKey(keyName, keyVersion, 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 = updateKeyDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) KeyBundle(com.microsoft.azure.keyvault.models.KeyBundle) KeyUpdateParameters(com.microsoft.azure.keyvault.models.KeyUpdateParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 5 with ServiceResponse

use of com.microsoft.rest.ServiceResponse in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method createCertificateWithServiceResponseAsync.

/**
     * Creates a new certificate. If this is the first version, the certificate resource is created.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param certificateName The name of the certificate.
     * @param certificatePolicy The management policy for the certificate.
     * @param certificateAttributes The attributes of the certificate (optional).
     * @param tags Application specific metadata in the form of key-value pairs.
     * @return the observable to the CertificateOperation object
     */
public Observable<ServiceResponse<CertificateOperation>> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map<String, String> tags) {
    if (vaultBaseUrl == null) {
        throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.");
    }
    if (certificateName == null) {
        throw new IllegalArgumentException("Parameter certificateName is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    Validator.validate(certificatePolicy);
    Validator.validate(certificateAttributes);
    Validator.validate(tags);
    CertificateCreateParameters parameters = new CertificateCreateParameters();
    parameters.withCertificatePolicy(certificatePolicy);
    parameters.withCertificateAttributes(certificateAttributes);
    parameters.withTags(tags);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<CertificateOperation>>>() {

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

Aggregations

ServiceResponse (com.microsoft.rest.ServiceResponse)147 Response (retrofit2.Response)147 ResponseBody (okhttp3.ResponseBody)107 Observable (rx.Observable)107 TypeToken (com.google.common.reflect.TypeToken)40 VirtualMachineScaleSetVMInstanceIDs (com.microsoft.azure.management.compute.VirtualMachineScaleSetVMInstanceIDs)16 Product (fixtures.lro.models.Product)14 SubProduct (fixtures.lro.models.SubProduct)9 Page (com.microsoft.azure.Page)8 KeyBundle (com.microsoft.azure.keyvault.models.KeyBundle)7 CertificateBundle (com.microsoft.azure.keyvault.models.CertificateBundle)6 RegenerateKeysParameters (com.microsoft.azure.management.servicebus.RegenerateKeysParameters)6 CertificateAttributes (com.microsoft.azure.keyvault.models.CertificateAttributes)4 IssuerBundle (com.microsoft.azure.keyvault.models.IssuerBundle)4 KeyOperationResult (com.microsoft.azure.keyvault.models.KeyOperationResult)4 SecretBundle (com.microsoft.azure.keyvault.models.SecretBundle)4 CsmPublishingProfileOptions (com.microsoft.azure.management.appservice.CsmPublishingProfileOptions)4 FailoverPolicies (com.microsoft.azure.management.documentdb.FailoverPolicies)4 RoleAssignmentCreateParameters (com.microsoft.azure.management.graphrbac.RoleAssignmentCreateParameters)4 Product (fixtures.paging.models.Product)4