Google Compute Engine API

The Compute Engine API allows you to create and manage virtual machine instances, instance groups, disks, networks, firewalls, and other compute resources programmatically within Google Cloud.

OpenAPI Specification

compute-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Google Cloud Compute Engine Google Compute Engine API
  description: >-
    Creates and runs virtual machines on Google Cloud infrastructure, with
    support for managing disks, networks, and firewall rules.
  version: 1.0.0
  contact:
    name: Google Cloud
    url: https://cloud.google.com/compute
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
  - url: https://compute.googleapis.com/compute/v1
    description: Google Compute Engine API v1
tags:
  - name: Disks
    description: Manage persistent disks
  - name: Firewalls
    description: Manage firewall rules
  - name: Instances
    description: Manage virtual machine instances
  - name: Networks
    description: Manage VPC networks
paths:
  /projects/{project}/zones/{zone}/instances:
    get:
      operationId: listInstances
      summary: Google Cloud Compute Engine List Instances
      description: Retrieves the list of instances contained within the specified zone.
      tags:
        - Instances
      parameters:
        - name: project
          in: path
          required: true
          schema:
            type: string
        - name: zone
          in: path
          required: true
          schema:
            type: string
        - name: maxResults
          in: query
          schema:
            type: integer
        - name: pageToken
          in: query
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Instance'
                  nextPageToken:
                    type: string
    post:
      operationId: insertInstance
      summary: Google Cloud Compute Engine Create Instance
      description: Creates an instance resource in the specified project using the data included in the request.
      tags:
        - Instances
      parameters:
        - name: project
          in: path
          required: true
          schema:
            type: string
        - name: zone
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Instance'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Operation'
  /projects/{project}/zones/{zone}/instances/{instance}:
    get:
      operationId: getInstance
      summary: Google Cloud Compute Engine Get Instance
      description: Returns the specified Instance resource.
      tags:
        - Instances
      parameters:
        - name: project
          in: path
          required: true
          schema:
            type: string
        - name: zone
          in: path
          required: true
          schema:
            type: string
        - name: instance
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Instance'
    delete:
      operationId: deleteInstance
      summary: Google Cloud Compute Engine Delete Instance
      description: Deletes the specified Instance resource.
      tags:
        - Instances
      parameters:
        - name: project
          in: path
          required: true
          schema:
            type: string
        - name: zone
          in: path
          required: true
          schema:
            type: string
        - name: instance
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Operation'
  /projects/{project}/zones/{zone}/disks:
    get:
      operationId: listDisks
      summary: Google Cloud Compute Engine List Disks
      description: Retrieves a list of persistent disks contained within the specified zone.
      tags:
        - Disks
      parameters:
        - name: project
          in: path
          required: true
          schema:
            type: string
        - name: zone
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Disk'
                  nextPageToken:
                    type: string
  /projects/{project}/global/networks:
    get:
      operationId: listNetworks
      summary: Google Cloud Compute Engine List Networks
      description: Retrieves the list of networks available to the specified project.
      tags:
        - Networks
      parameters:
        - name: project
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Network'
                  nextPageToken:
                    type: string
  /projects/{project}/global/firewalls:
    get:
      operationId: listFirewalls
      summary: Google Cloud Compute Engine List Firewalls
      description: Retrieves the list of firewall rules available to the specified project.
      tags:
        - Firewalls
      parameters:
        - name: project
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Firewall'
                  nextPageToken:
                    type: string
components:
  schemas:
    Instance:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        zone:
          type: string
        machineType:
          type: string
        status:
          type: string
          enum:
            - PROVISIONING
            - STAGING
            - RUNNING
            - STOPPING
            - STOPPED
            - SUSPENDING
            - SUSPENDED
            - TERMINATED
        networkInterfaces:
          type: array
          items:
            type: object
            properties:
              network:
                type: string
              subnetwork:
                type: string
              networkIP:
                type: string
        disks:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              boot:
                type: boolean
              autoDelete:
                type: boolean
        selfLink:
          type: string
        creationTimestamp:
          type: string
          format: date-time
    Disk:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        sizeGb:
          type: string
        type:
          type: string
        status:
          type: string
        zone:
          type: string
        selfLink:
          type: string
        creationTimestamp:
          type: string
          format: date-time
    Network:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        autoCreateSubnetworks:
          type: boolean
        IPv4Range:
          type: string
        selfLink:
          type: string
        creationTimestamp:
          type: string
          format: date-time
    Firewall:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
        network:
          type: string
        direction:
          type: string
          enum:
            - INGRESS
            - EGRESS
        priority:
          type: integer
        allowed:
          type: array
          items:
            type: object
            properties:
              IPProtocol:
                type: string
              ports:
                type: array
                items:
                  type: string
        sourceRanges:
          type: array
          items:
            type: string
        selfLink:
          type: string
    Operation:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        operationType:
          type: string
        status:
          type: string
        targetLink:
          type: string
        progress:
          type: integer
        insertTime:
          type: string
          format: date-time
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://accounts.google.com/o/oauth2/auth
          tokenUrl: https://oauth2.googleapis.com/token
          scopes:
            https://www.googleapis.com/auth/compute: Full access to Compute Engine
            https://www.googleapis.com/auth/cloud-platform: Full access to Google Cloud Platform
security:
  - oauth2:
      - https://www.googleapis.com/auth/compute