I'm probably very confused with the API concepts but I'm not understanding how to use REST Google API with Python.
On the API documentation, it said to use HTTP Requests or client libs (in case of Python, libcloud or Google API Python Client Library. I saw examples for some functionalities that work well like, create VMs or attaching disks.
Although, I could not find an example pure REST request, like, if I want to create a scheduled snapshot.
So I have two questions:
- How to use libs to authenticate and call a function that the lib doesn't have a built-in method (like schedule snapshots)?
According to documentation, should be a request like this:
https://compute.googleapis.com/compute/v1/projects/{PROJECT_ID}/regions/{REGION_ID}/resourcePolicies
{
"name": "name",
"snapshotSchedulePolicy": {
"schedule": {
"dailySchedule": {
"startTime": "12:00",
"daysInCycle": "1"
}
},
"retentionPolicy": {
"maxRetentionDays": "5"
},
"snapshotProperties": {
"guestFlush": "False",
"labels": {
"env": "dev",
"media": "images"
},
"storageLocations": ["US"]
}
}
- Can I use the API, inside a Cloud Functions, without worrying to get a Token?
Someone can help me understand this better?
Thanks in advance