berget 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FluxService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing Flux CD
17
+ * Command group: flux
18
+ */
14
19
  class FluxService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,17 +26,29 @@ class FluxService {
21
26
  }
22
27
  return FluxService.instance;
23
28
  }
24
- // This endpoint is not available in the API
25
- installFlux(options) {
29
+ /**
30
+ * Install Flux CD
31
+ * Command: berget flux install
32
+ * This endpoint is not available in the API
33
+ */
34
+ install(options) {
26
35
  return __awaiter(this, void 0, void 0, function* () {
27
36
  throw new Error('This functionality is not available in the API');
28
37
  });
29
38
  }
30
- // This endpoint is not available in the API
31
- bootstrapFlux(options) {
39
+ /**
40
+ * Bootstrap Flux CD
41
+ * Command: berget flux bootstrap
42
+ * This endpoint is not available in the API
43
+ */
44
+ bootstrap(options) {
32
45
  return __awaiter(this, void 0, void 0, function* () {
33
46
  throw new Error('This functionality is not available in the API');
34
47
  });
35
48
  }
36
49
  }
37
50
  exports.FluxService = FluxService;
51
+ // Command group name for this service
52
+ FluxService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.FLUX;
53
+ // Subcommands for this service
54
+ FluxService.COMMANDS = command_structure_1.SUBCOMMANDS.FLUX;
@@ -11,6 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.HelmService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing Helm charts
17
+ * Command group: helm
18
+ */
14
19
  class HelmService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,17 +26,29 @@ class HelmService {
21
26
  }
22
27
  return HelmService.instance;
23
28
  }
24
- // This endpoint is not available in the API
29
+ /**
30
+ * Add a Helm repository
31
+ * Command: berget helm add-repo
32
+ * This endpoint is not available in the API
33
+ */
25
34
  addRepo(options) {
26
35
  return __awaiter(this, void 0, void 0, function* () {
27
36
  throw new Error('This functionality is not available in the API');
28
37
  });
29
38
  }
30
- // This endpoint is not available in the API
31
- installChart(options) {
39
+ /**
40
+ * Install a Helm chart
41
+ * Command: berget helm install
42
+ * This endpoint is not available in the API
43
+ */
44
+ install(options) {
32
45
  return __awaiter(this, void 0, void 0, function* () {
33
46
  throw new Error('This functionality is not available in the API');
34
47
  });
35
48
  }
36
49
  }
37
50
  exports.HelmService = HelmService;
51
+ // Command group name for this service
52
+ HelmService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.HELM;
53
+ // Subcommands for this service
54
+ HelmService.COMMANDS = command_structure_1.SUBCOMMANDS.HELM;
@@ -11,6 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.KubectlService = void 0;
13
13
  const client_1 = require("../client");
