I'm trying to automate the entire process of project creation using the official Google SDK for Node.js. For project creation, I use the Resource Manager SDK:
const resource = new Resource();
const project = resource.project(projectName);
const [, operation,] = await project.create();
I also have to enable some services in order to use them in the process. When I run:
const client = new ServiceUsageClient();
const [operation] = await client.batchEnableServices({
parent: `projects/${projectId}`,
serviceIds: [
"apigateway.googleapis.com",
"servicecontrol.googleapis.com",
"servicemanagement.googleapis.com",
]
});
I receive:
Service Usage API has not been used in project 1014682171642 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/serviceusage.googleapis.com/overview?project=1014682171642 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
I find it suspicious that Service Usage API isn't enabled by default when I create a project via API. Obviously, it takes the benefit of using APIs if I had to enable something manually. When I create a project via Could Console, Service Usage API is enabled by default, so this issue affects only the API. Maybe there's some other way to enable Service Usage API programmatically.
I would appreciate any form of help.