I am creating disk using python3. While try to create a disk, I am using the below config for body. I am able to create a disk if I am not using "type": "pd-standard" or "type": "pd-ssd":
config = {
"name": "mytestdisk",
"description": "this disk is created using python code",
"sizeGb": '1',
"type": "pd-standard",
"zone": zone
}
But when using "type": "pd-standard" or "type": "pd-ssd" I am getting the below error:
Traceback (most recent call last):
File "C:/Users/myuser/PycharmProjects/pythonProject/cretedisk.py", line 31, in <module>
print(create_disk(compute, project, zone))
File "C:/Users/myuser/PycharmProjects/pythonProject/cretedisk.py", line 24, in create_disk
return compute.disks().insert(
File "C:\Users\myuser\PycharmProjects\pythonProject\venv\lib\site-packages\googleapiclient\_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\myuser\PycharmProjects\pythonProject\venv\lib\site-packages\googleapiclient\http.py", line 907, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://compute.googleapis.com/compute/v1/projects/superman/zones/us-central1-a/disks?alt=json returned "Invalid value for field 'resource.type': 'pd-standard'. The URL is malformed.">
The url should be
'type': 'https://www.googleapis.com/compute/v1/projects/superman/zones/us-central1-a/diskTypes/pd-standard',
'type': 'https://www.googleapis.com/compute/v1/projects/superman/zones/us-central1-a/diskTypes/pd-ssd'
I am not sure why it is trying the incorrect url:
https://compute.googleapis.com/compute/v1/projects/superman/zones/us-central1-a/disks
To me it looks like there is a bug in the library. Has anyone tried and faced such issue or have a solution to this error?
Thanks