Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Switch the template build to local (#338)

Jakub Novák2bafaf0db45e
diff --git a/.changeset/late-rice-hammer.md b/.changeset/late-rice-hammer.md
new file mode 100644
index 000000000..bc7aeebd4
--- /dev/null
+++ b/.changeset/late-rice-hammer.md
@@ -0,0 +1,7 @@
+---
+"e2b": minor
+"@e2b/cli": minor
+"@e2b/python-sdk": patch
+---
+
+Change template build to local docker
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 91bedc062..59eefcd83 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -28,9 +28,9 @@
"update-deps": "ncu -u && pnpm i"
},
"devDependencies": {
+ "@types/command-exists": "^1.2.3",
"@types/inquirer": "^9.0.7",
"@types/node": "^18.18.6",
- "@types/tar-fs": "^2.0.3",
"@types/update-notifier": "6.0.5",
"knip": "^2.33.4",
"npm-check-updates": "^16.14.6",
@@ -48,21 +48,18 @@
"e2b": "dist/index.js"
},
"dependencies": {
- "@balena/dockerignore": "^1.0.2",
"@iarna/toml": "^2.2.5",
- "@nodelib/fs.walk": "^2.0.0",
"async-listen": "^3.0.1",
"boxen": "^7.1.1",
"chalk": "^5.3.0",
"cli-highlight": "^2.1.11",
+ "command-exists": "^1.2.9",
"commander": "^11.1.0",
"console-table-printer": "^2.11.2",
"e2b": "^0.12.6",
- "ignore": "^5.2.4",
"inquirer": "^9.2.12",
"open": "^9.1.0",
"strip-ansi": "^7.1.0",
- "tar-fs": "^3.0.4",
"update-notifier": "5.1.0",
"yup": "^1.3.2"
},
diff --git a/packages/cli/src/commands/sandbox/list.ts b/packages/cli/src/commands/sandbox/list.ts
index d1199137f..b95401ed3 100644
--- a/packages/cli/src/commands/sandbox/list.ts
+++ b/packages/cli/src/commands/sandbox/list.ts
@@ -26,8 +26,8 @@ export const listCommand = new commander.Command('list')
{ name: 'templateID', alignment: 'left', title: 'Template ID' },
{ name: 'alias', alignment: 'left', title: 'Alias' },
{ name: 'startedAt', alignment: 'left', title: 'Started at' },
- { name: 'cpuCount', alignment: 'left', title: 'CPUs' },
- { name: 'memoryMB', alignment: 'left', title: 'RAM MB' },
+ { name: 'cpuCount', alignment: 'left', title: 'vCPUs' },
+ { name: 'memoryMB', alignment: 'left', title: 'RAM MiB' },
{ name: 'metadata', alignment: 'left', title: 'Metadata' },
],
disabledColumns: ['clientID'],
diff --git a/packages/cli/src/commands/template/build.ts b/packages/cli/src/commands/template/build.ts
index 692f3f7fc..cc7454252 100644
--- a/packages/cli/src/commands/template/build.ts
+++ b/packages/cli/src/commands/template/build.ts
@@ -4,10 +4,10 @@ import * as path from 'path'
import * as e2b from 'e2b'
import * as stripAnsi from 'strip-ansi'
import * as boxen from 'boxen'
-
+import commandExists from 'command-exists'
import { wait } from 'src/utils/wait'
import { ensureAccessToken } from 'src/api'
-import { getFiles, getRoot } from 'src/utils/filesystem'
+import { getRoot } from 'src/utils/filesystem'
import {
asBold,
asBuildLogs,
@@ -20,15 +20,26 @@ import {
withDelimiter,
} from 'src/utils/format'
import { pathOption } from 'src/options'
-import { createBlobFromFiles } from 'src/docker/archive'
import { defaultDockerfileName, fallbackDockerfileName } from 'src/docker/constants'
-import { configName, getConfigPath, loadConfig, maxContentSize, saveConfig } from 'src/config'
-import { estimateContentLength } from '../../utils/form'
+import { configName, getConfigPath, loadConfig, saveConfig } from 'src/config'
+import * as child_process from 'child_process'
-const templateCheckInterval = 1_000 // 1 sec
+const templateCheckInterval = 500 // 0.5 sec
const getTemplate = e2b.withAccessToken(
- e2b.api.path('/templates/{templateID}/builds/{buildID}').method('get').create(),
+ e2b.api.path('/templates/{templateID}/builds/{buildID}/status').method('get').create(),
+)
+
+const requestTemplateBuild = e2b.withAccessToken(
+ e2b.api.path('/templates').method('post').create(),
+)
+
+const requestTemplateRebuild = e2b.withAccessToken(
+ e2b.api.path('/templates/{templateID}').method('post').create(),
+)
+
+const triggerTemplateBuild = e2b.withAccessToken(
+ e2b.api.path('/templates/{templateID}/builds/{buildID}').method('post').create(),
)
export const buildCommand = new commander.Command('build')
@@ -67,10 +78,12 @@ export const buildCommand = new commander.Command('build')
.option(
'--cpu-count <cpu-count>',
'specify the number of CPUs that will be used to run the sandbox. The default value is 2.',
+ parseInt,
)
.option(
'--memory-mb <memory-mb>',
'specify the amount of memory in megabytes that will be used to run the sandbox. Must be an even number. The default value is 512.',
+ parseInt,
)
.alias('bd')
.action(
@@ -81,11 +94,19 @@ export const buildCommand = new commander.Command('build')
dockerfile?: string;
name?: string;
cmd?: string;
- cpuCount?: string;
- memoryMb?: string;
+ cpuCount?: number;
+ memoryMb?: number;
},
) => {
try {
+ const dockerInstalled = commandExists.sync('docker')
+ if (!dockerInstalled) {
+ console.error(
+ 'Docker is required to build and push the sandbox template. Please install Docker and try again.',
+ )
+ process.exit(1)
+ }
+
const accessToken = ensureAccessToken()
process.stdout.write('\n')
@@ -99,7 +120,8 @@ export const buildCommand = new commander.Command('build')
let dockerfile = opts.dockerfile
let startCmd = opts.cmd
-
+ let cpuCount= opts.cpuCount
+ let memoryMB = opts.memoryMb
const root = getRoot(opts.path)
const configPath = getConfigPath(root)
@@ -123,6 +145,8 @@ export const buildCommand = new commander.Command('build')
templateID = config.template_id
dockerfile = opts.dockerfile || config.dockerfile
startCmd = opts.cmd || config.start_cmd
+ cpuCount = opts.cpuCount || config.cpu_count
+ memoryMB = opts.memoryMb || config.memory_mb
}
if (config && templateID && config.template_id !== templateID) {
@@ -131,12 +155,6 @@ export const buildCommand = new commander.Command('build')
process.exit(1)
}
- const filePaths = await getFiles(root, {
- respectGitignore: false,
- respectDockerignore: true,
- overrideIgnoreFor: [dockerfile || defaultDockerfileName],
- })
-
if (newName && config?.template_name && newName !== config?.template_name) {
console.log(
`The sandbox template name will be changed from ${asLocal(config.template_name)} to ${asLocal(newName)}.`,
@@ -144,10 +162,6 @@ export const buildCommand = new commander.Command('build')
}
const name = newName || config?.template_name
- console.log(
- `Preparing sandbox template building (${filePaths.length} files in Docker build context). ${!filePaths.length ? `If you are using ${asLocal('.dockerignore')} check if it is configured correctly.` : ''}`,
- )
-
const { dockerfileContent, dockerfileRelativePath } = getDockerfile(
root,
dockerfile,
@@ -159,79 +173,71 @@ export const buildCommand = new commander.Command('build')
)} that will be used to build the sandbox template.`,
)
- const body = new FormData()
-
- body.append('dockerfile', dockerfileContent)
-
- // It should be possible to pipe directly to the API
- // instead of creating a blob in memory then streaming.
- const blob = await createBlobFromFiles(
- root,
- filePaths,
- dockerfileRelativePath !== fallbackDockerfileName
- ? [
- {
- oldPath: dockerfileRelativePath,
- newPath: fallbackDockerfileName,
- },
- ]
- : [],
- maxContentSize,
- )
- body.append('buildContext', blob, 'env.tar.gz.e2b')
-
- if (name) {
- body.append('alias', name)
- }
-
- if (startCmd) {
- body.append('startCmd', startCmd)
- }
-
- if (opts.cpuCount) {
- body.append('cpuCount', opts.cpuCount)
+ const body = {
+ alias: name,
+ startCmd: startCmd,
+ cpuCount: cpuCount,
+ memoryMB: memoryMB,
+ dockerfile: dockerfileContent,
}
if (opts.memoryMb) {
- if (parseInt(opts.memoryMb) % 2 !== 0) {
+ if (opts.memoryMb % 2 !== 0) {
console.error(
- `The memory in megabytes must be an even number. You provided ${asLocal(opts.memoryMb)}.`,
+ `The memory in megabytes must be an even number. You provided ${asLocal(opts.memoryMb.toFixed(0))}.`,
)
process.exit(1)
}
-
- body.append('memoryMB', opts.memoryMb)
}
- const estimatedSize = estimateContentLength(body)
- if (estimatedSize > maxContentSize) {
- console.error(
- `The sandbox template build context is too large ${asLocal(`${Math.round(estimatedSize / 1024 / 1024 * 100) / 100} MiB`)}. The maximum size is ${asLocal(
- `${maxContentSize / 1024 / 1024} MiB.`)}\n\nCheck if you are not including unnecessary files in the build context (e.g. node_modules)`,
- )
- process.exit(1)
- }
-
- const build = await buildTemplate(accessToken, body, !!config, configPath, templateID)
+ const template = await requestBuildTemplate(accessToken, body, !!config, relativeConfigPath, templateID)
+ templateID = template.templateID
console.log(
- `Started building the sandbox template ${asFormattedSandboxTemplate(
- build,
+ `Requested build for the sandbox template ${asFormattedSandboxTemplate(
+ template,
)} `,
)
- await waitForBuildFinish(accessToken, build.templateID, build.buildID, name)
-
await saveConfig(
configPath,
{
- template_id: build.templateID,
+ template_id: template.templateID,
dockerfile: dockerfileRelativePath,
template_name: name,
start_cmd: startCmd,
+ cpu_count: cpuCount,
+ memory_mb: memoryMB,
},
true,
)
+
+
+ child_process.execSync(`echo ${accessToken} | docker login docker.e2b-staging.com -u _e2b_access_token --password-stdin`, { stdio: 'inherit', cwd: root})
+ process.stdout.write('\n')
+
+ console.log('Building docker image...')
+ child_process.execSync(`DOCKER_CLI_HINTS=false docker build . -f ${dockerfileRelativePath} --platform linux/amd64 -t docker.e2b-staging.com/e2b-dev/e2b-custom-environments/${templateID}:${template.buildID}`, { stdio: 'inherit', cwd: root})
+
+ process.stdout.write('\n')
+ console.log('Pushing docker image...')
+ child_process.execSync(`docker push docker.e2b-staging.com/e2b-dev/e2b-custom-environments/${templateID}:${template.buildID}`, { stdio: 'inherit', cwd: root })
+
+ process.stdout.write('\n')
+
+ console.log('Triggering build...')
+ await triggerBuild(accessToken, templateID, template.buildID)
+
+ console.log(
+ `Triggered build for the sandbox template ${asFormattedSandboxTemplate(
+ template,
+ )} `,
+ )
+
+ console.log('Waiting for build to finish...')
+ await waitForBuildFinish(accessToken, templateID, template.buildID, name)
+
+ process.exit(0)
} catch (err: any) {
console.error(err)
process.exit(1)
@@ -424,9 +430,9 @@ function getDockerfile(root: string, file?: string) {
)
}
-async function buildTemplate(
+async function requestBuildTemplate(
accessToken: string,
- body: FormData,
+ args: e2b.paths['/templates']['post']['requestBody']['content']['application/json'],
hasConfig: boolean,
configPath: string,
templateID?: string,
@@ -436,27 +442,18 @@ async function buildTemplate(
'logs'
>
> {
- const res = await fetch(e2b.API_HOST + (templateID ? `/templates/${templateID}` : '/templates'), {
- method: 'POST',
- headers: { Authorization: `Bearer ${accessToken}` },
- body,
- })
-
- let data: any
-
- try {
- data = await res.json()
- } catch (e) {
- throw new Error(
- `Build API request failed: ${res.statusText}`,
- )
+ let res
+ if (templateID) {
+ res = await requestTemplateRebuild(accessToken, { templateID, ...args })
+ } else {
+ res = await requestTemplateBuild(accessToken, args)
}
if (!res.ok) {
const error:
| e2b.paths['/templates']['post']['responses']['401']['content']['application/json']
| e2b.paths['/templates']['post']['responses']['500']['content']['application/json'] =
- data as any
+ res.data as any
if (error.code === 401) {
throw new Error(
@@ -483,5 +480,40 @@ async function buildTemplate(
)
}
- return data as any
+ return res.data as any
+}
+
+
+async function triggerBuild(
+ accessToken: string,
+ templateID: string,
+ buildID: string,
+) {
+ const res = await triggerTemplateBuild(accessToken, { templateID, buildID })
+
+ if (!res.ok) {
+ const error:
+ | e2b.paths['/templates/{templateID}/builds/{buildID}']['post']['responses']['401']['content']['application/json']
+ | e2b.paths['/templates/{templateID}/builds/{buildID}']['post']['responses']['500']['content']['application/json'] =
+ res.data as any
+
+ if (error.code === 401) {
+ throw new Error(
+ `Authentication error: ${res.statusText}, ${error.message ?? 'no message'
+ }`,
+ )
+ }
+
+ if (error.code === 500) {
+ throw new Error(
+ `Server error: ${res.statusText}, ${error.message ?? 'no message'}`,
+ )
+ }
+
+ throw new Error(
+ `API request failed: ${res.statusText}, ${error.message ?? 'no message'}`,
+ )
+ }
+
+ return
}
diff --git a/packages/cli/src/commands/template/list.ts b/packages/cli/src/commands/template/list.ts
index da66bb2b6..acb357a2b 100644
--- a/packages/cli/src/commands/template/list.ts
+++ b/packages/cli/src/commands/template/list.ts
@@ -32,6 +32,8 @@ export const listCommand = new commander.Command('list')
columns: [
{ name: 'templateID', alignment: 'left', title: 'Template ID' },
{ name: 'aliases', alignment: 'left', title: 'Template Name', color: 'orange' },
+ { name: 'cpuCount', alignment: 'right', title: 'vCPUs' },
+ { name: 'memoryMB', alignment: 'right', title: 'RAM MiB' },
],
disabledColumns: ['public', 'buildID'],
rows: templates.map((template) => ({ ...template, aliases: listAliases(template.aliases) })),
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index 593f12dde..5cea8b5b0 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -6,7 +6,6 @@ import * as path from 'path'
import { asFormattedSandboxTemplate, asLocalRelative } from 'src/utils/format'
-export const maxContentSize = 256 * 1024 * 1024 // 256MiB
export const configName = 'e2b.toml'
function getConfigHeader(config: E2BConfig) {
@@ -29,9 +28,11 @@ export const configSchema = yup.object({
template_name: yup.string().optional(),
dockerfile: yup.string().required(),
start_cmd: yup.string().optional(),
+ cpu_count: yup.number().integer().min(1).optional(),
+ memory_mb: yup.number().integer().min(128).optional(),
})
-export type E2BConfig = yup.InferType<typeof configSchema>;
+export type E2BConfig = yup.InferType<typeof configSchema>
interface Migration {
from: string;
diff --git a/packages/cli/src/docker/archive.ts b/packages/cli/src/docker/archive.ts
deleted file mode 100644
index aad560f4c..000000000
--- a/packages/cli/src/docker/archive.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import * as tar from 'tar-fs'
-import * as path from 'path'
-import { asLocal } from '../utils/format'
-
-export interface FilePath {
- path: string
- rootPath: string
- name: string
-}
-
-export interface FileRewrite {
- oldPath: string
- newPath: string
-}
-
-export async function createBlobFromFiles(
- root: string,
- filePaths: FilePath[],
- rewrites: FileRewrite[],
- maxSizeBytes: number = 1024 * 1024 * 1024, // 1 GiB
-) {
- const absoluteRewrites = rewrites.map(({ oldPath, newPath }) => ({
- oldPath: path.join(path.sep, oldPath),
- newPath: path.join(path.sep, newPath),
- }))
-
- const blob = await new Promise<Blob>((resolve, reject) => {
- const chunks: BlobPart[] = []
- let size = 0
-
- const pack = tar.pack(root, {
- entries: filePaths
- .filter(f =>
- absoluteRewrites.every(({ oldPath }) => path.resolve(oldPath) !== f.path),
- )
- .map(({ rootPath }) => rootPath),
- map: header => {
- const rewrite = absoluteRewrites.find(({ oldPath }) => header.name === oldPath)
- if (rewrite) {
- header.name = rewrite.newPath
- }
- return header
- },
- })
-
- pack.on('data', (chunk: BlobPart) => {
- if (typeof chunk === 'object') {
- if (chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
- size += chunk.byteLength;
- } else {
- size += chunk.size;
- }
- } else {
- size += String(chunk).length;
- }
-
- if (size > maxSizeBytes) {
- reject(new Error(`Content size is too big. The maximum size is ${asLocal(`${maxSizeBytes / 1024 / 1024} MiB.`)}\n\nCheck if you are not including unnecessary files in the build context (e.g. node_modules)`));
- }
- chunks.push(chunk)
- })
-
- pack.on('end', () => {
- const blob = new Blob(chunks)
- resolve(blob)
- })
-
- pack.on('error', (error: any) => {
- reject(new Error(`Error creating tar blob: ${error.message}`))
- })
- })
-
- return blob
-}
diff --git a/packages/cli/src/utils/filesystem.ts b/packages/cli/src/utils/filesystem.ts
index 3436c4045..cd0b4133b 100644
--- a/packages/cli/src/utils/filesystem.ts
+++ b/packages/cli/src/utils/filesystem.ts
@@ -1,95 +1,4 @@
-import * as dockerIgnore from '@balena/dockerignore'
-import * as fsWalk from '@nodelib/fs.walk'
-import * as fs from 'fs'
-import * as gitIgnore from 'ignore'
import * as path from 'path'
-import * as util from 'util'
-
-const walk = util.promisify(fsWalk.walk)
-
-/**
- * Asynchronously retrieves files from a specified root path.
- *
- * @param rootPath - The root directory from which to retrieve files.
- * @param opts - Optional parameters to filter the files by extension and/or name.
- * @param opts.extension - If specified, only files with this extension will be returned.
- * @param opts.name - If specified, only a file with this name will be returned.
- * @param opts.respectGitignore - If true, files that are ignored by .gitignore will be excluded.
- * @param opts.respectDockerignore - If true, files that are ignored by .dockerignore will be excluded.
- * @param opts.overrideIgnoreFor - If specified, files that should be ignored will be still included if they match this list.
- */
-export async function getFiles(
- rootPath: string,
- opts?: {
- extension?: string;
- name?: string;
- respectGitignore?: boolean;
- respectDockerignore?: boolean;
- overrideIgnoreFor?: string[];
- },
-) {
- let gitignore: gitIgnore.Ignore | undefined
- if (opts?.respectGitignore) {
- const gitignorePath = path.join(rootPath, '.gitignore')
- if (fs.existsSync(gitignorePath)) {
- gitignore = gitIgnore
- .default()
- .add(fs.readFileSync(gitignorePath).toString())
- }
- }
-
- let dockerignore: { ignores: (path: string) => boolean } | undefined
- if (opts?.respectDockerignore) {
- const dockerignorePath = path.join(rootPath, '.dockerignore')
- if (fs.existsSync(dockerignorePath)) {
- const dockerIgnoreContent = fs.readFileSync(dockerignorePath, 'utf-8')
- const dockerIgnoreLines = dockerIgnoreContent
- .split('\n')
- .map((line) => line.trim())
- dockerignore = dockerIgnore.default().add(dockerIgnoreLines)
- }
- }
-
- const entries = await walk(rootPath, {
- entryFilter: (e) => {
- return [
- !!e.stats?.isFile(),
- opts?.extension ? e.name.endsWith(opts.extension) : true,
- opts?.name ? e.name === opts.name : true,
- !(gitignore && gitignore.ignores(path.relative(rootPath, e.path))),
- !(
- dockerignore && dockerignore.ignores(path.relative(rootPath, e.path))
- ),
- ].every(Boolean)
- },
- stats: true,
- })
-
- const files = await Promise.all(
- entries.map(async (e) => {
- return {
- path: e.path as string,
- rootPath: path.join('/', path.relative(rootPath, e.path)),
- name: e.name as string,
- }
- }),
- )
-
- if (opts?.overrideIgnoreFor) {
- for (const override of opts.overrideIgnoreFor) {
- const overridePath = path.join(rootPath, override)
- if (files.map(file => file.path).indexOf(overridePath) === -1 && fs.existsSync(overridePath)) {
- files.push({
- path: overridePath,
- rootPath: path.join('/', override),
- name: path.basename(overridePath),
- })
- }
- }
- }
-
- return files
-}
export function getRoot(templatePath?: string) {
const defaultPath = process.cwd()
diff --git a/packages/cli/src/utils/form.ts b/packages/cli/src/utils/form.ts
deleted file mode 100644
index 993177842..000000000
--- a/packages/cli/src/utils/form.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export function estimateContentLength(formData: FormData) {
- const baseLength = 50; // estimated max value
- const separatorLength = 115; // estimated max value
- let length = baseLength;
- const entries = formData.entries();
- for (const [key, value] of entries) {
- length += key.length + separatorLength;
- if (typeof value === 'object') {
- length += value.size;
- } else {
- length += String(value).length;
- }
- }
- return length;
-}
diff --git a/packages/cli/test/filesystem.test.ts b/packages/cli/test/filesystem.test.ts
deleted file mode 100644
index cc6a43856..000000000
--- a/packages/cli/test/filesystem.test.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import path from 'path'
-import { expect, test } from 'vitest'
-
-import * as e2bFs from '../src/utils/filesystem'
-
-test('getFiles(): empty-dir', async () => {
- const files = await e2bFs.getFiles(
- path.join(process.cwd(), 'test/fixtures/complementing-ignore-files'),
- { respectGitignore: true, respectDockerignore: true },
- )
- expect(files).toEqual([])
-})
diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.ts
index e7638b6e6..3e0870df1 100644
--- a/packages/js-sdk/src/api/schema.gen.ts
+++ b/packages/js-sdk/src/api/schema.gen.ts
@@ -107,7 +107,7 @@ export interface paths {
/** Create a new template */
post: {
responses: {
- /** The build has started */
+ /** The build was accepted */
202: {
content: {
"application/json": components["schemas"]["Template"];
@@ -118,23 +118,7 @@ export interface paths {
};
requestBody: {
content: {
- "multipart/form-data": {
- /** @description Alias of the template */
- alias?: string;
- /**
- * Format: binary
- * @description Docker build context
- */
- buildContext: string;
- /** @description Dockerfile content */
- dockerfile: string;
- /** @description Start command to execute in the template after the build */
- startCmd?: string;
- /** @description CPU cores for the template */
- cpuCount?: string;
- /** @description Memory limit for the template in MB */
- memoryMB?: string;
- };
+ "application/json": components["schemas"]["TemplateBuildRequest"];
};
};
};
@@ -148,7 +132,7 @@ export interface paths {
};
};
responses: {
- /** The build has started */
+ /** The build was accepted */
202: {
content: {
"application/json": components["schemas"]["Template"];
@@ -159,23 +143,7 @@ export interface paths {
};
requestBody: {
content: {
- "multipart/form-data": {
- /** @description Alias of the template */
- alias?: string;
- /**
- * Format: binary
- * @description Docker build context
- */
- buildContext: string;
- /** @description Dockerfile content */
- dockerfile: string;
- /** @description Start command to execute in the template after the build */
- startCmd?: string;
- /** @description CPU cores for the template */
- cpuCount?: string;
- /** @description Memory limit for the template in MB */
- memoryMB?: string;
- };
+ "application/json": components["schemas"]["TemplateBuildRequest"];
};
};
};
@@ -195,27 +163,18 @@ export interface paths {
};
};
"/templates/{templateID}/builds/{buildID}": {
- /** Get template build info */
- get: {
+ /** Start the build */
+ post: {
parameters: {
path: {
templateID: components["parameters"]["templateID"];
buildID: components["parameters"]["buildID"];
};
- query: {
- /** Index of the starting build log that should be returned with the template */
- logsOffset?: number;
- };
};
responses: {
- /** Successfully returned the template */
- 200: {
- content: {
- "application/json": components["schemas"]["TemplateBuild"];
- };
- };
+ /** The build has started */
+ 202: unknown;
401: components["responses"]["401"];
- 404: components["responses"]["404"];
500: components["responses"]["500"];
};
};
@@ -246,120 +205,24 @@ export interface paths {
};
};
};
- "/envs": {
- /** List all environments */
- get: {
- responses: {
- /** Successfully returned all environments */
- 200: {
- content: {
- "application/json": components["schemas"]["Environment"][];
- };
- };
- 401: components["responses"]["401"];
- 500: components["responses"]["500"];
- };
- };
- /** Create a new environment */
- post: {
- responses: {
- /** The build has started */
- 202: {
- content: {
- "application/json": components["schemas"]["Environment"];
- };
- };
- 401: components["responses"]["401"];
- 500: components["responses"]["500"];
- };
- requestBody: {
- content: {
- "multipart/form-data": {
- /** @description Alias of the environment */
- alias?: string;
- /**
- * Format: binary
- * @description Docker build context
- */
- buildContext: string;
- /** @description Dockerfile content */
- dockerfile: string;
- /** @description Start command to execute in the template after the build */
- startCmd?: string;
- };
- };
- };
- };
- };
- "/envs/{envID}": {
- /** Rebuild an environment */
- post: {
- parameters: {
- path: {
- envID: components["parameters"]["envID"];
- };
- };
- responses: {
- /** The build has started */
- 202: {
- content: {
- "application/json": components["schemas"]["Environment"];
- };
- };
- 401: components["responses"]["401"];
- 500: components["responses"]["500"];
- };
- requestBody: {
- content: {
- "multipart/form-data": {
- /** @description Alias of the environment */
- alias?: string;
- /**
- * Format: binary
- * @description Docker build context
- */
- buildContext: string;
- /** @description Dockerfile content */
- dockerfile: string;
- /** @description Start command to execute in the template after the build */
- startCmd?: string;
- };
- };
- };
- };
- /** Delete an environment */
- delete: {
- parameters: {
- path: {
- envID: components["parameters"]["envID"];
- };
- };
- responses: {
- /** The environment was deleted successfully */
- 204: never;
- 401: components["responses"]["401"];
- 500: components["responses"]["500"];
- };
- };
- };
- "/envs/{envID}/builds/{buildID}": {
- /** Get environment build info */
+ "/templates/{templateID}/builds/{buildID}/status": {
+ /** Get template build info */
get: {
parameters: {
path: {
- envID: components["parameters"]["envID"];
+ templateID: components["parameters"]["templateID"];
buildID: components["parameters"]["buildID"];
};
query: {
- /** Index of the starting build log that should be returned with the environment */
+ /** Index of the starting build log that should be returned with the template */
logsOffset?: number;
};
};
responses: {
- /** Successfully returned the environment */
+ /** Successfully returned the template */
200: {
content: {
- "application/json": components["schemas"]["EnvironmentBuild"];
+ "application/json": components["schemas"]["TemplateBuild"];
};
};
401: components["responses"]["401"];
@@ -368,91 +231,6 @@ export interface paths {
};
};
};
- "/envs/{envID}/builds/{buildID}/logs": {
- /** Add a build log */
- post: {
- parameters: {
- path: {
- envID: components["parameters"]["envID"];
- buildID: components["parameters"]["buildID"];
- };
- };
- responses: {
- /** Successfully added log */
- 201: unknown;
- 401: components["responses"]["401"];
- 404: components["responses"]["404"];
- };
- requestBody: {
- content: {
- "application/json": {
- /** @description API secret */
- apiSecret: string;
- logs: string[];
- };
- };
- };
- };
- };
- "/instances": {
- /** List all running instances */
- get: {
- responses: {
- /** Successfully returned all running instances */
- 200: {
- content: {
- "application/json": components["schemas"]["RunningInstance"][];
- };
- };
- 400: components["responses"]["400"];
- 401: components["responses"]["401"];
- 500: components["responses"]["500"];
- };
- };
- /** Create an instance from the environment */
- post: {
- responses: {
- /** The instance was created successfully */
- 201: {
- content: {
- "application/json": components["schemas"]["Instance"];
- };
- };
- 400: components["responses"]["400"];
- 401: components["responses"]["401"];
- 500: components["responses"]["500"];
- };
- requestBody: {
- content: {
- "application/json": components["schemas"]["NewInstance"];
- };
- };
- };
- };
- "/instances/{instanceID}/refreshes": {
- /** Refresh the instance extending its time to live */
- post: {
- parameters: {
- path: {
- instanceID: components["parameters"]["instanceID"];
- };
- };
- responses: {
- /** Successfully refreshed the instance */
- 204: never;
- 401: components["responses"]["401"];
- 404: components["responses"]["404"];
- };
- requestBody: {
- content: {
- "application/json": {
- /** @description Duration for which the instance should be kept alive in seconds */
- duration?: number;
- };
- };
- };
- };
- };
}
export interface components {
@@ -498,10 +276,28 @@ export interface components {
templateID: string;
/** @description Identifier of the last successful build for given template */
buildID: string;
+ /** @description CPU cores for the sandbox */
+ cpuCount: number;
+ /** @description Memory limit for the sandbox in MB */
+ memoryMB: number;
/** @description Whether the template is public or only accessible by the team */
public: boolean;
/** @description Aliases of the template */
aliases?: string[];
+ } & {
+ storageGB: unknown;
+ };
+ TemplateBuildRequest: {
+ /** @description Alias of the template */
+ alias?: string;
+ /** @description Dockerfile for the template */
+ dockerfile: string;
+ /** @description Start command to execute in the template after the build */
+ startCmd?: string;
+ /** @description CPU cores for the template */
+ cpuCount?: number;
+ /** @description Memory limit for the template in MB */
+ memoryMB?: number;
};
TemplateBuild: {
/**
@@ -530,62 +326,6 @@ export interface components {
/** @description Error */
message: string;
};
- Environment: {
- /** @description Identifier of the environment */
- envID: string;
- /** @description Identifier of the last successful build for given environment */
- buildID: string;
- /** @description Whether the environment is public or only accessible by the team */
- public: boolean;
- /** @description Aliases of the environment */
- aliases?: string[];
- };
- EnvironmentBuild: {
- /**
- * @description Build logs
- * @default []
- */
- logs: string[];
- /** @description Identifier of the environment */
- envID: string;
- /** @description Identifier of the build */
- buildID: string;
- /**
- * @description Status of the environment
- * @enum {string}
- */
- status?: "building" | "ready" | "error";
- } & {
- finished: unknown;
- };
- InstanceMetadata: { [key: string]: string };
- NewInstance: {
- /** @description Identifier of the required environment */
- envID: string;
- metadata?: components["schemas"]["InstanceMetadata"];
- };
- Instance: {
- /** @description Identifier of the environment from which is the instance created */
- envID: string;
- /** @description Identifier of the instance */
- instanceID: string;
- /** @description Identifier of the client */
- clientID: string;
- };
- RunningInstance: {
- /** @description Identifier of the environment from which is the instance created */
- envID: string;
- /** @description Identifier of the instance */
- instanceID: string;
- /** @description Identifier of the client */
- clientID: string;
- /**
- * Format: date-time
- * @description Time when the instance was started
- */
- startedAt: string;
- metadata?: components["schemas"]["InstanceMetadata"];
- };
};
responses: {
/** Bad request */
@@ -617,8 +357,6 @@ export interface components {
templateID: string;
buildID: string;
sandboxID: string;
- envID: string;
- instanceID: string;
};
}
diff --git a/packages/python-sdk/e2b/api/v1/client/__init__.py b/packages/python-sdk/e2b/api/v1/client/__init__.py
index e076a1163..3fc1bbe80 100644
--- a/packages/python-sdk/e2b/api/v1/client/__init__.py
+++ b/packages/python-sdk/e2b/api/v1/client/__init__.py
@@ -31,16 +31,8 @@ from e2b.api.v1.client.exceptions import ApiAttributeError
from e2b.api.v1.client.exceptions import ApiException
# import models into sdk package
-from e2b.api.v1.client.models.environment import Environment
-from e2b.api.v1.client.models.environment_build import EnvironmentBuild
from e2b.api.v1.client.models.error import Error
-from e2b.api.v1.client.models.instance import Instance
-from e2b.api.v1.client.models.instances_instance_id_refreshes_post_request import (
- InstancesInstanceIDRefreshesPostRequest,
-)
-from e2b.api.v1.client.models.new_instance import NewInstance
from e2b.api.v1.client.models.new_sandbox import NewSandbox
-from e2b.api.v1.client.models.running_instance import RunningInstance
from e2b.api.v1.client.models.running_sandboxes import RunningSandboxes
from e2b.api.v1.client.models.sandbox import Sandbox
from e2b.api.v1.client.models.sandboxes_sandbox_id_refreshes_post_request import (
@@ -48,6 +40,7 @@ from e2b.api.v1.client.models.sandboxes_sandbox_id_refreshes_post_request import
)
from e2b.api.v1.client.models.template import Template
from e2b.api.v1.client.models.template_build import TemplateBuild
+from e2b.api.v1.client.models.template_build_request import TemplateBuildRequest
from e2b.api.v1.client.models.templates_template_id_builds_build_id_logs_post_request import (
TemplatesTemplateIDBuildsBuildIDLogsPostRequest,
)
diff --git a/packages/python-sdk/e2b/api/v1/client/models/__init__.py b/packages/python-sdk/e2b/api/v1/client/models/__init__.py
index ea14b0760..5558c390a 100644
--- a/packages/python-sdk/e2b/api/v1/client/models/__init__.py
+++ b/packages/python-sdk/e2b/api/v1/client/models/__init__.py
@@ -14,16 +14,8 @@
# import models into model package
-from e2b.api.v1.client.models.environment import Environment
-from e2b.api.v1.client.models.environment_build import EnvironmentBuild
from e2b.api.v1.client.models.error import Error
-from e2b.api.v1.client.models.instance import Instance
-from e2b.api.v1.client.models.instances_instance_id_refreshes_post_request import (
- InstancesInstanceIDRefreshesPostRequest,
-)
-from e2b.api.v1.client.models.new_instance import NewInstance
from e2b.api.v1.client.models.new_sandbox import NewSandbox
-from e2b.api.v1.client.models.running_instance import RunningInstance
from e2b.api.v1.client.models.running_sandboxes import RunningSandboxes
from e2b.api.v1.client.models.sandbox import Sandbox
from e2b.api.v1.client.models.sandboxes_sandbox_id_refreshes_post_request import (
@@ -31,6 +23,7 @@ from e2b.api.v1.client.models.sandboxes_sandbox_id_refreshes_post_request import
)
from e2b.api.v1.client.models.template import Template
from e2b.api.v1.client.models.template_build import TemplateBuild
+from e2b.api.v1.client.models.template_build_request import TemplateBuildRequest
from e2b.api.v1.client.models.templates_template_id_builds_build_id_logs_post_request import (
TemplatesTemplateIDBuildsBuildIDLogsPostRequest,
)
diff --git a/packages/python-sdk/e2b/api/v1/client/models/environment.py b/packages/python-sdk/e2b/api/v1/client/models/environment.py
deleted file mode 100644
index 26dbfa8b0..000000000
--- a/packages/python-sdk/e2b/api/v1/client/models/environment.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, Dict, List, Optional
-from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
-
-
-class Environment(BaseModel):
- """
- Environment
- """
-
- env_id: StrictStr = Field(
- ..., alias="envID", description="Identifier of the environment"
- )
- build_id: StrictStr = Field(
- ...,
- alias="buildID",
- description="Identifier of the last successful build for given environment",
- )
- public: StrictBool = Field(
- ...,
- description="Whether the environment is public or only accessible by the team",
- )
- aliases: Optional[conlist(StrictStr)] = Field(
- None, description="Aliases of the environment"
- )
- additional_properties: Dict[str, Any] = {}
- __properties = ["envID", "buildID", "public", "aliases"]
-
- class Config:
- """Pydantic configuration"""
-
- allow_population_by_field_name = True
- validate_assignment = True
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.dict(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> Environment:
- """Create an instance of Environment from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self):
- """Returns the dictionary representation of the model using alias"""
- _dict = self.dict(
- by_alias=True, exclude={"additional_properties"}, exclude_none=True
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: dict) -> Environment:
- """Create an instance of Environment from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return Environment.parse_obj(obj)
-
- _obj = Environment.parse_obj(
- {
- "env_id": obj.get("envID"),
- "build_id": obj.get("buildID"),
- "public": obj.get("public"),
- "aliases": obj.get("aliases"),
- }
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v1/client/models/environment_build.py b/packages/python-sdk/e2b/api/v1/client/models/environment_build.py
deleted file mode 100644
index 374b744f1..000000000
--- a/packages/python-sdk/e2b/api/v1/client/models/environment_build.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, Dict, List, Optional
-from pydantic import BaseModel, Field, StrictStr, conlist, validator
-
-
-class EnvironmentBuild(BaseModel):
- """
- EnvironmentBuild
- """
-
- logs: conlist(StrictStr) = Field(..., description="Build logs")
- env_id: StrictStr = Field(
- ..., alias="envID", description="Identifier of the environment"
- )
- build_id: StrictStr = Field(
- ..., alias="buildID", description="Identifier of the build"
- )
- status: Optional[StrictStr] = Field(None, description="Status of the environment")
- additional_properties: Dict[str, Any] = {}
- __properties = ["logs", "envID", "buildID", "status"]
-
- @validator("status")
- def status_validate_enum(cls, value):
- """Validates the enum"""
- if value is None:
- return value
-
- if value not in ("building", "ready", "error"):
- raise ValueError(
- "must be one of enum values ('building', 'ready', 'error')"
- )
- return value
-
- class Config:
- """Pydantic configuration"""
-
- allow_population_by_field_name = True
- validate_assignment = True
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.dict(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> EnvironmentBuild:
- """Create an instance of EnvironmentBuild from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self):
- """Returns the dictionary representation of the model using alias"""
- _dict = self.dict(
- by_alias=True, exclude={"additional_properties"}, exclude_none=True
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: dict) -> EnvironmentBuild:
- """Create an instance of EnvironmentBuild from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return EnvironmentBuild.parse_obj(obj)
-
- _obj = EnvironmentBuild.parse_obj(
- {
- "logs": obj.get("logs"),
- "env_id": obj.get("envID"),
- "build_id": obj.get("buildID"),
- "status": obj.get("status"),
- }
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v1/client/models/instance.py b/packages/python-sdk/e2b/api/v1/client/models/instance.py
deleted file mode 100644
index cd388e7c5..000000000
--- a/packages/python-sdk/e2b/api/v1/client/models/instance.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, Dict
-from pydantic import BaseModel, Field, StrictStr
-
-
-class Instance(BaseModel):
- """
- Instance
- """
-
- env_id: StrictStr = Field(
- ...,
- alias="envID",
- description="Identifier of the environment from which is the instance created",
- )
- instance_id: StrictStr = Field(
- ..., alias="instanceID", description="Identifier of the instance"
- )
- client_id: StrictStr = Field(
- ..., alias="clientID", description="Identifier of the client"
- )
- additional_properties: Dict[str, Any] = {}
- __properties = ["envID", "instanceID", "clientID"]
-
- class Config:
- """Pydantic configuration"""
-
- allow_population_by_field_name = True
- validate_assignment = True
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.dict(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> Instance:
- """Create an instance of Instance from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self):
- """Returns the dictionary representation of the model using alias"""
- _dict = self.dict(
- by_alias=True, exclude={"additional_properties"}, exclude_none=True
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: dict) -> Instance:
- """Create an instance of Instance from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return Instance.parse_obj(obj)
-
- _obj = Instance.parse_obj(
- {
- "env_id": obj.get("envID"),
- "instance_id": obj.get("instanceID"),
- "client_id": obj.get("clientID"),
- }
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v1/client/models/instances_instance_id_refreshes_post_request.py b/packages/python-sdk/e2b/api/v1/client/models/instances_instance_id_refreshes_post_request.py
deleted file mode 100644
index 7bd8bb95b..000000000
--- a/packages/python-sdk/e2b/api/v1/client/models/instances_instance_id_refreshes_post_request.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, Dict, Optional
-from pydantic import BaseModel, Field, conint
-
-
-class InstancesInstanceIDRefreshesPostRequest(BaseModel):
- """
- InstancesInstanceIDRefreshesPostRequest
- """
-
- duration: Optional[conint(strict=True, le=3600, ge=0)] = Field(
- None,
- description="Duration for which the instance should be kept alive in seconds",
- )
- additional_properties: Dict[str, Any] = {}
- __properties = ["duration"]
-
- class Config:
- """Pydantic configuration"""
-
- allow_population_by_field_name = True
- validate_assignment = True
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.dict(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> InstancesInstanceIDRefreshesPostRequest:
- """Create an instance of InstancesInstanceIDRefreshesPostRequest from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self):
- """Returns the dictionary representation of the model using alias"""
- _dict = self.dict(
- by_alias=True, exclude={"additional_properties"}, exclude_none=True
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: dict) -> InstancesInstanceIDRefreshesPostRequest:
- """Create an instance of InstancesInstanceIDRefreshesPostRequest from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return InstancesInstanceIDRefreshesPostRequest.parse_obj(obj)
-
- _obj = InstancesInstanceIDRefreshesPostRequest.parse_obj(
- {"duration": obj.get("duration")}
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v1/client/models/new_instance.py b/packages/python-sdk/e2b/api/v1/client/models/new_instance.py
deleted file mode 100644
index 557780454..000000000
--- a/packages/python-sdk/e2b/api/v1/client/models/new_instance.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, Dict, Optional
-from pydantic import BaseModel, Field, StrictStr
-
-
-class NewInstance(BaseModel):
- """
- NewInstance
- """
-
- env_id: StrictStr = Field(
- ..., alias="envID", description="Identifier of the required environment"
- )
- metadata: Optional[Dict[str, StrictStr]] = None
- additional_properties: Dict[str, Any] = {}
- __properties = ["envID", "metadata"]
-
- class Config:
- """Pydantic configuration"""
-
- allow_population_by_field_name = True
- validate_assignment = True
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.dict(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> NewInstance:
- """Create an instance of NewInstance from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self):
- """Returns the dictionary representation of the model using alias"""
- _dict = self.dict(
- by_alias=True, exclude={"additional_properties"}, exclude_none=True
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: dict) -> NewInstance:
- """Create an instance of NewInstance from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return NewInstance.parse_obj(obj)
-
- _obj = NewInstance.parse_obj(
- {"env_id": obj.get("envID"), "metadata": obj.get("metadata")}
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v1/client/models/template.py b/packages/python-sdk/e2b/api/v1/client/models/template.py
index 38fdd7b70..d3f5528ab 100644
--- a/packages/python-sdk/e2b/api/v1/client/models/template.py
+++ b/packages/python-sdk/e2b/api/v1/client/models/template.py
@@ -19,7 +19,7 @@ import json
from typing import Any, Dict, List, Optional
-from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
+from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, conlist
class Template(BaseModel):
@@ -35,6 +35,12 @@ class Template(BaseModel):
alias="buildID",
description="Identifier of the last successful build for given template",
)
+ cpu_count: StrictInt = Field(
+ ..., alias="cpuCount", description="CPU cores for the sandbox"
+ )
+ memory_mb: StrictInt = Field(
+ ..., alias="memoryMB", description="Memory limit for the sandbox in MB"
+ )
public: StrictBool = Field(
..., description="Whether the template is public or only accessible by the team"
)
@@ -42,7 +48,14 @@ class Template(BaseModel):
None, description="Aliases of the template"
)
additional_properties: Dict[str, Any] = {}
- __properties = ["templateID", "buildID", "public", "aliases"]
+ __properties = [
+ "templateID",
+ "buildID",
+ "cpuCount",
+ "memoryMB",
+ "public",
+ "aliases",
+ ]
class Config:
"""Pydantic configuration"""
@@ -88,6 +101,8 @@ class Template(BaseModel):
{
"template_id": obj.get("templateID"),
"build_id": obj.get("buildID"),
+ "cpu_count": obj.get("cpuCount"),
+ "memory_mb": obj.get("memoryMB"),
"public": obj.get("public"),
"aliases": obj.get("aliases"),
}
diff --git a/packages/python-sdk/e2b/api/v1/client/models/running_instance.py b/packages/python-sdk/e2b/api/v1/client/models/template_build_request.py
similarity index 56%
rename from packages/python-sdk/e2b/api/v1/client/models/running_instance.py
rename to packages/python-sdk/e2b/api/v1/client/models/template_build_request.py
index 6054115ff..cd4f3bbd8 100644
--- a/packages/python-sdk/e2b/api/v1/client/models/running_instance.py
+++ b/packages/python-sdk/e2b/api/v1/client/models/template_build_request.py
@@ -17,33 +17,31 @@ import pprint
import re # noqa: F401
import json
-from datetime import datetime
+
from typing import Any, Dict, Optional
-from pydantic import BaseModel, Field, StrictStr
+from pydantic import BaseModel, Field, StrictStr, conint
-class RunningInstance(BaseModel):
+class TemplateBuildRequest(BaseModel):
"""
- RunningInstance
+ TemplateBuildRequest
"""
- env_id: StrictStr = Field(
- ...,
- alias="envID",
- description="Identifier of the environment from which is the instance created",
- )
- instance_id: StrictStr = Field(
- ..., alias="instanceID", description="Identifier of the instance"
+ alias: Optional[StrictStr] = Field(None, description="Alias of the template")
+ dockerfile: StrictStr = Field(..., description="Dockerfile for the template")
+ start_cmd: Optional[StrictStr] = Field(
+ None,
+ alias="startCmd",
+ description="Start command to execute in the template after the build",
)
- client_id: StrictStr = Field(
- ..., alias="clientID", description="Identifier of the client"
+ cpu_count: Optional[conint(strict=True, ge=1)] = Field(
+ None, alias="cpuCount", description="CPU cores for the template"
)
- started_at: datetime = Field(
- ..., alias="startedAt", description="Time when the instance was started"
+ memory_mb: Optional[conint(strict=True, ge=128)] = Field(
+ None, alias="memoryMB", description="Memory limit for the template in MB"
)
- metadata: Optional[Dict[str, StrictStr]] = None
additional_properties: Dict[str, Any] = {}
- __properties = ["envID", "instanceID", "clientID", "startedAt", "metadata"]
+ __properties = ["alias", "dockerfile", "startCmd", "cpuCount", "memoryMB"]
class Config:
"""Pydantic configuration"""
@@ -60,8 +58,8 @@ class RunningInstance(BaseModel):
return json.dumps(self.to_dict())
@classmethod
- def from_json(cls, json_str: str) -> RunningInstance:
- """Create an instance of RunningInstance from a JSON string"""
+ def from_json(cls, json_str: str) -> TemplateBuildRequest:
+ """Create an instance of TemplateBuildRequest from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
@@ -77,21 +75,21 @@ class RunningInstance(BaseModel):
return _dict
@classmethod
- def from_dict(cls, obj: dict) -> RunningInstance:
- """Create an instance of RunningInstance from a dict"""
+ def from_dict(cls, obj: dict) -> TemplateBuildRequest:
+ """Create an instance of TemplateBuildRequest from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
- return RunningInstance.parse_obj(obj)
+ return TemplateBuildRequest.parse_obj(obj)
- _obj = RunningInstance.parse_obj(
+ _obj = TemplateBuildRequest.parse_obj(
{
- "env_id": obj.get("envID"),
- "instance_id": obj.get("instanceID"),
- "client_id": obj.get("clientID"),
- "started_at": obj.get("startedAt"),
- "metadata": obj.get("metadata"),
+ "alias": obj.get("alias"),
+ "dockerfile": obj.get("dockerfile"),
+ "start_cmd": obj.get("startCmd"),
+ "cpu_count": obj.get("cpuCount"),
+ "memory_mb": obj.get("memoryMB"),
}
)
# store additional fields in additional_properties
diff --git a/packages/python-sdk/e2b/api/v1/client_README.md b/packages/python-sdk/e2b/api/v1/client_README.md
index 137e0294c..e4e2048b7 100644
--- a/packages/python-sdk/e2b/api/v1/client_README.md
+++ b/packages/python-sdk/e2b/api/v1/client_README.md
@@ -80,19 +80,14 @@ Class | Method | HTTP request | Description
## Documentation For Models
- - [Environment](e2b/api/v1/client/docs/Environment.md)
- - [EnvironmentBuild](e2b/api/v1/client/docs/EnvironmentBuild.md)
- [Error](e2b/api/v1/client/docs/Error.md)
- - [Instance](e2b/api/v1/client/docs/Instance.md)
- - [InstancesInstanceIDRefreshesPostRequest](e2b/api/v1/client/docs/InstancesInstanceIDRefreshesPostRequest.md)
- - [NewInstance](e2b/api/v1/client/docs/NewInstance.md)
- [NewSandbox](e2b/api/v1/client/docs/NewSandbox.md)
- - [RunningInstance](e2b/api/v1/client/docs/RunningInstance.md)
- [RunningSandboxes](e2b/api/v1/client/docs/RunningSandboxes.md)
- [Sandbox](e2b/api/v1/client/docs/Sandbox.md)
- [SandboxesSandboxIDRefreshesPostRequest](e2b/api/v1/client/docs/SandboxesSandboxIDRefreshesPostRequest.md)
- [Template](e2b/api/v1/client/docs/Template.md)
- [TemplateBuild](e2b/api/v1/client/docs/TemplateBuild.md)
+ - [TemplateBuildRequest](e2b/api/v1/client/docs/TemplateBuildRequest.md)
- [TemplatesTemplateIDBuildsBuildIDLogsPostRequest](e2b/api/v1/client/docs/TemplatesTemplateIDBuildsBuildIDLogsPostRequest.md)
diff --git a/packages/python-sdk/e2b/api/v2/client/__init__.py b/packages/python-sdk/e2b/api/v2/client/__init__.py
index 31403aff1..88f895f0c 100644
--- a/packages/python-sdk/e2b/api/v2/client/__init__.py
+++ b/packages/python-sdk/e2b/api/v2/client/__init__.py
@@ -31,16 +31,8 @@ from e2b.api.v2.client.exceptions import ApiAttributeError
from e2b.api.v2.client.exceptions import ApiException
# import models into sdk package
-from e2b.api.v2.client.models.environment import Environment
-from e2b.api.v2.client.models.environment_build import EnvironmentBuild
from e2b.api.v2.client.models.error import Error
-from e2b.api.v2.client.models.instance import Instance
-from e2b.api.v2.client.models.instances_instance_id_refreshes_post_request import (
- InstancesInstanceIDRefreshesPostRequest,
-)
-from e2b.api.v2.client.models.new_instance import NewInstance
from e2b.api.v2.client.models.new_sandbox import NewSandbox
-from e2b.api.v2.client.models.running_instance import RunningInstance
from e2b.api.v2.client.models.running_sandboxes import RunningSandboxes
from e2b.api.v2.client.models.sandbox import Sandbox
from e2b.api.v2.client.models.sandboxes_sandbox_id_refreshes_post_request import (
@@ -48,6 +40,7 @@ from e2b.api.v2.client.models.sandboxes_sandbox_id_refreshes_post_request import
)
from e2b.api.v2.client.models.template import Template
from e2b.api.v2.client.models.template_build import TemplateBuild
+from e2b.api.v2.client.models.template_build_request import TemplateBuildRequest
from e2b.api.v2.client.models.templates_template_id_builds_build_id_logs_post_request import (
TemplatesTemplateIDBuildsBuildIDLogsPostRequest,
)
diff --git a/packages/python-sdk/e2b/api/v2/client/models/__init__.py b/packages/python-sdk/e2b/api/v2/client/models/__init__.py
index 0b0cbf222..c4c737a46 100644
--- a/packages/python-sdk/e2b/api/v2/client/models/__init__.py
+++ b/packages/python-sdk/e2b/api/v2/client/models/__init__.py
@@ -14,16 +14,8 @@
# import models into model package
-from e2b.api.v2.client.models.environment import Environment
-from e2b.api.v2.client.models.environment_build import EnvironmentBuild
from e2b.api.v2.client.models.error import Error
-from e2b.api.v2.client.models.instance import Instance
-from e2b.api.v2.client.models.instances_instance_id_refreshes_post_request import (
- InstancesInstanceIDRefreshesPostRequest,
-)
-from e2b.api.v2.client.models.new_instance import NewInstance
from e2b.api.v2.client.models.new_sandbox import NewSandbox
-from e2b.api.v2.client.models.running_instance import RunningInstance
from e2b.api.v2.client.models.running_sandboxes import RunningSandboxes
from e2b.api.v2.client.models.sandbox import Sandbox
from e2b.api.v2.client.models.sandboxes_sandbox_id_refreshes_post_request import (
@@ -31,6 +23,7 @@ from e2b.api.v2.client.models.sandboxes_sandbox_id_refreshes_post_request import
)
from e2b.api.v2.client.models.template import Template
from e2b.api.v2.client.models.template_build import TemplateBuild
+from e2b.api.v2.client.models.template_build_request import TemplateBuildRequest
from e2b.api.v2.client.models.templates_template_id_builds_build_id_logs_post_request import (
TemplatesTemplateIDBuildsBuildIDLogsPostRequest,
)
diff --git a/packages/python-sdk/e2b/api/v2/client/models/environment.py b/packages/python-sdk/e2b/api/v2/client/models/environment.py
deleted file mode 100644
index 99fc8d46e..000000000
--- a/packages/python-sdk/e2b/api/v2/client/models/environment.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, ClassVar, Dict, List, Optional
-from pydantic import BaseModel, StrictBool, StrictStr
-from pydantic import Field
-
-try:
- from typing import Self
-except ImportError:
- from typing_extensions import Self
-
-
-class Environment(BaseModel):
- """
- Environment
- """ # noqa: E501
-
- env_id: StrictStr = Field(
- description="Identifier of the environment", alias="envID"
- )
- build_id: StrictStr = Field(
- description="Identifier of the last successful build for given environment",
- alias="buildID",
- )
- public: StrictBool = Field(
- description="Whether the environment is public or only accessible by the team"
- )
- aliases: Optional[List[StrictStr]] = Field(
- default=None, description="Aliases of the environment"
- )
- additional_properties: Dict[str, Any] = {}
- __properties: ClassVar[List[str]] = ["envID", "buildID", "public", "aliases"]
-
- model_config = {"populate_by_name": True, "validate_assignment": True}
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.model_dump(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> Self:
- """Create an instance of Environment from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self) -> Dict[str, Any]:
- """Return the dictionary representation of the model using alias.
-
- This has the following differences from calling pydantic's
- `self.model_dump(by_alias=True)`:
-
- * `None` is only added to the output dict for nullable fields that
- were set at model initialization. Other fields with value `None`
- are ignored.
- * Fields in `self.additional_properties` are added to the output dict.
- """
- _dict = self.model_dump(
- by_alias=True,
- exclude={
- "additional_properties",
- },
- exclude_none=True,
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: Dict) -> Self:
- """Create an instance of Environment from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return cls.model_validate(obj)
-
- _obj = cls.model_validate(
- {
- "envID": obj.get("envID"),
- "buildID": obj.get("buildID"),
- "public": obj.get("public"),
- "aliases": obj.get("aliases"),
- }
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v2/client/models/environment_build.py b/packages/python-sdk/e2b/api/v2/client/models/environment_build.py
deleted file mode 100644
index 9fe0cf0f7..000000000
--- a/packages/python-sdk/e2b/api/v2/client/models/environment_build.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, ClassVar, Dict, List, Optional
-from pydantic import BaseModel, StrictStr, field_validator
-from pydantic import Field
-
-try:
- from typing import Self
-except ImportError:
- from typing_extensions import Self
-
-
-class EnvironmentBuild(BaseModel):
- """
- EnvironmentBuild
- """ # noqa: E501
-
- logs: List[StrictStr] = Field(description="Build logs")
- env_id: StrictStr = Field(
- description="Identifier of the environment", alias="envID"
- )
- build_id: StrictStr = Field(description="Identifier of the build", alias="buildID")
- status: Optional[StrictStr] = Field(
- default=None, description="Status of the environment"
- )
- additional_properties: Dict[str, Any] = {}
- __properties: ClassVar[List[str]] = ["logs", "envID", "buildID", "status"]
-
- @field_validator("status")
- def status_validate_enum(cls, value):
- """Validates the enum"""
- if value is None:
- return value
-
- if value not in ("building", "ready", "error"):
- raise ValueError(
- "must be one of enum values ('building', 'ready', 'error')"
- )
- return value
-
- model_config = {"populate_by_name": True, "validate_assignment": True}
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.model_dump(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> Self:
- """Create an instance of EnvironmentBuild from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self) -> Dict[str, Any]:
- """Return the dictionary representation of the model using alias.
-
- This has the following differences from calling pydantic's
- `self.model_dump(by_alias=True)`:
-
- * `None` is only added to the output dict for nullable fields that
- were set at model initialization. Other fields with value `None`
- are ignored.
- * Fields in `self.additional_properties` are added to the output dict.
- """
- _dict = self.model_dump(
- by_alias=True,
- exclude={
- "additional_properties",
- },
- exclude_none=True,
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: Dict) -> Self:
- """Create an instance of EnvironmentBuild from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return cls.model_validate(obj)
-
- _obj = cls.model_validate(
- {
- "logs": obj.get("logs"),
- "envID": obj.get("envID"),
- "buildID": obj.get("buildID"),
- "status": obj.get("status"),
- }
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v2/client/models/instance.py b/packages/python-sdk/e2b/api/v2/client/models/instance.py
deleted file mode 100644
index b7a2c4c45..000000000
--- a/packages/python-sdk/e2b/api/v2/client/models/instance.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, ClassVar, Dict, List
-from pydantic import BaseModel, StrictStr
-from pydantic import Field
-
-try:
- from typing import Self
-except ImportError:
- from typing_extensions import Self
-
-
-class Instance(BaseModel):
- """
- Instance
- """ # noqa: E501
-
- env_id: StrictStr = Field(
- description="Identifier of the environment from which is the instance created",
- alias="envID",
- )
- instance_id: StrictStr = Field(
- description="Identifier of the instance", alias="instanceID"
- )
- client_id: StrictStr = Field(
- description="Identifier of the client", alias="clientID"
- )
- additional_properties: Dict[str, Any] = {}
- __properties: ClassVar[List[str]] = ["envID", "instanceID", "clientID"]
-
- model_config = {"populate_by_name": True, "validate_assignment": True}
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.model_dump(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> Self:
- """Create an instance of Instance from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self) -> Dict[str, Any]:
- """Return the dictionary representation of the model using alias.
-
- This has the following differences from calling pydantic's
- `self.model_dump(by_alias=True)`:
-
- * `None` is only added to the output dict for nullable fields that
- were set at model initialization. Other fields with value `None`
- are ignored.
- * Fields in `self.additional_properties` are added to the output dict.
- """
- _dict = self.model_dump(
- by_alias=True,
- exclude={
- "additional_properties",
- },
- exclude_none=True,
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: Dict) -> Self:
- """Create an instance of Instance from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return cls.model_validate(obj)
-
- _obj = cls.model_validate(
- {
- "envID": obj.get("envID"),
- "instanceID": obj.get("instanceID"),
- "clientID": obj.get("clientID"),
- }
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v2/client/models/instances_instance_id_refreshes_post_request.py b/packages/python-sdk/e2b/api/v2/client/models/instances_instance_id_refreshes_post_request.py
deleted file mode 100644
index a22b06ec4..000000000
--- a/packages/python-sdk/e2b/api/v2/client/models/instances_instance_id_refreshes_post_request.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, ClassVar, Dict, List, Optional
-from pydantic import BaseModel
-from pydantic import Field
-from typing_extensions import Annotated
-
-try:
- from typing import Self
-except ImportError:
- from typing_extensions import Self
-
-
-class InstancesInstanceIDRefreshesPostRequest(BaseModel):
- """
- InstancesInstanceIDRefreshesPostRequest
- """ # noqa: E501
-
- duration: Optional[Annotated[int, Field(le=3600, strict=True, ge=0)]] = Field(
- default=None,
- description="Duration for which the instance should be kept alive in seconds",
- )
- additional_properties: Dict[str, Any] = {}
- __properties: ClassVar[List[str]] = ["duration"]
-
- model_config = {"populate_by_name": True, "validate_assignment": True}
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.model_dump(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> Self:
- """Create an instance of InstancesInstanceIDRefreshesPostRequest from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self) -> Dict[str, Any]:
- """Return the dictionary representation of the model using alias.
-
- This has the following differences from calling pydantic's
- `self.model_dump(by_alias=True)`:
-
- * `None` is only added to the output dict for nullable fields that
- were set at model initialization. Other fields with value `None`
- are ignored.
- * Fields in `self.additional_properties` are added to the output dict.
- """
- _dict = self.model_dump(
- by_alias=True,
- exclude={
- "additional_properties",
- },
- exclude_none=True,
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: Dict) -> Self:
- """Create an instance of InstancesInstanceIDRefreshesPostRequest from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return cls.model_validate(obj)
-
- _obj = cls.model_validate({"duration": obj.get("duration")})
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v2/client/models/new_instance.py b/packages/python-sdk/e2b/api/v2/client/models/new_instance.py
deleted file mode 100644
index 6b5aced04..000000000
--- a/packages/python-sdk/e2b/api/v2/client/models/new_instance.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# coding: utf-8
-
-"""
- E2B API
-
- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
-
- The version of the OpenAPI document: 0.1.0
- Generated by OpenAPI Generator (https://openapi-generator.tech)
-
- Do not edit the class manually.
-""" # noqa: E501
-
-
-from __future__ import annotations
-import pprint
-import re # noqa: F401
-import json
-
-
-from typing import Any, ClassVar, Dict, List, Optional
-from pydantic import BaseModel, StrictStr
-from pydantic import Field
-
-try:
- from typing import Self
-except ImportError:
- from typing_extensions import Self
-
-
-class NewInstance(BaseModel):
- """
- NewInstance
- """ # noqa: E501
-
- env_id: StrictStr = Field(
- description="Identifier of the required environment", alias="envID"
- )
- metadata: Optional[Dict[str, StrictStr]] = None
- additional_properties: Dict[str, Any] = {}
- __properties: ClassVar[List[str]] = ["envID", "metadata"]
-
- model_config = {"populate_by_name": True, "validate_assignment": True}
-
- def to_str(self) -> str:
- """Returns the string representation of the model using alias"""
- return pprint.pformat(self.model_dump(by_alias=True))
-
- def to_json(self) -> str:
- """Returns the JSON representation of the model using alias"""
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
- return json.dumps(self.to_dict())
-
- @classmethod
- def from_json(cls, json_str: str) -> Self:
- """Create an instance of NewInstance from a JSON string"""
- return cls.from_dict(json.loads(json_str))
-
- def to_dict(self) -> Dict[str, Any]:
- """Return the dictionary representation of the model using alias.
-
- This has the following differences from calling pydantic's
- `self.model_dump(by_alias=True)`:
-
- * `None` is only added to the output dict for nullable fields that
- were set at model initialization. Other fields with value `None`
- are ignored.
- * Fields in `self.additional_properties` are added to the output dict.
- """
- _dict = self.model_dump(
- by_alias=True,
- exclude={
- "additional_properties",
- },
- exclude_none=True,
- )
- # puts key-value pairs in additional_properties in the top level
- if self.additional_properties is not None:
- for _key, _value in self.additional_properties.items():
- _dict[_key] = _value
-
- return _dict
-
- @classmethod
- def from_dict(cls, obj: Dict) -> Self:
- """Create an instance of NewInstance from a dict"""
- if obj is None:
- return None
-
- if not isinstance(obj, dict):
- return cls.model_validate(obj)
-
- _obj = cls.model_validate(
- {"envID": obj.get("envID"), "metadata": obj.get("metadata")}
- )
- # store additional fields in additional_properties
- for _key in obj.keys():
- if _key not in cls.__properties:
- _obj.additional_properties[_key] = obj.get(_key)
-
- return _obj
diff --git a/packages/python-sdk/e2b/api/v2/client/models/template.py b/packages/python-sdk/e2b/api/v2/client/models/template.py
index e941b8c9d..5357bc750 100644
--- a/packages/python-sdk/e2b/api/v2/client/models/template.py
+++ b/packages/python-sdk/e2b/api/v2/client/models/template.py
@@ -19,7 +19,7 @@ import json
from typing import Any, ClassVar, Dict, List, Optional
-from pydantic import BaseModel, StrictBool, StrictStr
+from pydantic import BaseModel, StrictBool, StrictInt, StrictStr
from pydantic import Field
try:
@@ -40,6 +40,12 @@ class Template(BaseModel):
description="Identifier of the last successful build for given template",
alias="buildID",
)
+ cpu_count: StrictInt = Field(
+ description="CPU cores for the sandbox", alias="cpuCount"
+ )
+ memory_mb: StrictInt = Field(
+ description="Memory limit for the sandbox in MB", alias="memoryMB"
+ )
public: StrictBool = Field(
description="Whether the template is public or only accessible by the team"
)
@@ -47,7 +53,14 @@ class Template(BaseModel):
default=None, description="Aliases of the template"
)
additional_properties: Dict[str, Any] = {}
- __properties: ClassVar[List[str]] = ["templateID", "buildID", "public", "aliases"]
+ __properties: ClassVar[List[str]] = [
+ "templateID",
+ "buildID",
+ "cpuCount",
+ "memoryMB",
+ "public",
+ "aliases",
+ ]
model_config = {"populate_by_name": True, "validate_assignment": True}
@@ -103,6 +116,8 @@ class Template(BaseModel):
{
"templateID": obj.get("templateID"),
"buildID": obj.get("buildID"),
+ "cpuCount": obj.get("cpuCount"),
+ "memoryMB": obj.get("memoryMB"),
"public": obj.get("public"),
"aliases": obj.get("aliases"),
}
diff --git a/packages/python-sdk/e2b/api/v2/client/models/running_instance.py b/packages/python-sdk/e2b/api/v2/client/models/template_build_request.py
similarity index 68%
rename from packages/python-sdk/e2b/api/v2/client/models/running_instance.py
rename to packages/python-sdk/e2b/api/v2/client/models/template_build_request.py
index c072168b1..e9d50c619 100644
--- a/packages/python-sdk/e2b/api/v2/client/models/running_instance.py
+++ b/packages/python-sdk/e2b/api/v2/client/models/template_build_request.py
@@ -17,10 +17,11 @@ import pprint
import re # noqa: F401
import json
-from datetime import datetime
+
from typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictStr
from pydantic import Field
+from typing_extensions import Annotated
try:
from typing import Self
@@ -28,32 +29,35 @@ except ImportError:
from typing_extensions import Self
-class RunningInstance(BaseModel):
+class TemplateBuildRequest(BaseModel):
"""
- RunningInstance
+ TemplateBuildRequest
""" # noqa: E501
- env_id: StrictStr = Field(
- description="Identifier of the environment from which is the instance created",
- alias="envID",
+ alias: Optional[StrictStr] = Field(
+ default=None, description="Alias of the template"
)
- instance_id: StrictStr = Field(
- description="Identifier of the instance", alias="instanceID"
+ dockerfile: StrictStr = Field(description="Dockerfile for the template")
+ start_cmd: Optional[StrictStr] = Field(
+ default=None,
+ description="Start command to execute in the template after the build",
+ alias="startCmd",
)
- client_id: StrictStr = Field(
- description="Identifier of the client", alias="clientID"
+ cpu_count: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(
+ default=None, description="CPU cores for the template", alias="cpuCount"
)
- started_at: datetime = Field(
- description="Time when the instance was started", alias="startedAt"
+ memory_mb: Optional[Annotated[int, Field(strict=True, ge=128)]] = Field(
+ default=None,
+ description="Memory limit for the template in MB",
+ alias="memoryMB",
)
- metadata: Optional[Dict[str, StrictStr]] = None
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = [
- "envID",
- "instanceID",
- "clientID",
- "startedAt",
- "metadata",
+ "alias",
+ "dockerfile",
+ "startCmd",
+ "cpuCount",
+ "memoryMB",
]
model_config = {"populate_by_name": True, "validate_assignment": True}
@@ -69,7 +73,7 @@ class RunningInstance(BaseModel):
@classmethod
def from_json(cls, json_str: str) -> Self:
- """Create an instance of RunningInstance from a JSON string"""
+ """Create an instance of TemplateBuildRequest from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
@@ -99,7 +103,7 @@ class RunningInstance(BaseModel):
@classmethod
def from_dict(cls, obj: Dict) -> Self:
- """Create an instance of RunningInstance from a dict"""
+ """Create an instance of TemplateBuildRequest from a dict"""
if obj is None:
return None
@@ -108,11 +112,11 @@ class RunningInstance(BaseModel):
_obj = cls.model_validate(
{
- "envID": obj.get("envID"),
- "instanceID": obj.get("instanceID"),
- "clientID": obj.get("clientID"),
- "startedAt": obj.get("startedAt"),
- "metadata": obj.get("metadata"),
+ "alias": obj.get("alias"),
+ "dockerfile": obj.get("dockerfile"),
+ "startCmd": obj.get("startCmd"),
+ "cpuCount": obj.get("cpuCount"),
+ "memoryMB": obj.get("memoryMB"),
}
)
# store additional fields in additional_properties
diff --git a/packages/python-sdk/e2b/api/v2/client_README.md b/packages/python-sdk/e2b/api/v2/client_README.md
index 93e0e1659..36efbadd9 100644
--- a/packages/python-sdk/e2b/api/v2/client_README.md
+++ b/packages/python-sdk/e2b/api/v2/client_README.md
@@ -79,19 +79,14 @@ Class | Method | HTTP request | Description
## Documentation For Models
- - [Environment](e2b/api/v2/client/docs/Environment.md)
- - [EnvironmentBuild](e2b/api/v2/client/docs/EnvironmentBuild.md)
- [Error](e2b/api/v2/client/docs/Error.md)
- - [Instance](e2b/api/v2/client/docs/Instance.md)
- - [InstancesInstanceIDRefreshesPostRequest](e2b/api/v2/client/docs/InstancesInstanceIDRefreshesPostRequest.md)
- - [NewInstance](e2b/api/v2/client/docs/NewInstance.md)
- [NewSandbox](e2b/api/v2/client/docs/NewSandbox.md)
- - [RunningInstance](e2b/api/v2/client/docs/RunningInstance.md)
- [RunningSandboxes](e2b/api/v2/client/docs/RunningSandboxes.md)
- [Sandbox](e2b/api/v2/client/docs/Sandbox.md)
- [SandboxesSandboxIDRefreshesPostRequest](e2b/api/v2/client/docs/SandboxesSandboxIDRefreshesPostRequest.md)
- [Template](e2b/api/v2/client/docs/Template.md)
- [TemplateBuild](e2b/api/v2/client/docs/TemplateBuild.md)
+ - [TemplateBuildRequest](e2b/api/v2/client/docs/TemplateBuildRequest.md)
- [TemplatesTemplateIDBuildsBuildIDLogsPostRequest](e2b/api/v2/client/docs/TemplatesTemplateIDBuildsBuildIDLogsPostRequest.md)
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f7b3c0384..42fd2fc19 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -242,15 +242,9 @@ importers:
packages/cli:
dependencies:
- '@balena/dockerignore':
- specifier: ^1.0.2
- version: 1.0.2
'@iarna/toml':
specifier: ^2.2.5
version: 2.2.5
- '@nodelib/fs.walk':
- specifier: ^2.0.0
- version: 2.0.0
async-listen:
specifier: ^3.0.1
version: 3.0.1
@@ -263,6 +257,9 @@ importers:
cli-highlight:
specifier: ^2.1.11
version: 2.1.11
+ command-exists:
+ specifier: ^1.2.9
+ version: 1.2.9
commander:
specifier: ^11.1.0
version: 11.1.0
@@ -272,9 +269,6 @@ importers:
e2b:
specifier: ^0.12.6
version: 0.12.6([email protected])
- ignore:
- specifier: ^5.2.4
- version: 5.2.4
inquirer:
specifier: ^9.2.12
version: 9.2.12
@@ -284,9 +278,6 @@ importers:
strip-ansi:
specifier: ^7.1.0
version: 7.1.0
- tar-fs:
- specifier: ^3.0.4
- version: 3.0.4
update-notifier:
specifier: 5.1.0
version: 5.1.0
@@ -294,15 +285,15 @@ importers:
specifier: ^1.3.2
version: 1.3.2
devDependencies:
+ '@types/command-exists':
+ specifier: ^1.2.3
+ version: 1.2.3
'@types/inquirer':
specifier: ^9.0.7
version: 9.0.7
'@types/node':
specifier: ^18.18.6
version: 18.18.6
- '@types/tar-fs':
- specifier: ^2.0.3
- version: 2.0.3
'@types/update-notifier':
specifier: 6.0.5
version: 6.0.5
@@ -557,10 +548,6 @@ packages:
dependencies:
regenerator-runtime: 0.14.0
- /@balena/[email protected]:
- resolution: {integrity: sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==}
- dev: false
-
/@changesets/[email protected]:
resolution: {integrity: sha512-FMpKF1fRlJyCZVYHr3CbinpZZ+6MwvOtWUuO8uo+svcATEoc1zRDcj23pAurJ2TZ/uVz1wFHH6K3NlACy0PLew==}
dependencies:
@@ -1678,6 +1665,7 @@ packages:
dependencies:
'@nodelib/fs.stat': 3.0.0
run-parallel: 1.2.0
+ dev: true
/@nodelib/[email protected]:
resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==}
@@ -1686,6 +1674,7 @@ packages:
/@nodelib/[email protected]:
resolution: {integrity: sha512-2tQOI38s19P9i7X/Drt0v8iMA+KMsgdhB/dyPER+e+2Y8L1Z7QvnuRdW/uLuf5YRFUYmnj4bMA6qCuZHFI1GDQ==}
engines: {node: '>=16.14.0'}
+ dev: true
/@nodelib/[email protected]:
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
@@ -1700,6 +1689,7 @@ packages:
dependencies:
'@nodelib/fs.scandir': 3.0.0
fastq: 1.15.0
+ dev: true
resolution: {integrity: sha512-7kZUAaLscfgbwBQRbvdMYaZOWyMEcPTH/tJjnyAWJ/dvvs9Ef+CERx/qJb9GExJpl1qipaDGn7KqHnFGGixd0w==}
@@ -2830,6 +2820,10 @@ packages:
resolution: {integrity: sha512-69TtiDzu0bcmKQv3yg1Zx409/Kd7r0b5F1PfpYJfSHzLGtB53547V4u+9iqKYsTu/O2ai6KTb0TInNpvuQ3qmg==}
dev: true
+ resolution: {integrity: sha512-PpbaE2XWLaWYboXD6k70TcXO/OdOyyRFq5TVpmlUELNxdkkmXU9fkImNosmXU1DtsNrqdUgWd/nJQYXgwmtdXQ==}
+ dev: true
+
resolution: {integrity: sha512-ML2U2xzN6PwCh1I6QgWI3TdzS7CRLsv5DSCLX4/Wfg+f30JF60WgS9ZbVOOrTk+N67WTCSUKm6Q7k6M/BjbXQw==}
dev: true
@@ -3008,19 +3002,6 @@ packages:
resolution: {integrity: sha512-7aqorHYgdNO4DM36stTiGO3DvKoex9TQRwsJU6vMaFGyqpBA1MNZkz+PG3gaNUPpTAOYhT1WR7M1JyA3fbS9Cw==}
- resolution: {integrity: sha512-ADS99HAnztB8MD+LSOdzDrDLcSe5oBIg+SUQwwsgnsOgZobWoSqYmg9ZJWdvLppoKV8R8kZinX6Om+LlsNuIlQ==}
- dependencies:
- '@types/node': 18.18.6
- '@types/tar-stream': 3.1.2
- dev: true
-
- resolution: {integrity: sha512-qnIpUItVb5u8jl3kbrHofkM40ggO3YKSzc7TWqLYjDdwlrL7CiEAkDySaGfeUBLtC50RTfh2acdz51ItUbV7pQ==}
- dependencies:
- '@types/node': 18.18.6
- dev: true
-
resolution: {integrity: sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==}
dependencies:
@@ -3926,6 +3907,7 @@ packages:
resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==}
+ dev: true
resolution: {integrity: sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==}
@@ -4479,6 +4461,10 @@ packages:
resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==}
dev: false
+ resolution: {integrity: sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==}
+ dev: false
+
resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==}
engines: {node: '>=14'}
@@ -5626,6 +5612,7 @@ packages:
resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==}
+ dev: true
resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==}
@@ -8092,6 +8079,7 @@ packages:
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
+ dev: true
resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==}
@@ -9235,6 +9223,7 @@ packages:
resolution: {integrity: sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==}
+ dev: true
resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==}
@@ -10072,6 +10061,7 @@ packages:
dependencies:
fast-fifo: 1.3.2
queue-tick: 1.0.1
+ dev: true
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
@@ -10345,6 +10335,7 @@ packages:
mkdirp-classic: 0.5.3
pump: 3.0.0
tar-stream: 3.1.6
+ dev: true
resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
@@ -10363,6 +10354,7 @@ packages:
b4a: 1.6.4
fast-fifo: 1.3.2
streamx: 2.15.1
+ dev: true
resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==}
diff --git a/spec/openapi.yml b/spec/openapi.yml
index bc5cb0495..66e01a5f8 100644
--- a/spec/openapi.yml
+++ b/spec/openapi.yml
@@ -36,20 +36,6 @@ components:
required: true
schema:
type: string
- # ------ Deprecated --------
- envID:
- name: envID
- in: path
- required: true
- schema:
- type: string
- instanceID:
- name: instanceID
- in: path
- required: true
- schema:
- type: string
- # ----------------------
responses:
400:
@@ -151,6 +137,9 @@ components:
required:
- templateID
- buildID
+ - cpuCount
+ - memoryMB
+ - storageGB
- public
properties:
templateID:
@@ -159,6 +148,12 @@ components:
buildID:
type: string
description: Identifier of the last successful build for given template
+ cpuCount:
+ type: integer
+ description: CPU cores for the sandbox
+ memoryMB:
+ type: integer
+ description: Memory limit for the sandbox in MB
public:
type: boolean
description: Whether the template is public or only accessible by the team
@@ -168,6 +163,28 @@ components:
items:
type: string
+ TemplateBuildRequest:
+ required:
+ - dockerfile
+ properties:
+ alias:
+ description: Alias of the template
+ type: string
+ dockerfile:
+ description: Dockerfile for the template
+ type: string
+ startCmd:
+ description: Start command to execute in the template after the build
+ type: string
+ cpuCount:
+ description: CPU cores for the template
+ type: integer
+ minimum: 1
+ memoryMB:
+ description: Memory limit for the template in MB
+ type: integer
+ minimum: 128
+
TemplateBuild:
required:
- templateID
@@ -207,117 +224,10 @@ components:
message:
type: string
description: Error
- # ------ Deprecated --------
- Environment:
- required:
- - envID
- - buildID
- - public
- properties:
- envID:
- type: string
- description: Identifier of the environment
- buildID:
- type: string
- description: Identifier of the last successful build for given environment
- public:
- type: boolean
- description: Whether the environment is public or only accessible by the team
- aliases:
- type: array
- description: Aliases of the environment
- items:
- type: string
-
- EnvironmentBuild:
- required:
- - envID
- - buildID
- - finished
- - logs
- properties:
- logs:
- default: []
- description: Build logs
- type: array
- items:
- type: string
- envID:
- type: string
- description: Identifier of the environment
- buildID:
- type: string
- description: Identifier of the build
- status:
- type: string
- description: Status of the environment
- enum:
- - building
- - ready
- - error
-
- InstanceMetadata:
- additionalProperties:
- type: string
- description: Metadata of the instance
-
- NewInstance:
- required:
- - envID
- properties:
- envID:
- type: string
- description: Identifier of the required environment
- metadata:
- $ref: "#/components/schemas/InstanceMetadata"
-
- Instance:
- required:
- - envID
- - instanceID
- - clientID
- properties:
- envID:
- type: string
- description: Identifier of the environment from which is the instance created
- instanceID:
- type: string
- description: Identifier of the instance
- clientID:
- type: string
- description: Identifier of the client
-
- RunningInstance:
- required:
- - envID
- - instanceID
- - clientID
- - startedAt
- properties:
- envID:
- type: string
- description: Identifier of the environment from which is the instance created
- instanceID:
- type: string
- description: Identifier of the instance
- clientID:
- type: string
- description: Identifier of the client
- startedAt:
- type: string
- format: date-time
- description: Time when the instance was started
- metadata:
- $ref: "#/components/schemas/InstanceMetadata"
-# ---------------------
tags:
- name: templates
- name: sandboxes
- # ------ Deprecated --------
- - name: instances
- - name: envs
-# ---------------------------
paths:
/health:
@@ -450,39 +360,13 @@ paths:
requestBody:
required: true
content:
- multipart/form-data:
+ application/json:
schema:
- type: object
- required:
- - buildContext
- - dockerfile
- properties:
- alias:
- description: Alias of the template
- type: string
- buildContext:
- description: Docker build context
- type: string
- format: binary
- dockerfile:
- type: string
- description: Dockerfile content
- startCmd:
- description: Start command to execute in the template after the build
- type: string
- cpuCount:
- description: CPU cores for the template
- type: string # form data does not support integer
- memoryMB:
- description: Memory limit for the template in MB
- type: string # form data does not support integer
- encoding:
- buildContext:
- contentType: application/octet-stream
+ $ref: "#/components/schemas/TemplateBuildRequest"
responses:
202:
- description: The build has started
+ description: The build was accepted
content:
application/json:
schema:
@@ -503,39 +387,13 @@ paths:
requestBody:
required: true
content:
- multipart/form-data:
+ application/json:
schema:
- type: object
- required:
- - buildContext
- - dockerfile
- properties:
- alias:
- description: Alias of the template
- type: string
- buildContext:
- description: Docker build context
- type: string
- format: binary
- dockerfile:
- type: string
- description: Dockerfile content
- startCmd:
- description: Start command to execute in the template after the build
- type: string
- cpuCount:
- description: CPU cores for the template
- type: string # form data does not support integer
- memoryMB:
- description: Memory limit for the template in MB
- type: string # form data does not support integer
- encoding:
- buildContext:
- contentType: application/octet-stream
+ $ref: "#/components/schemas/TemplateBuildRequest"
responses:
202:
- description: The build has started
+ description: The build was accepted
content:
application/json:
schema:
@@ -560,31 +418,19 @@ paths:
$ref: "#/components/responses/500"
/templates/{templateID}/builds/{buildID}:
- get:
- description: Get template build info
+ post:
+ description: Start the build
tags: [templates]
security:
- - AccessTokenAuth: []
+ - AccessTokenAuth: []
parameters:
- $ref: "#/components/parameters/templateID"
- $ref: "#/components/parameters/buildID"
- - in: query
- name: logsOffset
- schema:
- default: 0
- type: integer
- description: Index of the starting build log that should be returned with the template
responses:
- 200:
- description: Successfully returned the template
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/TemplateBuild"
+ 202:
+ description: The build has started
401:
$ref: "#/components/responses/401"
- 404:
- $ref: "#/components/responses/404"
500:
$ref: "#/components/responses/500"
@@ -620,265 +466,31 @@ paths:
404:
$ref: "#/components/responses/404"
- # ------ Deprecated --------
- /envs:
- get:
- description: List all environments
- tags: [envs]
- security:
- - AccessTokenAuth: []
- responses:
- 200:
- description: Successfully returned all environments
- content:
- application/json:
- schema:
- type: array
- items:
- allOf:
- - $ref: "#/components/schemas/Environment"
- 401:
- $ref: "#/components/responses/401"
- 500:
- $ref: "#/components/responses/500"
- post:
- description: Create a new environment
- tags: [envs]
- security:
- - AccessTokenAuth: []
- requestBody:
- required: true
- content:
- multipart/form-data:
- schema:
- type: object
- required:
- - buildContext
- - dockerfile
- properties:
- alias:
- description: Alias of the environment
- type: string
- buildContext:
- description: Docker build context
- type: string
- format: binary
- dockerfile:
- type: string
- description: Dockerfile content
- startCmd:
- description: Start command to execute in the template after the build
- type: string
- encoding:
- buildContext:
- contentType: application/octet-stream
-
- responses:
- 202:
- description: The build has started
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Environment"
- 401:
- $ref: "#/components/responses/401"
- 500:
- $ref: "#/components/responses/500"
-
- /envs/{envID}:
- post:
- description: Rebuild an environment
- tags: [envs]
- security:
- - AccessTokenAuth: []
- parameters:
- - $ref: "#/components/parameters/envID"
- requestBody:
- required: true
- content:
- multipart/form-data:
- schema:
- type: object
- required:
- - buildContext
- - dockerfile
- properties:
- alias:
- description: Alias of the environment
- type: string
- buildContext:
- description: Docker build context
- type: string
- format: binary
- dockerfile:
- type: string
- description: Dockerfile content
- startCmd:
- description: Start command to execute in the template after the build
- type: string
- encoding:
- buildContext:
- contentType: application/octet-stream
-
- responses:
- 202:
- description: The build has started
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Environment"
- 401:
- $ref: "#/components/responses/401"
- 500:
- $ref: "#/components/responses/500"
- delete:
- description: Delete an environment
- tags: [envs]
- security:
- - AccessTokenAuth: []
- parameters:
- - $ref: "#/components/parameters/envID"
- responses:
- 204:
- description: The environment was deleted successfully
- 401:
- $ref: "#/components/responses/401"
- 500:
- $ref: "#/components/responses/500"
-
- /envs/{envID}/builds/{buildID}:
+ /templates/{templateID}/builds/{buildID}/status:
get:
- description: Get environment build info
- tags: [envs]
+ description: Get template build info
+ tags: [ templates ]
security:
- - AccessTokenAuth: []
+ - AccessTokenAuth: [ ]
parameters:
- - $ref: "#/components/parameters/envID"
+ - $ref: "#/components/parameters/templateID"
- $ref: "#/components/parameters/buildID"
- in: query
name: logsOffset
schema:
default: 0
type: integer
- description: Index of the starting build log that should be returned with the environment
+ description: Index of the starting build log that should be returned with the template
responses:
200:
- description: Successfully returned the environment
+ description: Successfully returned the template
content:
application/json:
schema:
- $ref: "#/components/schemas/EnvironmentBuild"
- 401:
- $ref: "#/components/responses/401"
- 404:
- $ref: "#/components/responses/404"
- 500:
- $ref: "#/components/responses/500"
-
- /envs/{envID}/builds/{buildID}/logs:
- post:
- description: Add a build log
- tags: [envs]
- parameters:
- - $ref: "#/components/parameters/envID"
- - $ref: "#/components/parameters/buildID"
- requestBody:
- required: true
- content:
- application/json:
- schema:
- type: object
- required:
- - apiSecret
- - logs
- properties:
- apiSecret:
- description: API secret
- type: string
- logs:
- type: array
- items:
- type: string
- responses:
- 201:
- description: Successfully added log
+ $ref: "#/components/schemas/TemplateBuild"
401:
$ref: "#/components/responses/401"
404:
$ref: "#/components/responses/404"
-
- /instances:
- get:
- description: List all running instances
- tags: [instances]
- security:
- - ApiKeyAuth: []
- responses:
- 200:
- description: Successfully returned all running instances
- content:
- application/json:
- schema:
- type: array
- items:
- allOf:
- - $ref: "#/components/schemas/RunningInstance"
- 401:
- $ref: "#/components/responses/401"
- 400:
- $ref: "#/components/responses/400"
500:
$ref: "#/components/responses/500"
- post:
- description: Create an instance from the environment
- tags: [instances]
- security:
- - ApiKeyAuth: []
- requestBody:
- required: true
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/NewInstance"
- responses:
- 201:
- description: The instance was created successfully
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/Instance"
- 401:
- $ref: "#/components/responses/401"
- 400:
- $ref: "#/components/responses/400"
- 500:
- $ref: "#/components/responses/500"
-
- /instances/{instanceID}/refreshes:
- post:
- description: Refresh the instance extending its time to live
- security:
- - ApiKeyAuth: []
- tags: [instances]
- requestBody:
- required: false
- content:
- application/json:
- schema:
- type: object
- properties:
- duration:
- description: Duration for which the instance should be kept alive in seconds
- type: integer
- maximum: 3600 # 1 hour
- minimum: 0
- parameters:
- - $ref: "#/components/parameters/instanceID"
- responses:
- 204:
- description: Successfully refreshed the instance
- 401:
- $ref: "#/components/responses/401"
- 404:
- $ref: "#/components/responses/404"
-# ---------------------