I'm trying to create an API to manage API Keys from inside a VM instance, so I'm looking for a programmatic and/or using Google REST APIS way to create, delete and list Google Cloud API Management Credentials, especially API KEYs.
With Google Cloud SDK you can create and API keys with the following command("gcloud alpha services api-keys" docs):
$ gcloud alpha services api-keys create --display-name="test name"
After carefully searching through the Google's Cloud documentation I haven't found a way of programmatic(example 1) nor using a cURL(example 2) to call Google API to manage API Keys.
Example 1 of creating bucket in a programmatic way:
from google.cloud import storage
def create_bucket_class_location(bucket_name):
"""Create a new bucket in specific location with storage class"""
# bucket_name = "your-new-bucket-name"
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
bucket.storage_class = "COLDLINE"
new_bucket = storage_client.create_bucket(bucket, location="us")
print(
"Created bucket {} in {} with storage class {}".format(
new_bucket.name, new_bucket.location, new_bucket.storage_class
)
)
return new_bucket
Example 2 of creating bucket using REST APIs:
curl -X POST --data-binary @create-bucket.json \
-H "Authorization: Bearer OAUTH2_TOKEN" \
-H "Content-Type: application/json" \
"https://storage.googleapis.com/storage/v1/b?project=PROJECT_ID"