I am trying to implement a method to programmatically start and stop google compute instances using com.google.cloud.compute.v1
library.
The issue I am currently fighting is this:
...
Caused by: java.lang.NoSuchMethodError: 'boolean com.google.cloud.compute.v1.StopInstanceRequest.hasDiscardLocalSsd()'
...
The function is:
private fun stopInstance( zone: String, instanceName: String) : Boolean{
val project = Helpers.getProperties("PROJECT_ID")
val instancesClient:InstancesClient = InstancesClient.create()
val stopInstanceRequest = StopInstanceRequest.newBuilder()
.setProject(project)
.setZone(zone)
.setInstance(instanceName)
.build()
val operation: OperationFuture<Operation, Operation> = instancesClient.stopAsync(
stopInstanceRequest)
val response = operation.get(3, TimeUnit.MINUTES)
return if (operation.isDone && response.status == Operation.Status.DONE) {
println("Instance stopped successfully! ${response.status}")
true
} else {
println("Instance failed to stop. ${response.status}")
false
}
}
My question is these:
1- From where is hasDiscardLocalSsd()
called?
2- where in the library should this function be located.
I am using google-cloud-compute v 1.18.0
I hav tried reading the reference.
To get this to work you need the right version of the library and libraries-bom from maven.