curl --request POST \
--url https://console.gmicloud.ai/api/v2/templates/{template_id}/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "<string>",
"sha256": "<string>",
"size_bytes": 536870912
}
'import requests
url = "https://console.gmicloud.ai/api/v2/templates/{template_id}/files"
payload = {
"name": "<string>",
"sha256": "<string>",
"size_bytes": 536870912
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', sha256: '<string>', size_bytes: 536870912})
};
fetch('https://console.gmicloud.ai/api/v2/templates/{template_id}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://console.gmicloud.ai/api/v2/templates/{template_id}/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'sha256' => '<string>',
'size_bytes' => 536870912
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://console.gmicloud.ai/api/v2/templates/{template_id}/files"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"sha256\": \"<string>\",\n \"size_bytes\": 536870912\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://console.gmicloud.ai/api/v2/templates/{template_id}/files")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"sha256\": \"<string>\",\n \"size_bytes\": 536870912\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/templates/{template_id}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"sha256\": \"<string>\",\n \"size_bytes\": 536870912\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "awaiting_upload",
"status_url": "<string>",
"upload": {
"method": "PUT",
"url": "<string>",
"headers": {},
"expires_at": "2023-11-07T05:31:56Z"
}
}
}{
"code": "Parameter.Invalid",
"message": "Invalid request parameters",
"request_id": "req-xxxx"
}{
"code": "Auth.Unauthorized",
"message": "Authentication required",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Resource.NotFound",
"message": "The requested resource was not found",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Request.Canceled",
"message": "Request canceled",
"request_id": "req-xxxx"
}{
"code": "System.Internal",
"message": "An internal server error occurred",
"request_id": "req-xxxx"
}{
"code": "Request.Timeout",
"message": "Request timed out",
"request_id": "req-xxxx"
}Initialize a Template build-context upload
Creates an immutable tar/tgz build context and returns a staging upload
session. Upload the archive directly with a single HTTP PUT to the
returned URL and poll the returned status URL; there is no
client-visible complete operation. The platform verifies the uploaded
object and imports it into the selected IDC. Backend identity and
storage object identifiers are never exposed. Maximum declared size is
1 GiB. Idempotency-Key is required. A replay returns the same file
ID. While the file is still awaiting upload and the archive has not
been received yet, the replay issues a fresh upload session for the
same staging object; if the archive has already been received, or the
file has advanced past awaiting_upload, upload is omitted and
callers should poll status_url. Once the file is failed or
expired, or its upload deadline has passed, the key is consumed and
the replay returns 409 Sandbox.IdempotentKeyConsumed — create a new
file with a new key.
curl --request POST \
--url https://console.gmicloud.ai/api/v2/templates/{template_id}/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "<string>",
"sha256": "<string>",
"size_bytes": 536870912
}
'import requests
url = "https://console.gmicloud.ai/api/v2/templates/{template_id}/files"
payload = {
"name": "<string>",
"sha256": "<string>",
"size_bytes": 536870912
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', sha256: '<string>', size_bytes: 536870912})
};
fetch('https://console.gmicloud.ai/api/v2/templates/{template_id}/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://console.gmicloud.ai/api/v2/templates/{template_id}/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'sha256' => '<string>',
'size_bytes' => 536870912
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://console.gmicloud.ai/api/v2/templates/{template_id}/files"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"sha256\": \"<string>\",\n \"size_bytes\": 536870912\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://console.gmicloud.ai/api/v2/templates/{template_id}/files")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"sha256\": \"<string>\",\n \"size_bytes\": 536870912\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.gmicloud.ai/api/v2/templates/{template_id}/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"sha256\": \"<string>\",\n \"size_bytes\": 536870912\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"state": "awaiting_upload",
"status_url": "<string>",
"upload": {
"method": "PUT",
"url": "<string>",
"headers": {},
"expires_at": "2023-11-07T05:31:56Z"
}
}
}{
"code": "Parameter.Invalid",
"message": "Invalid request parameters",
"request_id": "req-xxxx"
}{
"code": "Auth.Unauthorized",
"message": "Authentication required",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Resource.NotFound",
"message": "The requested resource was not found",
"request_id": "req-xxxx"
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Resource.QuotaExceeded",
"message": "The resource quota is not enough.",
"request_id": "req-xxxx",
"trace_id": "<string>",
"details": {}
}{
"code": "Request.Canceled",
"message": "Request canceled",
"request_id": "req-xxxx"
}{
"code": "System.Internal",
"message": "An internal server error occurred",
"request_id": "req-xxxx"
}{
"code": "Request.Timeout",
"message": "Request timed out",
"request_id": "req-xxxx"
}Authorizations
API Key or Access Token, always sent as Authorization: Bearer <token>. The gateway recognizes the token type automatically.
Headers
Caller-generated key that makes Template file initialization safe to retry. Matched byte-for-byte: 1-64 printable ASCII characters with no whitespace. The key is scoped to the organization and Template and is retained with the Template file lifecycle. A different request body under the same key returns 400 Sandbox.IdempotentParameterMismatch.
1 - 64Path Parameters
Owning GMI Template identifier.
Query Parameters
Filter by data center name, e.g. us-denver-1