Skip to content

Create a Custom Image

client.GPUDroplets.Images.New(ctx, body) (*GPUDropletImageNewResponse, error)
post/v2/images

To create a new custom image, send a POST request to /v2/images. The body must contain a url attribute pointing to a Linux virtual machine image to be imported into DigitalOcean. The image must be in the raw, qcow2, vhdx, vdi, or vmdk format. It may be compressed using gzip or bzip2 and must be smaller than 100 GB after being decompressed.

ParametersExpand Collapse
body GPUDropletImageNewParams
Description param.Field[string]optional

An optional free-form text field to describe an image.

Distribution param.Field[GPUDropletImageNewParamsDistribution]optional

The name of a custom image's distribution. Currently, the valid values are Arch Linux, CentOS, CoreOS, Debian, Fedora, Fedora Atomic, FreeBSD, Gentoo, openSUSE, RancherOS, Rocky Linux, Ubuntu, and Unknown. Any other value will be accepted but ignored, and Unknown will be used in its place.

const GPUDropletImageNewParamsDistributionArchLinux GPUDropletImageNewParamsDistribution = "Arch Linux"
const GPUDropletImageNewParamsDistributionCentOs GPUDropletImageNewParamsDistribution = "CentOS"
const GPUDropletImageNewParamsDistributionCoreOs GPUDropletImageNewParamsDistribution = "CoreOS"
const GPUDropletImageNewParamsDistributionDebian GPUDropletImageNewParamsDistribution = "Debian"
const GPUDropletImageNewParamsDistributionFedora GPUDropletImageNewParamsDistribution = "Fedora"
const GPUDropletImageNewParamsDistributionFedoraAtomic GPUDropletImageNewParamsDistribution = "Fedora Atomic"
const GPUDropletImageNewParamsDistributionFreeBsd GPUDropletImageNewParamsDistribution = "FreeBSD"
const GPUDropletImageNewParamsDistributionGentoo GPUDropletImageNewParamsDistribution = "Gentoo"
const GPUDropletImageNewParamsDistributionOpenSuse GPUDropletImageNewParamsDistribution = "openSUSE"
const GPUDropletImageNewParamsDistributionRancherOs GPUDropletImageNewParamsDistribution = "RancherOS"
const GPUDropletImageNewParamsDistributionRockyLinux GPUDropletImageNewParamsDistribution = "Rocky Linux"
const GPUDropletImageNewParamsDistributionUbuntu GPUDropletImageNewParamsDistribution = "Ubuntu"
const GPUDropletImageNewParamsDistributionUnknown GPUDropletImageNewParamsDistribution = "Unknown"
Name param.Field[string]optional

The display name that has been given to an image. This is what is shown in the control panel and is generally a descriptive title for the image in question.

Region param.Field[GPUDropletImageNewParamsRegion]optional

The slug identifier for the region where the resource will initially be available.

const GPUDropletImageNewParamsRegionAms1 GPUDropletImageNewParamsRegion = "ams1"
const GPUDropletImageNewParamsRegionAms2 GPUDropletImageNewParamsRegion = "ams2"
const GPUDropletImageNewParamsRegionAms3 GPUDropletImageNewParamsRegion = "ams3"
const GPUDropletImageNewParamsRegionBlr1 GPUDropletImageNewParamsRegion = "blr1"
const GPUDropletImageNewParamsRegionFra1 GPUDropletImageNewParamsRegion = "fra1"
const GPUDropletImageNewParamsRegionLon1 GPUDropletImageNewParamsRegion = "lon1"
const GPUDropletImageNewParamsRegionNyc1 GPUDropletImageNewParamsRegion = "nyc1"
const GPUDropletImageNewParamsRegionNyc2 GPUDropletImageNewParamsRegion = "nyc2"
const GPUDropletImageNewParamsRegionNyc3 GPUDropletImageNewParamsRegion = "nyc3"
const GPUDropletImageNewParamsRegionSfo1 GPUDropletImageNewParamsRegion = "sfo1"
const GPUDropletImageNewParamsRegionSfo2 GPUDropletImageNewParamsRegion = "sfo2"
const GPUDropletImageNewParamsRegionSfo3 GPUDropletImageNewParamsRegion = "sfo3"
const GPUDropletImageNewParamsRegionSgp1 GPUDropletImageNewParamsRegion = "sgp1"
const GPUDropletImageNewParamsRegionTor1 GPUDropletImageNewParamsRegion = "tor1"
const GPUDropletImageNewParamsRegionSyd1 GPUDropletImageNewParamsRegion = "syd1"
Tags param.Field[[]string]optional

A flat array of tag names as strings to be applied to the resource. Tag names may be for either existing or new tags.

Requires tag:create scope.

URL param.Field[string]optional

A URL from which the custom Linux virtual machine image may be retrieved. The image it points to must be in the raw, qcow2, vhdx, vdi, or vmdk format. It may be compressed using gzip or bzip2 and must be smaller than 100 GB after being decompressed.

ReturnsExpand Collapse
type GPUDropletImageNewResponse struct{…}
Image Imageoptional
ID int64optional

A unique number that can be used to identify and reference a specific image.

CreatedAt Timeoptional

A time value given in ISO8601 combined date and time format that represents when the image was created.

formatdate-time
Description stringoptional

An optional free-form text field to describe an image.

Distribution ImageDistributionoptional

