public Optional<Provider> createProvider() {
if (accessKey.isEmpty() || secretKey.isEmpty()) {
return Optional.absent();
}
final ProviderBuilder builder = Provider.builder()
.id(AmazonProvisionr.ID)
.accessKey(accessKey)
.secretKey(secretKey);
if (!region.isEmpty()) {
builder.option("region", region);
}
if (endpoint.isEmpty()) {
builder.endpoint(Optional.<String>absent());
} else {
builder.endpoint(endpoint);
}
return Optional.of(builder.createProvider());
}