Skip to content

Commit

Permalink
LITE-28259: stream clone
Browse files Browse the repository at this point in the history
  • Loading branch information
gab832 committed Aug 18, 2023
1 parent 6667aa8 commit b8e183c
Show file tree
Hide file tree
Showing 5 changed files with 1,199 additions and 1 deletion.
63 changes: 63 additions & 0 deletions connect/cli/plugins/commerce/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
from connect.cli.core.config import pass_config
from connect.cli.core.terminal import console
from connect.cli.plugins.commerce.utils import (
clone_stream,
display_streams_table,
export_stream,
get_destination_account,
print_results,
)


Expand Down Expand Up @@ -102,5 +105,65 @@ def cmd_export_stream(config, stream_id, output_file, output_path):
)


@grp_commerce_streams.command(
name='clone',
short_help='Create a clone of a stream.',
)
@click.argument('source_stream_id', metavar='stream_id', nargs=1, required=True) # noqa: E304
@click.option(
'--destination_account',
'-d',
'destination_account',
help='Destination account ID',
)
@click.option(
'--new-stream-name',
'-n',
'name',
help='Cloned stream name',
)
@click.option(
'--validate',
'-v',
is_flag=True,
help='Executes the validate action after the clone.',
default=False,
)
@pass_config
def cmd_clone_stream(
config,
source_stream_id,
destination_account,
name,
validate,
):
destination_account_instance = get_destination_account(config, destination_account)

console.confirm(
'Are you sure you want to Clone ' f'the stream {source_stream_id} ?',
abort=True,
)
console.echo('')

stream_id, results = clone_stream(
origin_account=config.active,
stream_id=source_stream_id,
destination_account=destination_account_instance,
stream_name=name,
validate=validate,
)

console.echo('')

console.secho(
f'Stream {source_stream_id} cloned properly to {stream_id}.',
fg='green',
)

console.echo('')

print_results(results)


def get_group():
return grp_commerce
Loading

0 comments on commit b8e183c

Please sign in to comment.