Template Management

List available instance templates that define the machine type, disk, and image configuration for new compute instances.

List Templates

Returns all available instance templates.

Endpoint: https://apis.threatwinds.com/api/compute/v1/templates

Method: GET

Parameters

Headers

Header Type Required Description
Authorization string Optional* Bearer token for session authentication
api-key string Optional* API key for key-based authentication
api-secret string Optional* API secret for key-based authentication

Note: You must use either Authorization header OR API key/secret combination.

Request

To list all available templates, use a GET request:

curl -X 'GET' \
  'https://apis.threatwinds.com/api/compute/v1/templates' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <token>'

Or using API key and secret:

curl -X 'GET' \
  'https://apis.threatwinds.com/api/compute/v1/templates' \
  -H 'accept: application/json' \
  -H 'api-key: your-api-key' \
  -H 'api-secret: your-api-secret'

Response

A successful response will return an array of available templates.

Success Response (200 OK)

[
  {
    "id": "ubuntu-22-standard",
    "name": "Ubuntu 22 Standard",
    "description": "Ubuntu 22.04 LTS standard instance",
    "machineType": "n1-standard-2",
    "diskSizeGb": 50,
    "diskType": "pd-standard",
    "image": "projects/ubuntu-os-cloud/global/images/family/ubuntu-2204-lts",
    "region": "us-central1"
  }
]

Response Schema

Field Type Description
id string Template unique identifier
name string Human-readable template name
description string Template description
machineType string GCP machine type
diskSizeGb integer Disk size in gigabytes
diskType string GCP disk type (e.g., pd-standard, pd-ssd)
image string GCP image family or specific image path
region string GCP region where the template is available

Business Logic

  • Retrieves all instance templates from GCP
  • Converts GCP InstanceTemplate objects to the API response format
  • Extracts machine type, disk configuration, and region from GCP properties
  • Returns 404 if no templates are found

Error Codes

Status Code Description Possible Cause
200 OK Request successful
404 Not Found No templates found
429 Too Many Requests Rate limit exceeded
500 Internal Server Error GCP query error or server-side error

List Template Zones

Returns the available GCP zones for a given template. A zone is included only if it belongs to the template’s region, is operational, and supports the template’s machine type. Use this endpoint to discover valid zones before creating an instance.

Endpoint: https://apis.threatwinds.com/api/compute/v1/templates/{id}/zones

Method: GET

Parameters

Headers

Header Type Required Description
Authorization string Optional* Bearer token for session authentication
api-key string Optional* API key for key-based authentication
api-secret string Optional* API secret for key-based authentication

Note: You must use either Authorization header OR API key/secret combination.

Path Parameters

Parameter Type Required Description Example
id string Yes Template identifier ubuntu-22-standard

Request

To list available zones for a template, use a GET request:

curl -X 'GET' \
  'https://apis.threatwinds.com/api/compute/v1/templates/ubuntu-22-standard/zones' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <token>'

Or using API key and secret:

curl -X 'GET' \
  'https://apis.threatwinds.com/api/compute/v1/templates/ubuntu-22-standard/zones' \
  -H 'accept: application/json' \
  -H 'api-key: your-api-key' \
  -H 'api-secret: your-api-secret'

Response

A successful response will return a sorted array of zone name strings.

Success Response (200 OK)

[
  "us-central1-a",
  "us-central1-b",
  "us-central1-c",
  "us-central1-f"
]

Response Schema

The response is an array of strings, where each string is a GCP zone name that supports the template’s machine type.

Business Logic

  • Retrieves the template by ID from GCP managed instance templates
  • Extracts the region (from the template’s subnetwork) and machine type
  • Lists all GCP zones in the template’s region that have status UP
  • Concurrently verifies that the template’s machine type is available in each zone
  • Returns only zones where the machine type is confirmed available
  • Returns 404 if no zones are available or the template is not found

Error Codes

Status Code Description Possible Cause
200 OK Request successful
404 Not Found Template not found or no zones available for the machine type
429 Too Many Requests Rate limit exceeded
500 Internal Server Error GCP query error or server-side error