Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Run `dc-cli --help` to get a list of available commands.
- [hub](#hub)
- [job](#job)
- [linked-content-repository](#linked-content-repository)
- [webhook](#webhook)
- [Building the CLI](#building-the-cli)
- [Required permissions](#required-permissions)

Expand Down Expand Up @@ -137,7 +138,7 @@ Before importing, copying, or moving content you must ensure that a valid [conte

### extension

This category includes interactions with Dynamic Content's UI Extensions, and can be used to export and import extensions from an individual hub.
This category includes interactions with Dynamic Content's UI Extensions, and can be used to export, import and delete extensions from an individual hub.

[View commands for **extension**](docs/EXTENSION.md)

Expand Down Expand Up @@ -191,6 +192,12 @@ These commands can be used to list multiple linked content repository.

[View commands for **linked-content-repository**](docs/LINKED-CONTENT-REPOSITORY.md)

### webhook

This category includes interactions with Dynamic Content's UI Webhooks, and can be used to export, import and delete webhooks from an individual hub.

[View commands for **webhook**](docs/WEBHOOK.md)

## Building the CLI

We have included some NPM scripts to help create various installations of the CLI.
Expand Down
18 changes: 10 additions & 8 deletions docs/EXTENSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ dc-cli extension export <dir>

#### Options

| Option Name | Type | Description |
| --------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --id | [string] | The ID of an Extension to be exported.<br/>If no --id option is given, all extensions for the hub are exported.<br/>A single --id option may be given to export a single extension.<br/>Multiple --id options may be given to export multiple extensions at the same time. |
| -f<br />--force | [boolean] | Overwrite extensions without asking. |
| Option Name | Type | Description |
| --------------- | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --id | [string] | The ID of an Extension to be exported.<br/>If no --id option is given, all extensions for the hub are exported.<br/>A single --id option may be given to export a single extension.<br/>Multiple --id options may be given to export multiple extensions at the same time. |
| -f<br />--force | [boolean] | Overwrite extensions without asking. |
| --logFile | [string]<br />[default: (generated-value)] | Path to a log file to write to. |

#### Examples

Expand Down Expand Up @@ -87,10 +88,11 @@ dc-cli extension delete

#### Options

| Option Name | Type | Description |
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| --id | [string] | The ID of an Extension to be deleted.<br/>If no --id option is given, all extensions for the hub are deleted.<br/>A single --id option may be given to delete a single extension.<br/>Multiple --id options may be given to delete multiple extensions at the same time. |
| -f<br />--force | [boolean] | Delete extensions without asking. |
| Option Name | Type | Description |
| --------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| --id | [string] | The ID of an Extension to be deleted.<br/>If no --id option is given, all extensions for the hub are deleted.<br/>A single --id option may be given to delete a single extension.<br/>Multiple --id options may be given to delete multiple extensions at the same time. |
| -f<br />--force | [boolean] | Delete extensions without asking. |
| --logFile | [string]<br />[default: (generated-value)] | Path to a log file to write to. |

#### Examples

Expand Down
144 changes: 144 additions & 0 deletions docs/WEBHOOK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# webhook

## Description

The **webhook** command category includes a number of interactions with webhooks.

These commands can be used to export, import and delete webhooks from an individual hub.

Run `dc-cli webhook --help` to get a list of available commands.

Return to [README.md](../README.md) for information on other command categories.

<!-- MarkdownTOC levels="2,3" autolink="true" -->

- [Common Options](#common-options)
- [Commands](#commands)
- [export](#export)
- [import](#import)
- [delete](#delete)

<!-- /MarkdownTOC -->

## Common Options

The following options are available for all **webhook** commands.

| Option Name | Type | Description |
| -------------- | ---------------------------------------------------------- | -------------------------------- |
| --version | [boolean] | Show version number |
| --clientId | [string]<br />[required] | Client ID for the source hub |
| --clientSecret | [string]<br />[required] | Client secret for the source hub |
| --hubId | [string]<br />[required] | Hub ID for the source hub |
| --config | [string]<br />[default: "~/.amplience/dc-cli-config.json"] | Path to JSON config file |
| --help | [boolean] | Show help |

## Commands

### export

Exports webhooks from the targeted Dynamic Content hub into a folder called **exported_webhooks** at the user specified file path.

**Note**: No secret or auth header values will be exported.

```
dc-cli webhook export <dir>
```

#### Options

| Option Name | Type | Description |
| ---------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --id | [string] | The ID of the webhook to be exported.<br/>If no --id option is given, all webhooks for the hub are exported.<br/>A single --id option may be given to export a single webhook.<br/>Multiple --id options may be given to export multiple webhooks at the same time. |
| --logFile | [string]<br />[default: (generated-value)] | Path to a log file to write to. |
| -s<br />--silent | [boolean] | If present, no log file will be produced. |
| -f<br />--force | [boolean] | Export webhooks without asking. |

#### Examples

##### Export all webhooks from a hub

`dc-cli webhook export ./myDirectory/content`

##### Export a single webhook from a hub

`dc-cli webhook export ./myDirectory/content --id 1111111111`

##### Export multiple webhooks from a hub

`dc-cli webhook export ./myDirectory/content --id 1111111111 --id 2222222222`

### import

Imports webhooks from the specified filesystem location to the targeted Dynamic Content hub.

**Note**: The following values will be stripped out / not included during the import:

- **secret** - this will be recreated for the webhook in the destination hub during import.
- **createdDate** - this will be assigned during import (if webhook is being created).
- **lastModifiedDate** - this will be assigned during import (if webhook is being updated).
- **any header objects that are secrets** - these need to be manually assigned for the webhook in the destination hub.

Please see [the content-management API reference for Webhooks](https://amplience.com/developers/docs/apis/content-management-reference/#tag/Webhooks) for more information.

For any **customPayload** the following property values will be replaced by those in the destination hub:

- account
- stagingEnvironment

```
dc-cli webhook import <dir>
```

#### Options

| Option Name | Type | Description |
| ---------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --mapFile | [string] | Mapping file to use when updating content that already exists.<br />Updated with any new mappings that are generated. If not present, will be created.<br />For more information, see [mapping files](#MAPPING-FILES). |
| --logFile | [string]<br />[default: (generated-value)] | Path to a log file to write to. |
| -s<br />--silent | [boolean] | If present, no log file will be produced. |
| -f<br />--force | [boolean] | Overwrite webhooks without asking. |

#### Examples

##### Import content from the filesystem

`dc-cli webhook import ./myDirectory/webhooks`

##### Specify a mapping file when importing

`dc-cli webhook import ./myDirectory/webhooks --mapFile ./myDirectory/mappingFile.json`

### delete

Deletes webhooks from the targeted Dynamic Content hub.

```
dc-cli webhook delete
```

#### Options

| Option Name | Type | Description |
| --------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --id | [string] | The ID of an Webhook to be deleted.<br/>If no --id option is given, all webhooks for the hub are deleted.<br/>A single --id option may be given to delete a single webhook.<br/>Multiple --id options may be given to delete multiple webhooks at the same time. |
| -f<br />--force | [boolean] | Delete webhooks without asking. |
| --logFile | [string]<br />[default: (generated-value)] | Path to a log file to write to. |

#### Examples

##### Delete all webhooks from a Hub

`dc-cli webhook delete`

##### Delete a single webhook with the ID of 'foo'

`dc-cli webhook delete foo`

or

`dc-cli webhook delete --id foo`

##### Delete multiple webhooks with the IDs of 'foo' & 'bar'

`dc-cli webhook delete --id foo --id bar`
1 change: 1 addition & 0 deletions src/__snapshots__/cli.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Commands:
dc-cli linked-content-repository Linked Content Repository
dc-cli search-index Search Index
dc-cli settings Settings
dc-cli webhook Webhook

Options:
--help Show help [boolean]
Expand Down
2 changes: 1 addition & 1 deletion src/commands/extension/delete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('delete extensions', () => {

expect(spyPositional).toHaveBeenCalledWith('id', {
describe:
'The ID of a the extension to be deleted. If id is not provided, this command will delete ALL extensions in the hub.',
'The ID of the extension to be deleted. If id is not provided, this command will delete ALL extensions in the hub.',
type: 'string'
});
expect(spyOption).toHaveBeenCalledWith('f', {
Expand Down
7 changes: 4 additions & 3 deletions src/commands/extension/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const builder = (yargs: Argv): void => {
.positional('id', {
type: 'string',
describe:
'The ID of a the extension to be deleted. If id is not provided, this command will delete ALL extensions in the hub.'
'The ID of the extension to be deleted. If id is not provided, this command will delete ALL extensions in the hub.'
})
.alias('f', 'force')
.option('f', {
Expand Down Expand Up @@ -92,10 +92,11 @@ export const handler = async (
}

if (!force) {
const baseMessage = 'This action cannot be undone. Are you sure you want to continue? (Y/n)\n';
const yes = await asyncQuestion(
allExtensions
? `Providing no ID/s will delete ALL extensions! Are you sure you want to do this? (Y/n)\n`
: `${extensionsToDelete.length} extensions will be deleted. Would you like to continue? (Y/n)\n`
? `Providing no ID/s will permanently delete ALL extensions! ${baseMessage}`
: `${extensionsToDelete.length} extensions will be permanently deleted. ${baseMessage}`
);
if (!yes) {
return;
Expand Down
18 changes: 18 additions & 0 deletions src/commands/webhook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Argv } from 'yargs';
import { readConfig } from '../cli';
import YargsCommandBuilderOptions from '../common/yargs/yargs-command-builder-options';
import { configureCommandOptions } from './configure';

export const command = 'webhook';

export const desc = 'Webhook';

export const builder = (yargs: Argv): Argv =>
yargs
.commandDir('webhook', YargsCommandBuilderOptions)
.options(configureCommandOptions)
.config('config', readConfig)
.demandCommand()
.help();

export const handler = (): void => {};
Loading
Loading