The name of a custom image's distribution. Currently, the valid values are Arch Linux, CentOS, CoreOS, Debian, Fedora, Fedora Atomic, FreeBSD, Gentoo, openSUSE, RancherOS, Rocky Linux, Ubuntu, and Unknown. Any other value will be accepted but ignored, and Unknown will be used in its place.

Accepts one of the following:
const ImageDistributionArchLinux ImageDistribution = "Arch Linux"
const ImageDistributionCentOs ImageDistribution = "CentOS"
const ImageDistributionCoreOs ImageDistribution = "CoreOS"
const ImageDistributionDebian ImageDistribution = "Debian"
const ImageDistributionFedora ImageDistribution = "Fedora"
const ImageDistributionFedoraAtomic ImageDistribution = "Fedora Atomic"
const ImageDistributionFreeBsd ImageDistribution = "FreeBSD"
const ImageDistributionGentoo ImageDistribution = "Gentoo"
const ImageDistributionOpenSuse ImageDistribution = "openSUSE"
const ImageDistributionRancherOs ImageDistribution = "RancherOS"
const ImageDistributionRockyLinux ImageDistribution = "Rocky Linux"
const ImageDistributionUbuntu ImageDistribution = "Ubuntu"
const ImageDistributionUnknown ImageDistribution = "Unknown"
ErrorMessage stringoptional

A string containing information about errors that may occur when importing a custom image.

MinDiskSize int64optional

The minimum disk size in GB required for a Droplet to use this image.

minimum0
Name stringoptional

The display name that has been given to an image. This is what is shown in the control panel and is generally a descriptive title for the image in question.

Public booloptional

This is a boolean value that indicates whether the image in question is public or not. An image that is public is available to all accounts. A non-public image is only accessible from your account.

Regions []ImageRegionoptional

This attribute is an array of the regions that the image is available in. The regions are represented by their identifying slug values.

Accepts one of the following:
const ImageRegionAms1 ImageRegion = "ams1"
const ImageRegionAms2 ImageRegion = "ams2"
const ImageRegionAms3 ImageRegion = "ams3"
const ImageRegionBlr1 ImageRegion = "blr1"
const ImageRegionFra1 ImageRegion = "fra1"
const ImageRegionLon1 ImageRegion = "lon1"
const ImageRegionNyc1 ImageRegion = "nyc1"
const ImageRegionNyc2 ImageRegion = "nyc2"
const ImageRegionNyc3 ImageRegion = "nyc3"
const ImageRegionSfo1 ImageRegion = "sfo1"
const ImageRegionSfo2 ImageRegion = "sfo2"
const ImageRegionSfo3 ImageRegion = "sfo3"
const ImageRegionSgp1 ImageRegion = "sgp1"
const ImageRegionTor1 ImageRegion = "tor1"
const ImageRegionSyd1 ImageRegion = "syd1"
SizeGigabytes float64optional

The size of the image in gigabytes.

formatfloat
Slug stringoptional

A uniquely identifying string that is associated with each of the DigitalOcean-provided public images. These can be used to reference a public image as an alternative to the numeric id.

Status ImageStatusoptional

A status string indicating the state of a custom image. This may be NEW, available, pending, deleted, or retired.

Accepts one of the following:
const ImageStatusNew ImageStatus = "NEW"
const ImageStatusAvailable ImageStatus = "available"
const ImageStatusPending ImageStatus = "pending"
const ImageStatusDeleted ImageStatus = "deleted"
const ImageStatusRetired ImageStatus = "retired"
Tags []stringoptional

A flat array of tag names as strings to be applied to the resource. Tag names may be for either existing or new tags.

Requires tag:create scope.

Type ImageTypeoptional

Describes the kind of image. It may be one of base, snapshot, backup, custom, or admin. Respectively, this specifies whether an image is a DigitalOcean base OS image, user-generated Droplet snapshot, automatically created Droplet backup, user-provided virtual machine image, or an image used for DigitalOcean managed resources (e.g. DOKS worker nodes).

Accepts one of the following:
const ImageTypeBase ImageType = "base"
const ImageTypeSnapshot ImageType = "snapshot"
const ImageTypeBackup ImageType = "backup"
const ImageTypeCustom ImageType = "custom"
const ImageTypeAdmin ImageType = "admin"
Create a Custom Image
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := gradient.NewClient(
    option.WithAccessToken("My Access Token"),
  )
  image, err := client.GPUDroplets.Images.New(context.TODO(), gradient.GPUDropletImageNewParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", image.Image)
}
{
  "image": {
    "id": 7555620,
    "created_at": "2020-05-04T22:23:02Z",
    "description": " ",
    "distribution": "Ubuntu",
    "error_message": " ",
    "min_disk_size": 20,
    "name": "Nifty New Snapshot",
    "public": true,
    "regions": [
      "nyc1",
      "nyc2"
    ],
    "size_gigabytes": 2.34,
    "slug": "nifty1",
    "status": "NEW",
    "tags": [
      "base-image",
      "prod"
    ],
    "type": "snapshot"
  }
}
Returns Examples
{
  "image": {
    "id": 7555620,
    "created_at": "2020-05-04T22:23:02Z",
    "description": " ",
    "distribution": "Ubuntu",
    "error_message": " ",
    "min_disk_size": 20,
    "name": "Nifty New Snapshot",
    "public": true,
    "regions": [
      "nyc1",
      "nyc2"
    ],
    "size_gigabytes": 2.34,
    "slug": "nifty1",
    "status": "NEW",
    "tags": [
      "base-image",
      "prod"
    ],
    "type": "snapshot"
  }
}