|
| 1 | +/* |
| 2 | + * Copyright (c) 2024, salesforce.com, inc. |
| 3 | + * All rights reserved. |
| 4 | + * Licensed under the BSD 3-Clause license. |
| 5 | + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
| 6 | + */ |
| 7 | + |
| 8 | +import { SfCommand, Flags } from '@salesforce/sf-plugins-core'; |
| 9 | +import { Messages } from '@salesforce/core'; |
| 10 | + |
| 11 | +Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); |
| 12 | +const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.cancel'); |
| 13 | + |
| 14 | +export type AgentTestCancelResult = { |
| 15 | + jobId: string; // AiEvaluation.Id |
| 16 | + success: boolean; |
| 17 | + errorCode?: string; |
| 18 | + message?: string; |
| 19 | +}; |
| 20 | + |
| 21 | +export default class AgentTestCancel extends SfCommand<AgentTestCancelResult> { |
| 22 | + public static readonly summary = messages.getMessage('summary'); |
| 23 | + public static readonly description = messages.getMessage('description'); |
| 24 | + public static readonly examples = messages.getMessages('examples'); |
| 25 | + |
| 26 | + public static readonly flags = { |
| 27 | + 'target-org': Flags.requiredOrg(), |
| 28 | + 'job-id': Flags.string({ |
| 29 | + char: 'i', |
| 30 | + required: true, |
| 31 | + summary: messages.getMessage('flags.id.summary'), |
| 32 | + }), |
| 33 | + 'use-most-recent': Flags.boolean({ |
| 34 | + char: 'r', |
| 35 | + summary: messages.getMessage('flags.use-most-recent.summary'), |
| 36 | + exactlyOne: ['use-most-recent', 'job-id'], |
| 37 | + }), |
| 38 | + // |
| 39 | + // Future flags: |
| 40 | + // ??? api-version ??? |
| 41 | + }; |
| 42 | + |
| 43 | + public async run(): Promise<AgentTestCancelResult> { |
| 44 | + const { flags } = await this.parse(AgentTestCancel); |
| 45 | + |
| 46 | + this.log(`Canceling tests for AiEvaluation Job: ${flags['job-id']}`); |
| 47 | + |
| 48 | + // Call SF Eval Connect API passing AiEvaluation.Id |
| 49 | + // POST to /einstein/ai-evaluations/{aiEvaluationId}/stop |
| 50 | + |
| 51 | + // Returns: AiEvaluation.Id |
| 52 | + |
| 53 | + return { |
| 54 | + success: true, |
| 55 | + jobId: '4KBSM000000003F4AQ', // AiEvaluation.Id |
| 56 | + }; |
| 57 | + } |
| 58 | +} |
0 commit comments