My goal is to check google orchestrator and api computing engine by first getting a list of active instances. The orchestra project, including the servlet file, is stored in the bank.
I am trying to check the java client of Google Engine Engine. I have a cron job that invokes an orchestra servlet. The purpose of cron is the backend. From which I am trying to get a list of instances:
... AppIdentityCredential credential = getCredential(computeScope); String appName = ConfigProperties.getInstance().getGceConfigProperties().get("projectId"); try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); final Compute compute = new Compute.Builder( httpTransport, JSON_FACTORY, credential).setApplicationName(appName) .build(); logger.info("================== Listing Compute Engine Instances =================="); Compute.Instances.List instances = compute.instances().list(projectId, zone); InstanceList list = instances.execute(); if (list.getItems() == null) { logger.info("No instances found. Sign in to the Google APIs Console and create " + "an instance at: code.google.com/apis/console"); } else { for (Instance instance : list.getItems()) { logger.info(instance.toPrettyString()); } } ...
I get an error message (I omitted my project name from the answer, I confirmed that I am using the correct project identifier in my code):
com.google.cloud.solutions.sampleapps.orchestration.orchestrator.server.GceClientApiUtils getInstances: com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 OK { "code" : 404, "errors" : [ { "domain" : "global", "message" : "The resource 'projects/<project-name-here>' was not found", "reason" : "notFound" } ], "message" : "The resource 'projects/<project-name_here>' was not found" }
I also tried to do this by extracting the access token and making a RESTful call to get a list of instances, and I got the same answer. I confirmed that the built Url was correct by comparing it to a successful request for instances using api explorer.
EDIT: I solved the problem using another message: Finally, I was able to find the solution in the message Error API Compute Engine API with http 404
I needed to add my application engine service account as a member of a team with editing capabilities, which it is not specified by default. Once I did this, the code worked properly. I had to do this through cloud.google.com/console, as if it were done through appengine.google.com, the pending status would be granted to the service account and would not have access.