-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdelete.ts
More file actions
77 lines (61 loc) · 2.23 KB
/
delete.ts
File metadata and controls
77 lines (61 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright (c) 2025, Salesforce, Inc.
* SPDX-License-Identifier: Apache-2
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
*/
import {ux} from '@oclif/core';
import {EcdnZoneCommand, formatApiError} from '../../../utils/ecdn/index.js';
import {t, withDocs} from '../../../i18n/index.js';
/**
* Response type for the delete command.
*/
interface DeleteOutput {
deleted: boolean;
}
/**
* Command to delete origin header modification for a zone.
*/
export default class EcdnOriginHeadersDelete extends EcdnZoneCommand<typeof EcdnOriginHeadersDelete> {
static description = withDocs(
t('commands.ecdn.origin-headers.delete.description', 'Delete origin header modification for a zone (MRT type)'),
'/cli/ecdn.html#b2c-ecdn-origin-headers-delete',
);
static enableJsonFlag = true;
static examples = ['<%= config.bin %> <%= command.id %> --tenant-id zzxy_prd --zone my-zone'];
static flags = {
...EcdnZoneCommand.baseFlags,
};
async run(): Promise<DeleteOutput> {
// Prevent deletion in safe mode
this.assertDestructiveOperationAllowed('delete origin header modification');
this.requireOAuthCredentials();
const zoneId = await this.resolveZoneId();
if (!this.jsonEnabled()) {
this.log(t('commands.ecdn.origin-headers.delete.deleting', 'Deleting origin header modification...'));
}
const client = this.getCdnZonesRwClient();
const organizationId = this.getOrganizationId();
const type = 'mrt'; // Only mrt type is supported
const {error} = await client.DELETE(
'/organizations/{organizationId}/zones/{zoneId}/origin-header-modification/{type}',
{
params: {
path: {organizationId, zoneId, type},
},
},
);
if (error) {
this.error(
t('commands.ecdn.origin-headers.delete.error', 'Failed to delete origin header modification: {{message}}', {
message: formatApiError(error),
}),
);
}
const output: DeleteOutput = {deleted: true};
if (this.jsonEnabled()) {
return output;
}
ux.stdout(t('commands.ecdn.origin-headers.delete.success', 'Origin header modification deleted successfully.'));
return output;
}
}