Search in sources :

Example 96 with Call

use of retrofit2.Call 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 97 with Call

use of retrofit2.Call 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 98 with Call

use of retrofit2.Call 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 99 with Call

use of retrofit2.Call 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)

Example 100 with Call

use of retrofit2.Call in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method updateSecretWithServiceResponseAsync.

/**
     * Updates the attributes associated with a specified secret in a given key vault.
     *
     * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
     * @param secretName The name of the secret.
     * @param secretVersion The version of the secret.
     * @param contentType Type of the secret value such as a password.
     * @param secretAttributes The secret management attributes.
     * @param tags Application specific metadata in the form of key-value pairs.
     * @return the observable to the SecretBundle object
     */
public Observable<ServiceResponse<SecretBundle>> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map<String, String> tags) {
    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 (secretVersion == null) {
        throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null.");
    }
    if (this.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
    }
    Validator.validate(secretAttributes);
    Validator.validate(tags);
    SecretUpdateParameters parameters = new SecretUpdateParameters();
    parameters.withContentType(contentType);
    parameters.withSecretAttributes(secretAttributes);
    parameters.withTags(tags);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.updateSecret(secretName, secretVersion, 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 = updateSecretDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) SecretBundle(com.microsoft.azure.keyvault.models.SecretBundle) ServiceResponse(com.microsoft.rest.ServiceResponse) SecretUpdateParameters(com.microsoft.azure.keyvault.models.SecretUpdateParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

ResponseBody (okhttp3.ResponseBody)189 Request (okhttp3.Request)176 Test (org.junit.Test)155 Call (okhttp3.Call)127 Response (retrofit2.Response)107 Response (okhttp3.Response)105 Observable (rx.Observable)94 ServiceResponse (com.microsoft.rest.ServiceResponse)92 IOException (java.io.IOException)72 MockResponse (okhttp3.mockwebserver.MockResponse)67 RequestBody (okhttp3.RequestBody)51 Callback (okhttp3.Callback)44 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)34 OkHttpClient (okhttp3.OkHttpClient)33 ToStringConverterFactory (retrofit2.helpers.ToStringConverterFactory)27 Buffer (okio.Buffer)19 Call (retrofit2.Call)19 MultipartBody (okhttp3.MultipartBody)17 HttpUrl (okhttp3.HttpUrl)15 Callback (retrofit2.Callback)15