use of com.microsoft.azure.keyvault.models.SecretAttributes 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.
* @return the observable to the SecretBundle object
*/
public Observable<ServiceResponse<SecretBundle>> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion) {
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.");
}
final String contentType = null;
final SecretAttributes secretAttributes = null;
final Map<String, String> tags = null;
SecretUpdateParameters parameters = new SecretUpdateParameters();
parameters.withContentType(null);
parameters.withSecretAttributes(null);
parameters.withTags(null);
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);
}
}
});
}
use of com.microsoft.azure.keyvault.models.SecretAttributes 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.
* @return the observable to the SecretBundle object
*/
public Observable<ServiceResponse<SecretBundle>> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value) {
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.");
}
final Map<String, String> tags = null;
final String contentType = null;
final SecretAttributes secretAttributes = null;
SecretSetParameters parameters = new SecretSetParameters();
parameters.withValue(value);
parameters.withTags(null);
parameters.withContentType(null);
parameters.withSecretAttributes(null);
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);
}
}
});
}
use of com.microsoft.azure.keyvault.models.SecretAttributes in project azure-sdk-for-java by Azure.
the class SecretOperationsTest method disabledSecretGet.
@Test
public // verifies the inner error on disabled secret
void disabledSecretGet() throws Exception {
String secretName = "disabledsecret";
SecretBundle secret = keyVaultClient.setSecret(new SetSecretRequest.Builder(getVaultUri(), secretName, SECRET_VALUE).withAttributes(new SecretAttributes().withEnabled(false)).build());
try {
keyVaultClient.getSecret(secret.id());
Assert.fail("Should throw exception for disabled secret.");
} catch (KeyVaultErrorException e) {
Assert.assertEquals(e.body().error().code(), "Forbidden");
Assert.assertNotNull(e.body().error().message());
Assert.assertNotNull(e.body().error().innerError());
Assert.assertEquals(e.body().error().innerError().code(), "SecretDisabled");
} catch (Exception e) {
Assert.fail("Should throw KeyVaultErrorException for disabled secret.");
}
keyVaultClient.deleteSecret(getVaultUri(), secretName);
}
Aggregations