Skip to content

Commit

Permalink
Changed template ls command to sync with latest API changes (#508)
Browse files Browse the repository at this point in the history
- Added createdBy, createdAt columns
- Hidden 'buildCount', 'lastSpawnedAt', 'spawnCount', 'updatedAt'
columns
- Sync API spec and ts schema to latest

---------

Co-authored-by: Mish Ushakov <[email protected]>
Co-authored-by: Jakub Novák <[email protected]>
  • Loading branch information
3 people authored Dec 17, 2024
1 parent c64e30a commit fc8086d
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/khaki-owls-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@e2b/cli': patch
---

Changed template ls command to sync with latest API changes
15 changes: 14 additions & 1 deletion packages/cli/src/commands/template/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const listCommand = new commander.Command('list')
const table = new tablePrinter.Table({
title: 'Sandbox templates',
columns: [
{ name: 'visibility', alignment: 'left', title: 'Access' },
{ name: 'templateID', alignment: 'left', title: 'Template ID' },
{
name: 'aliases',
Expand All @@ -42,11 +43,23 @@ export const listCommand = new commander.Command('list')
},
{ name: 'cpuCount', alignment: 'right', title: 'vCPUs' },
{ name: 'memoryMB', alignment: 'right', title: 'RAM MiB' },
{ name: 'createdBy', alignment: 'right', title: 'Created by' },
{ name: 'createdAt', alignment: 'right', title: 'Created at' },
],
disabledColumns: [
'public',
'buildID',
'buildCount',
'lastSpawnedAt',
'spawnCount',
'updatedAt',
],
disabledColumns: ['public', 'buildID'],
rows: templates.map((template) => ({
...template,
visibility: template.public ? 'Public' : 'Private',
aliases: listAliases(template.aliases),
createdBy: template.createdBy?.email,
createdAt: new Date(template.createdAt).toLocaleDateString(),
})),
style: {
headerTop: {
Expand Down
61 changes: 61 additions & 0 deletions packages/js-sdk/src/api/schema.gen.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions spec/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ components:
type: boolean
description: Whether the team is the default team

TeamUser:
required:
- id
- email
properties:
id:
type: string
format: uuid
description: Identifier of the user
email:
type: string
description: Email of the user

TemplateUpdateRequest:
properties:
public:
type: boolean
description: Whether the template is public or only accessible by the team

CPUCount:
type: integer
format: int32
Expand Down Expand Up @@ -218,6 +237,12 @@ components:
- cpuCount
- memoryMB
- public
- createdAt
- updatedAt
- createdBy
- lastSpawnedAt
- spawnCount
- buildCount
properties:
templateID:
type: string
Expand All @@ -237,6 +262,30 @@ components:
description: Aliases of the template
items:
type: string
createdAt:
type: string
format: date-time
description: Time when the template was created
updatedAt:
type: string
format: date-time
description: Time when the template was last updated
createdBy:
allOf:
- $ref: "#/components/schemas/TeamUser"
nullable: true
lastSpawnedAt:
type: string
format: date-time
description: Time when the template was last used
spawnCount:
type: integer
format: int64
description: Number of times the template was used
buildCount:
type: integer
format: int32
description: Number of times the template was built

TemplateBuildRequest:
required:
Expand Down Expand Up @@ -586,6 +635,28 @@ paths:
$ref: "#/components/responses/401"
"500":
$ref: "#/components/responses/500"
patch:
description: Update template
tags: [templates]
security:
- AccessTokenAuth: []
parameters:
- $ref: "#/components/parameters/templateID"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TemplateUpdateRequest"
responses:
"200":
description: The template was updated successfully
"400":
$ref: "#/components/responses/400"
"401":
$ref: "#/components/responses/401"
"500":
$ref: "#/components/responses/500"

/templates/{templateID}/builds/{buildID}:
post:
Expand Down

0 comments on commit fc8086d

Please sign in to comment.