Reputation: 14736
I'm not able to find a way to use the gcloud
command line program to change a project's Enabled APIs. My hunch is that it's going to be in the billing "arena" but I've been trying to find this and having much luck.
Upvotes: 19
Views: 22887
Reputation: 2205
You can also use this Google Cloud Console API https://cloud.google.com/service-usage/docs/reference/rest/v1/services/enable
Upvotes: 1
Reputation: 3120
Select the project where your application will be registered (see the docs about gcloud config set)
gcloud config set project myProject
To see a list of available services for a project, run:
gcloud services list --available
Enable service in the current project (see the docs about gcloud services enable)
gcloud services enable my-consumed-service
Upvotes: 1
Reputation: 991
Edit: This has been deprecated. See gcloud services
answer.
Check out the service-management
surface. See gcloud help service-management
for more help, as well as gcloud help service-management enable
for help about enabling new services. Use gcloud service-management list
to list available services so you can find the name of the service you want to enable.
Upvotes: 6
Reputation: 321
Use
gcloud services enable <service name>
Example:
gcloud services enable containerregistry.googleapis.com
Upvotes: 22
Reputation: 181
What worked for me for enabling container engine API -
gcloud services enable containerregistry.googleapis.com
Upvotes: 1
Reputation: 510
Issue For your current default project do gcloud service-management list --enabled to list all available APIs enabled.
$ gcloud service-management list --enabled
Listed 0 items.
If you see something like the above i.e 0 items , then you most likely will be getting the error below for some commands for the project.
ERROR: (gcloud.compute.machine-types.list) Some requests did not succeed:
- Project {PROJECT_ID} is not found and cannot be used for API calls
Solution What you need to do are the below
The output is quite lengthy so I suggest you use the global option page-size e.g
$ gcloud service-management list --available --page-size=10 --sort-by="NAME"
NAME TITLE
picker.googleapis.com Google Picker API
bigquery-json.googleapis.com BigQuery API
chromewebstore.googleapis.com Chrome Web Store API
tracing.googleapis.com Google Tracing API
youtube.googleapis.com YouTube Data API v3
actions.googleapis.com Google Actions API
dataflow.googleapis.com Google Dataflow API
serviceuser.googleapis.com Google Service User API
fusiontables.googleapis.com Fusion Tables API
surveys.googleapis.com Surveys API
NAME TITLE
reseller.googleapis.com Google Apps Reseller API
speech.googleapis.com Google Cloud Speech API
appsmarket-component.googleapis.com Google Apps Marketplace SDK
bigtabletableadmin.googleapis.com Google Cloud Bigtable Table Admin API
container.googleapis.com Google Container Engine API
vision.googleapis.com Google Cloud Vision API
storage-api.googleapis.com Google Cloud Storage JSON API
weavecompanion.googleapis.com Weave Companion API
ml.googleapis.com Google Cloud Machine Learning Engine
firebaserules.googleapis.com Firebase Rules API
...
Better still check specific available APIs you need e.g to check for the Google Compute Engine API that I want to enable
$ gcloud service-management list --available --filter='NAME:compute*'
NAME TITLE
compute-component.googleapis.com Google Compute Engine API
Enable Billing for the project .
$ gcloud alpha billing accounts projects link amghouse-some-project-1 --account-id=XXFFXX-B9XX37-2D5DX --format=json
{
"billingAccountName": "billingAccounts/XXFFXX-B9XX37-2D5DX",
"billingEnabled": true,
"name": "projects/amghouse-some-project-1 /billingInfo",
"projectId": "amghouse-some-project-1 "
}
Finally enable the api for your project
`
$gcloud service-management enable compute-component.googleapis.com
Waiting for async operation operations/projectSettings.c6d11ddc-915f-4d66-9b98-237e473e7682 to complete...
Operation finished successfully. The following command can describe the Operation details:
gcloud service-management operations describe operations/projectSettings.c6d11ddc-915f-4d66-9b98-237e473e7682
`
`
$ gcloud service-management operations describe operations/projectSettings.c6d11ddc-915f-4d66-9b98-237e473e7682 --format=json
{
"done": true,
"metadata": {
"@type": "type.googleapis.com/google.api.servicemanagement.v1.OperationMetadata",
"persisted": true,
"resourceNames": [
"services/compute-component.googleapis.com/projectSettings/"
],
"startTime": "2017-04-08 23:30:22 WAT"
},
"name": "operations/projectSettings.c6d11ddc-915f-4d66-9b98-237e473e7682",
"response": {
"@type": "type.googleapis.com/google.api.servicemanagement.v1.EnableServiceResponse"
}
}
`
Caution Please note without the project being linked to a billing info , an attempt to enable the api will fail with an error similar to
$ gcloud service-management enable compute-component.googleapis.com
ERROR: (gcloud.service-management.enable) FAILED_PRECONDITION: Operation does not satisfy the following requirements: billing-enabled {Billing must be enabled for activation of service '' in project 'amghouse-bct-sms-1' to proceed., https://console.developers.google.com/project/amghouse-bct-sms-1/settings}
Upvotes: 7