Requires authorization
Creates a persistent disk resource in the specified project using the data included in the request. You can create a persistent disk in three ways:
-
If you specify a
sourceImage
as an optional parameter in your request, a root persistent disk is created. The persistent boot disk has a minimum size of 10GB, which can be expanded if you specify thesizeGb
field as well. You must provide an image that has kernel binaries included. You cannot specify an image that refers to a Google-provided kernel (marked by the existence of thepreferrredKernel
on the Image resource for API versions v1beta16 and earlier). -
Specify
sizeGB
.If you specify a
sizeGb
without a source image or source snapshot, a non-root persistent disk with the specified size is created. -
Specify
sourceSnapshot
.If you specify a
sourceSnapshot
parameter, a persistent disk is created using the specified snapshot. You can also specify this with thesizeGb
option to create a larger disk. IfsizeGb
is not specified, the persistent disk size will be the same size as the original persistent disk from which the snapshot was created.
If you use the
sizeGb
field to create a larger persistent
disk than the original image or snapshot, you will need to either
repartition the persistent disk
(for root persistent disks), or
restore the snapshot to a larger size
(for non-root persistent disks created
from a snapshot).
Request
HTTP request
POST https://www.googleapis.com/compute/v1/projects/project/zones/zone/disks
Parameters
Parameter name | Value | Description |
---|---|---|
Path parameters | ||
project
|
string
|
Project ID of the project scoping this request. |
zone
|
string
|
Name of the zone scoping this request. |
Optional query parameters | ||
sourceImage
|
string
|
Fully-qualified URL for a source image to apply to the disk. |
Authorization
This request requires authorization with the following scope ( read more about authentication and authorization ).
Scope |
---|
https://www.googleapis.com/auth/compute
|
Request body
In the request body, supply a Disks resource with the following properties:
Property name | Value | Description | Notes |
---|---|---|---|
Required Properties | |||
name
|
string
|
Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with
RFC1035
.
Specifically, the name must be 1-63 characters long and match the regular expression
[a-z]([-a-z0-9]*[a-z0-9])?
which means
the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
|
|
If you didn't provide a
sourceImage
,
supply one or more of the following properties:
|
|||
sizeGb
|
long
|
Size of the persistent disk, specified in GB. You can also specify
this when creating a persistent disk using the
sourceImage
or
sourceSnapshot
parameter.
|
|
sourceSnapshot
|
string
|
The source snapshot used to create this disk. Once the source
snapshot has been deleted from the system, this field will be cleared,
and will not be set even if a snapshot with the same name has been
re-created. This parameter is required if
sourceImage
and
sizeGb
are not specified.
|
Response
If successful, this method returns a ZoneOperations resource in the response body.
{ "kind": "compute#operation", "id": unsigned long, "creationTimestamp": string, "name": string, "zone": string, "clientOperationId": string, "operationType": string, "targetLink": string, "targetId": unsigned long, "status": string, "statusMessage": string, "user": string, "progress": integer, "insertTime": string, "startTime": string, "endTime": string, "error": { "errors": [ { "code": string, "location": string, "message": string } ] }, "warnings": [ { "code": string, "message": string, "data": [ { "key": string, "value": string } ] } ], "httpErrorStatusCode": integer, "httpErrorMessage": string, "selfLink": string, "region": string }
Property name | Value | Description | Notes |
---|---|---|---|
clientOperationId
|
string
|
[Output Only] An optional identifier specified by the client when the mutation was initiated. Must be unique for all operation resources in the project. | |
creationTimestamp
|
string
|
[Output Only] Creation timestamp in RFC3339 text format. | |
endTime
|
string
|
[Output Only] The time that this operation was completed. This is in RFC3339 text format. | |
error
|
object
|
[Output Only] If errors occurred during processing of this operation, this field will be populated. | |
error.
errors[]
|
list
|
[Output Only] The array of errors encountered while processing this operation. | |
error.errors[].
code
|
string
|
[Output Only] The error type identifier for this error. | |
error.errors[].
location
|
string
|
[Output Only] Indicates the field in the request which caused the error. This property is optional. | |
error.errors[].
message
|
string
|
[Output Only] An optional, human-readable error message. | |
httpErrorMessage
|
string
|
[Output Only]
If operation fails, the HTTP error message returned, e.g.
NOT FOUND
.
|
|
httpErrorStatusCode
|
integer
|
[Output Only]
If operation fails, the HTTP error status code returned, e.g.
404
.
|
|
id
|
unsigned long
|
[Output Only] Unique identifier for the resource, generated by the server. | |
insertTime
|
string
|
[Output Only] The time that this operation was requested. This is in RFC3339 text format. | |
kind
|
string
|
[Output Only]
Type of the resource. Always
compute#operation
for Operation resources.
|
|
name
|
string
|
[Output Only] Name of the resource. | |
operationType
|
string
|
[Output Only]
Type of the operation. Operations include
insert
,
update
, and
delete
.
|
|
progress
|
integer
|
[Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the operation will be complete. This number should be monotonically increasing as the operation progresses. | |
region
|
string
|
[Output Only] URL of the region where the operation resides. Only available when performing regional operations. | |
selfLink
|
string
|
[Output Only] Server-defined fully-qualified URL for this resource. | |
startTime
|
string
|
[Output Only] The time that this operation was started by the server. This is in RFC3339 text format. | |
status
|
string
|
[Output Only]
Status of the operation.
Acceptable values are:
|
|
statusMessage
|
string
|
[Output Only] An optional textual description of the current status of the operation. | |
targetId
|
unsigned long
|
[Output Only] Unique target id which identifies a particular incarnation of the target. | |
targetLink
|
string
|
[Output Only] URL of the resource the operation is mutating. | |
user
|
string
|
[Output Only]
User who requested the operation, for example:
[email protected]
.
|
|
warnings[]
|
list
|
[Output Only] If there are issues with this operation, a warning is returned. | |
warnings[].
code
|
string
|
[Output Only]
The warning type identifier for this warning.
Acceptable values are:
|
|
warnings[].
data[]
|
list
|
[Output Only] Metadata for this warning in 'key: value' format. | |
warnings[].data[].
key
|
string
|
[Output Only] Metadata key for this warning. | |
warnings[].data[].
value
|
string
|
[Output Only] Metadata value for the specified key. | |
warnings[].
message
|
string
|
[Output Only] Optional human-readable details for this warning. | |
zone
|
string
|
[Output Only] URL of the zone where the operation resides. Only available when performing per-zone operations. |
Try it!
Use the APIs Explorer below to call this method on live data and see the response.