def upload( ctx: click.Context, configfile: str, name: str, dry_run: bool, ) -> int: """Upload the connector configuration from a file.""" config = ctx.obj["config"] connect = Connect(config.connect_url) with open(configfile) as f: connect_config = json.load(f) # Ensure connector name is consistent connect_config["name"] = name # Validate the connector configuration only. if dry_run: validation = connect.validate( name=connect_config["connector.class"], connect_config=json.dumps(connect_config), ) click.echo(validation) return 0 click.echo(f"Uploading {name} connector configuration...") click.echo(connect.validate_and_create(name, json.dumps(connect_config))) return 0
def create_s3_sink( ctx: click.Context, configfile: str, name: str, aws_access_key_id: str, aws_secret_access_key: str, dry_run: bool, show_status: bool, show_status_interval: int, ) -> int: """Create an instance of the S3 Sink connector. Use the --show-status option to output status. """ # Get configuration from the parent command if ctx.parent: parent_config = ctx.parent.obj["config"] connect = Connect(parent_config.connect_url) with open(configfile) as f: config = json.load(f) if name: click.echo("Updating connector name.") config["name"] = name if None in (aws_access_key_id, aws_secret_access_key): click.echo( "Could not get the AWS credentials. " "Use the --access-key-id and --aws-secret-access-key options " "or set the AWS credentials using the AWS_ACCESS_KEY_ID and " "AWS_SECRET_ACCESS_KEY env variables.") return 1 config["aws.access.key.id"] = aws_access_key_id config["aws.secret.access.key"] = aws_secret_access_key # Validate the configuration only. if dry_run: validation = connect.validate( name=config["connector.class"], connect_config=json.dumps(config), ) click.echo(validation) return 0 name = config["name"] click.echo(f"Creating the {name} connector...") click.echo(connect.validate_and_create(name, json.dumps(config))) if show_status: while True: time.sleep(int(show_status_interval) / 1000) try: click.echo(connect.status(name=name)) except KeyboardInterrupt: raise click.ClickException("Interruped.") return 0
def create_jdbc_sink( ctx: click.Context, configfile: str, name: str, dry_run: bool, show_status: bool, show_status_interval: int, ) -> int: """Create an instance of the JDBC Sink connector. Use the --show-status option to output status. """ # Get configuration from the parent command if ctx.parent: parent_config = ctx.parent.obj["config"] connect = Connect(parent_config.connect_url) with open(configfile) as f: config = json.load(f) # Override connector name in the configuration if name: config["name"] = name # Validate the configuration only. if dry_run: validation = connect.validate( name=config["connector.class"], connect_config=json.dumps(config), ) click.echo(validation) return 0 name = config["name"] click.echo(f"Creating the {name} connector...") click.echo(connect.validate_and_create(name, json.dumps(config))) if show_status: while True: time.sleep(int(show_status_interval) / 1000) try: click.echo(connect.status(name=name)) except KeyboardInterrupt: raise click.ClickException("Interruped.") return 0
def create_mirrormaker2( ctx: click.Context, name: str, heartbeat_configfile: str, checkpoint_configfile: str, mirror_source_configfile: str, dry_run: bool, show_status: bool, show_status_interval: int, ) -> int: """Create an instance of the MirrorMaker 2 connectors. Create the heartbeat, checkpoint and mirror-source connectors. Use the --show-status option to output status. """ # Get configuration from the main command if ctx.parent: config = ctx.parent.obj["config"] connect = Connect(config.connect_url) with open(heartbeat_configfile) as f: heartbeat_config = json.load(f) with open(checkpoint_configfile) as f: checkpoint_config = json.load(f) with open(mirror_source_configfile) as f: mirror_source_config = json.load(f) # Override connector name in the configuration if name: heartbeat_config["name"] = f"{name}-heartbeat" checkpoint_config["name"] = f"{name}-checkpoint" mirror_source_config["name"] = f"{name}-mirror-source" # Validate the configuration only. if dry_run: heartbeat_validation = connect.validate( name=heartbeat_config["connector.class"], connect_config=json.dumps(heartbeat_config), ) click.echo(heartbeat_validation) checkpoint_validation = connect.validate( name=checkpoint_config["connector.class"], connect_config=json.dumps(checkpoint_config), ) click.echo(checkpoint_validation) mirror_source_validation = connect.validate( name=mirror_source_config["connector.class"], connect_config=json.dumps(mirror_source_config), ) click.echo(mirror_source_validation) return 0 heartbeat_name = heartbeat_config["name"] click.echo(f"Creating the {heartbeat_name} connector...") click.echo( connect.validate_and_create(heartbeat_name, json.dumps(heartbeat_config))) checkpoint_name = checkpoint_config["name"] click.echo(f"Creating the {checkpoint_name} connector...") click.echo( connect.validate_and_create(checkpoint_name, json.dumps(checkpoint_config))) mirror_source_name = mirror_source_config["name"] click.echo(f"Creating the {mirror_source_name} connector...") click.echo( connect.validate_and_create(mirror_source_name, json.dumps(mirror_source_config))) if show_status: while True: time.sleep(int(show_status_interval) / 1000) try: click.echo(connect.status(name=heartbeat_name)) click.echo(connect.status(name=checkpoint_name)) click.echo(connect.status(name=mirror_source_name)) except KeyboardInterrupt: raise click.ClickException("Interruped.") return 0