14
+ const command_structure_1 = require("../constants/command-structure");
15
+ /**
16
+ * Service for managing Kubernetes resources
17
+ * Command group: kubectl
18
+ */
14
19
  class KubectlService {
15
20
  constructor() {
16
21
  this.client = (0, client_1.createAuthenticatedClient)();
@@ -21,23 +26,39 @@ class KubectlService {
21
26
  }
22
27
  return KubectlService.instance;
23
28
  }
24
- // This endpoint is not available in the API
29
+ /**
30
+ * Create a Kubernetes namespace
31
+ * Command: berget kubectl create-namespace
32
+ * This endpoint is not available in the API
33
+ */
25
34
  createNamespace(name) {
26
35
  return __awaiter(this, void 0, void 0, function* () {
27
36
  throw new Error('This functionality is not available in the API');
28
37
  });
29
38
  }
30
- // This endpoint is not available in the API
31
- applyConfiguration(filename) {
39
+ /**
40
+ * Apply a Kubernetes configuration
41
+ * Command: berget kubectl apply
42
+ * This endpoint is not available in the API
43
+ */
44
+ apply(filename) {
32
45
  return __awaiter(this, void 0, void 0, function* () {
33
46
  throw new Error('This functionality is not available in the API');
34
47
  });
35
48
  }
36
- // This endpoint is not available in the API
37
- getResources(resource, namespace) {
49
+ /**
50
+ * Get Kubernetes resources
51
+ * Command: berget kubectl get
52
+ * This endpoint is not available in the API
53
+ */
54
+ get(resource, namespace) {
38
55
  return __awaiter(this, void 0, void 0, function* () {
39
56
  throw new Error('This functionality is not available in the API');
40
57
  });
41
58
  }
42
59
  }
43
60
  exports.KubectlService = KubectlService;
61
+ // Command group name for this service
62
+ KubectlService.COMMAND_GROUP = command_structure_1.COMMAND_GROUPS.KUBECTL;
63
+ // Subcommands for this service
64
+ KubectlService.COMMANDS = command_structure_1.SUBCOMMANDS.KUBECTL;
package/index.ts CHANGED
@@ -6,6 +6,7 @@ import * as path from 'path'
6
6
  import { createAuthenticatedClient } from './src/client'
7
7
  import { handleError } from './src/utils/error-handler'
8
8
  import chalk from 'chalk'
9
+ import { COMMAND_GROUPS, SUBCOMMANDS } from './src/constants/command-structure'
9
10
 
10
11
  // Set version and description
11
12
  program
@@ -29,16 +30,20 @@ import { ApiKeyService, ApiKey } from './src/services/api-key-service'
29
30
  import { ClusterService, Cluster } from './src/services/cluster-service'
30
31
 
31
32
  // Auth commands
32
- program
33
- .command('login')
33
+ const auth = program
34
+ .command(AuthService.COMMAND_GROUP)
35
+ .description('Manage authentication and authorization')
36
+
37
+ auth
38
+ .command(AuthService.COMMANDS.LOGIN)
34
39
  .description('Log in to Berget')
35
40
  .action(async () => {
36
41
  const authService = AuthService.getInstance()
37
42
  await authService.login()
38
43
  })
39
44
 
40
- program
41
- .command('logout')
45
+ auth
46
+ .command(AuthService.COMMANDS.LOGOUT)
42
47
  .description('Log out from Berget')
43
48
  .action(() => {
44
49
  const { clearAuthToken } = require('./src/client')
@@ -46,13 +51,13 @@ program
46
51
  console.log(chalk.green('You have been logged out from Berget'))
47
52
  })
48
53
 
49
- program
50
- .command('whoami')
54
+ auth
55
+ .command(AuthService.COMMANDS.WHOAMI)
51
56
  .description('Show information about the logged in user')
52
57
  .action(async () => {
53
58
  try {
54
59
  const authService = AuthService.getInstance()
55
- const profile = await authService.getUserProfile()
60
+ const profile = await authService.whoami()
56
61
 
57
62
  if (profile) {
58
63
  console.log(
@@ -75,15 +80,17 @@ program
75
80
  })
76
81
 
77
82
  // API Key commands
78
- const apiKey = program.command('api-key').description('Manage API keys')
83
+ const apiKey = program
84
+ .command(ApiKeyService.COMMAND_GROUP)
85
+ .description('Manage API keys')
79
86
 
80
87
  apiKey
81
- .command('list')
88
+ .command(ApiKeyService.COMMANDS.LIST)
82
89
  .description('List all API keys')
83
90
  .action(async () => {
84
91
  try {
85
92
  const apiKeyService = ApiKeyService.getInstance()
86
- const keys = await apiKeyService.listApiKeys()
93
+ const keys = await apiKeyService.list()
87
94
 
88
95
  if (keys.length === 0) {
89
96
  console.log(
@@ -143,7 +150,7 @@ apiKey
143
150
  })
144
151
 
145
152
  apiKey
146
- .command('create')
153
+ .command(ApiKeyService.COMMANDS.CREATE)
147
154
  .description('Create a new API key')
148
155
  .option('--name <name>', 'Name of the API key')
149
156
  .option('--description <description>', 'Description of the API key')
@@ -161,7 +168,7 @@ apiKey
161
168
  console.log(chalk.blue('Creating API key...'))
162
169
 
163
170
  const apiKeyService = ApiKeyService.getInstance()
164
- const result = await apiKeyService.createApiKey({
171
+ const result = await apiKeyService.create({
165
172
  name: options.name,
166
173
  description: options.description,
167
174
  })
@@ -202,7 +209,7 @@ apiKey
202
209
  })
203
210
 
204
211
  apiKey
205
- .command('delete')
212
+ .command(ApiKeyService.COMMANDS.DELETE)
206
213
  .description('Delete an API key')
207
214
  .argument('<id>', 'ID of the API key to delete')
208
215
  .action(async (id) => {
@@ -210,7 +217,7 @@ apiKey
210
217
  console.log(chalk.blue(`Deleting API key ${id}...`))
211
218
 
212
219
  const apiKeyService = ApiKeyService.getInstance()
213
- await apiKeyService.deleteApiKey(id)
220
+ await apiKeyService.delete(id)
214
221
 
215
222
  console.log(chalk.green(`✓ API key ${id} has been deleted`))
216
223
  console.log('')
@@ -228,7 +235,7 @@ apiKey
228
235
  })
229
236
 
230
237
  apiKey
231
- .command('rotate')
238
+ .command(ApiKeyService.COMMANDS.ROTATE)
232
239
  .description(
233
240
  'Rotate an API key (creates a new one and invalidates the old one)'
234
241
  )
@@ -241,7 +248,7 @@ apiKey
241
248
  )
242
249
 
243
250
  const apiKeyService = ApiKeyService.getInstance()
244
- const result = await apiKeyService.rotateApiKey(id)
251
+ const result = await apiKeyService.rotate(id)
245
252
 
246
253
  console.log('')
247
254
  console.log(chalk.green('✓ API key rotated'))
@@ -279,7 +286,7 @@ apiKey
279
286
  })
280
287
 
281
288
  apiKey
282
- .command('usage')
289
+ .command(ApiKeyService.COMMANDS.DESCRIBE)
283
290
  .description('Show usage statistics for an API key')
284
291
  .argument('<id>', 'ID of the API key')
285
292
  .option('--start <date>', 'Start date (YYYY-MM-DD)')
@@ -289,7 +296,7 @@ apiKey
289
296
  console.log(chalk.blue(`Fetching usage statistics for API key ${id}...`))
290
297
 
291
298
  const apiKeyService = ApiKeyService.getInstance()
292
- const usage = await apiKeyService.getApiKeyUsage(id)
299
+ const usage = await apiKeyService.describe(id)
293
300
 
294
301
  console.log('')
295
302
  console.log(
@@ -367,17 +374,19 @@ apiKey
367
374
  })
368
375
 
369
376
  // Cluster commands
370
- const cluster = program.command('cluster').description('Manage Berget clusters')
377
+ const cluster = program
378
+ .command(ClusterService.COMMAND_GROUP)
379
+ .description('Manage Berget clusters')
371
380
 
372
381
  // Removed cluster create command as it's not available in the API
373
382
 
374
383
  cluster
375
- .command('list')
384
+ .command(ClusterService.COMMANDS.LIST)
376
385
  .description('List all Berget clusters')
377
386
  .action(async () => {
378
387
  try {
379
388
  const clusterService = ClusterService.getInstance()
380
- const clusters = await clusterService.listClusters()
389
+ const clusters = await clusterService.list()
381
390
 
382
391
  console.log('NAME STATUS NODES CREATED')
383
392
  clusters.forEach((cluster: Cluster) => {
@@ -393,13 +402,13 @@ cluster
393
402
  })
394
403
 
395
404
  cluster
396
- .command('usage')
405
+ .command(ClusterService.COMMANDS.GET_USAGE)
397
406
  .description('Get usage metrics for a specific cluster')
398
407
  .argument('<clusterId>', 'Cluster ID')
399
408
  .action(async (clusterId) => {
400
409
  try {
401
410
  const clusterService = ClusterService.getInstance()
402
- const usage = await clusterService.getClusterUsage(clusterId)
411
+ const usage = await clusterService.getUsage(clusterId)
403
412
 
404
413
  console.log('Cluster Usage:')
405
414
  console.log(JSON.stringify(usage, null, 2))
@@ -408,6 +417,22 @@ cluster
408
417
  }
409
418
  })
410
419
 
420
+ cluster
421
+ .command(ClusterService.COMMANDS.DESCRIBE)
422
+ .description('Get detailed information about a cluster')
423
+ .argument('<clusterId>', 'Cluster ID')
424
+ .action(async (clusterId) => {
425
+ try {
426
+ const clusterService = ClusterService.getInstance()
427
+ const clusterInfo = await clusterService.describe(clusterId)
428
+
429
+ console.log('Cluster Details:')
430
+ console.log(JSON.stringify(clusterInfo, null, 2))
431
+ } catch (error) {
432
+ handleError('Failed to describe cluster', error)
433
+ }
434
+ })
435
+
411
436
  // Autocomplete command
412
437
  program
413
438
  .command('autocomplete')
@@ -430,8 +455,12 @@ program
430
455
  // Removed kubernetes-like commands as they're not available in the API
431
456
 
432
457
  // Add token usage command
433
- program
434
- .command('token-usage')
458
+ const billing = program
459
+ .command(COMMAND_GROUPS.BILLING)
460
+ .description('Manage billing and usage')
461
+
462
+ billing
463
+ .command(SUBCOMMANDS.BILLING.GET_USAGE)
435
464
  .description('Get token usage statistics')
436
465
  .option('--model <modelId>', 'Get usage for a specific model')
437
466
  .action(async (options) => {
@@ -459,8 +488,12 @@ program
459
488
  })
460
489
 
461
490
  // Add models command
462
- program
463
- .command('models')
491
+ const models = program
492
+ .command(COMMAND_GROUPS.MODELS)
493
+ .description('Manage AI models')
494
+
495
+ models
496
+ .command(SUBCOMMANDS.MODELS.LIST)
464
497
  .description('List available AI models')
465
498
  .option('--id <modelId>', 'Get details for a specific model')
466
499
  .action(async (options) => {
@@ -506,9 +539,13 @@ program
506
539
  })
507
540
 
508
541
  // Add team command
509
- program
510
- .command('team')
511
- .description('Manage team members')
542
+ const users = program
543
+ .command(COMMAND_GROUPS.USERS)
544
+ .description('Manage users')
545
+
546
+ users
547
+ .command(SUBCOMMANDS.USERS.LIST)
548
+ .description('List team members')
512
549
  .action(async () => {
513
550
  try {
514
551
  const client = createAuthenticatedClient()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "berget",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "berget": "dist/index.js"
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Command structure constants for the CLI
3
+ * Following patterns from AWS CLI and Google Cloud CLI
4
+ */
5
+
6
+ // Main command groups
7
+ export const COMMAND_GROUPS = {
8
+ AUTH: 'auth',
9
+ API_KEYS: 'api-keys',
10
+ CLUSTERS: 'clusters',
11
+ APPS: 'apps',
12
+ MODELS: 'models',
13
+ HELM: 'helm',
14
+ KUBECTL: 'kubectl',
15
+ FLUX: 'flux',
16
+ USERS: 'users',
17
+ BILLING: 'billing',
18
+ }
19
+
20
+ // Subcommands for each group
21
+ export const SUBCOMMANDS = {
22
+ // Auth commands
23
+ AUTH: {
24
+ LOGIN: 'login',
25
+ LOGOUT: 'logout',
26
+ WHOAMI: 'whoami',
27
+ },
28
+
29
+ // API Keys commands
30
+ API_KEYS: {
31
+ LIST: 'list',
32
+ CREATE: 'create',
33
+ DELETE: 'delete',
34
+ ROTATE: 'rotate',
35
+ DESCRIBE: 'describe',
36
+ },
37
+
38
+ // Clusters commands
39
+ CLUSTERS: {
40
+ LIST: 'list',
41
+ DESCRIBE: 'describe',
42
+ GET_USAGE: 'get-usage',
43
+ },
44
+
45
+ // Apps commands
46
+ APPS: {
47
+ LIST_TEMPLATES: 'list-templates',
48
+ DESCRIBE_TEMPLATE: 'describe-template',
49
+ LIST_INSTALLATIONS: 'list-installations',
50
+ INSTALL: 'install',
51
+ UNINSTALL: 'uninstall',
52
+ DESCRIBE_INSTALLATION: 'describe-installation',
53
+ },
54
+
55
+ // Models commands
56
+ MODELS: {
57
+ LIST: 'list',
58
+ DESCRIBE: 'describe',
59
+ },
60
+
61
+ // Helm commands
62
+ HELM: {
63
+ ADD_REPO: 'add-repo',
64
+ INSTALL: 'install',
65
+ },
66
+
67
+ // Kubectl commands
68
+ KUBECTL: {
69
+ CREATE_NAMESPACE: 'create-namespace',
70
+ APPLY: 'apply',
71
+ GET: 'get',
72
+ },
73
+
74
+ // Flux commands
75
+ FLUX: {
76
+ INSTALL: 'install',
77
+ BOOTSTRAP: 'bootstrap',
78
+ },
79
+
80
+ // Users commands
81
+ USERS: {
82
+ LIST: 'list',
83
+ DESCRIBE: 'describe',
84
+ UPDATE: 'update',
85
+ INVITE: 'invite',
86
+ },
87
+
88
+ // Billing commands
89
+ BILLING: {
90
+ GET_USAGE: 'get-usage',
91
+ LIST_INVOICES: 'list-invoices',
92
+ DESCRIBE_INVOICE: 'describe-invoice',
93
+ LIST_PAYMENT_METHODS: 'list-payment-methods',
94
+ ADD_PAYMENT_METHOD: 'add-payment-method',
95
+ REMOVE_PAYMENT_METHOD: 'remove-payment-method',
96
+ UPDATE_SUBSCRIPTION: 'update-subscription',
97
+ },
98
+ }
99
+
100
+ // Command descriptions
101
+ export const COMMAND_DESCRIPTIONS = {
102
+ // Auth group
103
+ [COMMAND_GROUPS.AUTH]: 'Manage authentication and authorization',
104
+ [`${COMMAND_GROUPS.AUTH} ${SUBCOMMANDS.AUTH.LOGIN}`]: 'Log in to Berget AI',
105
+ [`${COMMAND_GROUPS.AUTH} ${SUBCOMMANDS.AUTH.LOGOUT}`]: 'Log out from Berget AI',
106
+ [`${COMMAND_GROUPS.AUTH} ${SUBCOMMANDS.AUTH.WHOAMI}`]: 'Display current user information',
107
+
108
+ // API Keys group
109
+ [COMMAND_GROUPS.API_KEYS]: 'Manage API keys',
110
+ [`${COMMAND_GROUPS.API_KEYS} ${SUBCOMMANDS.API_KEYS.LIST}`]: 'List all API keys',
111
+ [`${COMMAND_GROUPS.API_KEYS} ${SUBCOMMANDS.API_KEYS.CREATE}`]: 'Create a new API key',
112
+ [`${COMMAND_GROUPS.API_KEYS} ${SUBCOMMANDS.API_KEYS.DELETE}`]: 'Delete an API key',
113
+ [`${COMMAND_GROUPS.API_KEYS} ${SUBCOMMANDS.API_KEYS.ROTATE}`]: 'Rotate an API key',
114
+ [`${COMMAND_GROUPS.API_KEYS} ${SUBCOMMANDS.API_KEYS.DESCRIBE}`]: 'Get usage statistics for an API key',
115
+
116
+ // Clusters group
117
+ [COMMAND_GROUPS.CLUSTERS]: 'Manage Kubernetes clusters',
118
+ [`${COMMAND_GROUPS.CLUSTERS} ${SUBCOMMANDS.CLUSTERS.LIST}`]: 'List all clusters',
119
+ [`${COMMAND_GROUPS.CLUSTERS} ${SUBCOMMANDS.CLUSTERS.DESCRIBE}`]: 'Get detailed information about a cluster',
120
+ [`${COMMAND_GROUPS.CLUSTERS} ${SUBCOMMANDS.CLUSTERS.GET_USAGE}`]: 'Get resource usage for a cluster',
121
+
122
+ // Apps group
123
+ [COMMAND_GROUPS.APPS]: 'Manage applications',
124
+ [`${COMMAND_GROUPS.APPS} ${SUBCOMMANDS.APPS.LIST_TEMPLATES}`]: 'List available application templates',
125
+ [`${COMMAND_GROUPS.APPS} ${SUBCOMMANDS.APPS.DESCRIBE_TEMPLATE}`]: 'Get detailed information about an application template',
126
+ [`${COMMAND_GROUPS.APPS} ${SUBCOMMANDS.APPS.LIST_INSTALLATIONS}`]: 'List installed applications',
127
+ [`${COMMAND_GROUPS.APPS} ${SUBCOMMANDS.APPS.INSTALL}`]: 'Install an application',
128
+ [`${COMMAND_GROUPS.APPS} ${SUBCOMMANDS.APPS.UNINSTALL}`]: 'Uninstall an application',
129
+ [`${COMMAND_GROUPS.APPS} ${SUBCOMMANDS.APPS.DESCRIBE_INSTALLATION}`]: 'Get detailed information about an installed application',
130
+
131
+ // Models group
132
+ [COMMAND_GROUPS.MODELS]: 'Manage AI models',
133
+ [`${COMMAND_GROUPS.MODELS} ${SUBCOMMANDS.MODELS.LIST}`]: 'List available AI models',
134
+ [`${COMMAND_GROUPS.MODELS} ${SUBCOMMANDS.MODELS.DESCRIBE}`]: 'Get detailed information about an AI model',
135
+
136
+ // Helm group
137
+ [COMMAND_GROUPS.HELM]: 'Manage Helm charts',
138
+ [`${COMMAND_GROUPS.HELM} ${SUBCOMMANDS.HELM.ADD_REPO}`]: 'Add a Helm repository',
139
+ [`${COMMAND_GROUPS.HELM} ${SUBCOMMANDS.HELM.INSTALL}`]: 'Install a Helm chart',
140
+
141
+ // Kubectl group
142
+ [COMMAND_GROUPS.KUBECTL]: 'Manage Kubernetes resources',
143
+ [`${COMMAND_GROUPS.KUBECTL} ${SUBCOMMANDS.KUBECTL.CREATE_NAMESPACE}`]: 'Create a Kubernetes namespace',
144
+ [`${COMMAND_GROUPS.KUBECTL} ${SUBCOMMANDS.KUBECTL.APPLY}`]: 'Apply a Kubernetes configuration',
145
+ [`${COMMAND_GROUPS.KUBECTL} ${SUBCOMMANDS.KUBECTL.GET}`]: 'Get Kubernetes resources',
146
+
147
+ // Flux group
148
+ [COMMAND_GROUPS.FLUX]: 'Manage Flux CD',
149
+ [`${COMMAND_GROUPS.FLUX} ${SUBCOMMANDS.FLUX.INSTALL}`]: 'Install Flux CD',
150
+ [`${COMMAND_GROUPS.FLUX} ${SUBCOMMANDS.FLUX.BOOTSTRAP}`]: 'Bootstrap Flux CD',
151
+
152
+ // Users group
153
+ [COMMAND_GROUPS.USERS]: 'Manage users',
154
+ [`${COMMAND_GROUPS.USERS} ${SUBCOMMANDS.USERS.LIST}`]: 'List all users in your organization',
155
+ [`${COMMAND_GROUPS.USERS} ${SUBCOMMANDS.USERS.DESCRIBE}`]: 'Get detailed information about a user',
156
+ [`${COMMAND_GROUPS.USERS} ${SUBCOMMANDS.USERS.UPDATE}`]: 'Update user information',
157
+ [`${COMMAND_GROUPS.USERS} ${SUBCOMMANDS.USERS.INVITE}`]: 'Invite a new user to your organization',
158
+
159
+ // Billing group
160
+ [COMMAND_GROUPS.BILLING]: 'Manage billing and usage',
161
+ [`${COMMAND_GROUPS.BILLING} ${SUBCOMMANDS.BILLING.GET_USAGE}`]: 'Get current usage metrics',
162
+ [`${COMMAND_GROUPS.BILLING} ${SUBCOMMANDS.BILLING.LIST_INVOICES}`]: 'List all invoices',
163
+ [`${COMMAND_GROUPS.BILLING} ${SUBCOMMANDS.BILLING.DESCRIBE_INVOICE}`]: 'Get detailed information about an invoice',
164
+ [`${COMMAND_GROUPS.BILLING} ${SUBCOMMANDS.BILLING.LIST_PAYMENT_METHODS}`]: 'List all payment methods',
165
+ [`${COMMAND_GROUPS.BILLING} ${SUBCOMMANDS.BILLING.ADD_PAYMENT_METHOD}`]: 'Add a new payment method',
166
+ [`${COMMAND_GROUPS.BILLING} ${SUBCOMMANDS.BILLING.REMOVE_PAYMENT_METHOD}`]: 'Remove a payment method',
167
+ [`${COMMAND_GROUPS.BILLING} ${SUBCOMMANDS.BILLING.UPDATE_SUBSCRIPTION}`]: 'Update subscription plan',
168
+ }
@@ -1,5 +1,6 @@
1
1
  import { createAuthenticatedClient } from '../client'
2
2
  import { handleError } from '../utils/error-handler'
3
+ import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
3
4
 
4
5
  export interface ApiKey {
5
6
  id: number
@@ -25,9 +26,19 @@ export interface ApiKeyResponse {
25
26
  created: string
26
27
  }
27
28
 
29
+ /**
30
+ * Service for managing API keys
31
+ * Command group: api-keys
32
+ */
28
33
  export class ApiKeyService {
29
34
  private static instance: ApiKeyService
30
35
  private client = createAuthenticatedClient()
36
+
37
+ // Command group name for this service
38
+ public static readonly COMMAND_GROUP = COMMAND_GROUPS.API_KEYS
39
+
40
+ // Subcommands for this service
41
+ public static readonly COMMANDS = SUBCOMMANDS.API_KEYS
31
42
 
32
43
  private constructor() {}
33
44
 
@@ -38,7 +49,11 @@ export class ApiKeyService {
38
49
  return ApiKeyService.instance
39
50
  }
40
51
 
41
- public async listApiKeys(): Promise<ApiKey[]> {
52
+ /**
53
+ * List all API keys
54
+ * Command: berget api-keys list
55
+ */
56
+ public async list(): Promise<ApiKey[]> {
42
57
  try {
43
58
  const { data, error } = await this.client.GET('/v1/api-keys')
44
59
  if (error) {
@@ -60,7 +75,11 @@ export class ApiKeyService {
60
75
  }
61
76
  }
62
77
 
63
- public async createApiKey(options: CreateApiKeyOptions): Promise<ApiKeyResponse> {
78
+ /**
79
+ * Create a new API key
80
+ * Command: berget api-keys create
81
+ */
82
+ public async create(options: CreateApiKeyOptions): Promise<ApiKeyResponse> {
64
83
  try {
65
84
  const { data, error } = await this.client.POST('/v1/api-keys', {
66
85
  body: options
@@ -73,7 +92,11 @@ export class ApiKeyService {
73
92
  }
74
93
  }
75
94
 
76
- public async deleteApiKey(id: string): Promise<boolean> {
95
+ /**
96
+ * Delete an API key
97
+ * Command: berget api-keys delete
98
+ */
99
+ public async delete(id: string): Promise<boolean> {
77
100
  try {
78
101
  const { error } = await this.client.DELETE('/v1/api-keys/{id}', {
79
102
  params: { path: { id } }
@@ -86,7 +109,11 @@ export class ApiKeyService {
86
109
  }
87
110
  }
88
111
 
89
- public async rotateApiKey(id: string): Promise<ApiKeyResponse> {
112
+ /**
113
+ * Rotate an API key
114
+ * Command: berget api-keys rotate
115
+ */
116
+ public async rotate(id: string): Promise<ApiKeyResponse> {
90
117
  try {
91
118
  const { data, error } = await this.client.PUT('/v1/api-keys/{id}/rotate', {
92
119
  params: { path: { id } }
@@ -99,7 +126,11 @@ export class ApiKeyService {
99
126
  }
100
127
  }
101
128
 
102
- public async getApiKeyUsage(id: string): Promise<any> {
129
+ /**
130
+ * Get usage statistics for an API key
131
+ * Command: berget api-keys describe
132
+ */
133
+ public async describe(id: string): Promise<any> {
103
134
  try {
104
135
  const { data, error } = await this.client.GET('/v1/api-keys/{id}/usage', {
105
136
  params: { path: { id } }