Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldiamond committed Jun 24, 2022
1 parent d66efbc commit 48676c1
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions octavia-cli/octavia_cli/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
from .check_context import check_api_health, check_is_initialized, check_workspace_exists
from .generate import commands as generate_commands
from .get import commands as get_commands
from .import_commands import commands as import_commands
from .init import commands as init_commands
from .list import commands as list_commands
from .telemetry import TelemetryClient, build_user_agent
from .update import commands as update_commands

AVAILABLE_COMMANDS: List[click.Command] = [
list_commands._list,
get_commands.get,
update_commands.update,
import_commands.import_commands,
init_commands.init,
generate_commands.generate,
apply_commands.apply,
Expand Down
2 changes: 1 addition & 1 deletion octavia-cli/octavia_cli/get/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

from typing import List
Expand Down
2 changes: 1 addition & 1 deletion octavia-cli/octavia_cli/get/resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

import abc
Expand Down
3 changes: 3 additions & 0 deletions octavia-cli/octavia_cli/import_commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

from typing import List
Expand All @@ -13,9 +13,9 @@
from octavia_cli.list.listings import Destinations, Sources


@click.group("update", help="Update configurations in a YAML spec for a source, destination or a connection.")
@click.group("import", help="Import configurations in a YAML spec for a source, destination or a connection.")
@click.pass_context
def update(ctx: click.Context):
def import_commands(ctx: click.Context):
pass


Expand All @@ -30,7 +30,7 @@ def get_resource_definition_id(resource_type, api_client, workspace_id, resource
return config[f"{resource_type.name}_definition_id"]


def update_resource(resource_type, api_client, workspace_id, resource_id):
def import_resource(resource_type, api_client, workspace_id, resource_id):
resource = resource_type(api_client, workspace_id, resource_id)
definition_type = resource_type.name
config = resource.get_config()
Expand All @@ -42,18 +42,18 @@ def update_resource(resource_type, api_client, workspace_id, resource_id):
renderer = ConnectorSpecificationRenderer(resource_name, definition)

output_path = renderer.update_configuration(project_path=".", configuration=config["connection_configuration"])
message = f"✅ - Updated the {resource_type.name} template for {resource_name} in {output_path}."
message = f"✅ - Imported the {resource_type.name} template for {resource_name} in {output_path}."
click.echo(click.style(message, fg="green"))


@update.command(cls=OctaviaCommand, name="source", help="Get YAML for a source")
@import_commands.command(cls=OctaviaCommand, name="source", help="Get YAML for a source")
@click.argument("resource_id", type=click.STRING)
@click.pass_context
def source(ctx: click.Context, resource_id: str):
update_resource(Source, ctx.obj["API_CLIENT"], ctx.obj["WORKSPACE_ID"], resource_id)
import_resource(Source, ctx.obj["API_CLIENT"], ctx.obj["WORKSPACE_ID"], resource_id)


@update.command(cls=OctaviaCommand, name="sources", help="Get YAML for a source")
@import_commands.command(cls=OctaviaCommand, name="sources", help="Get YAML for a source")
@click.pass_context
def sources(ctx: click.Context):
api_client = ctx.obj["API_CLIENT"]
Expand All @@ -65,10 +65,10 @@ def sources(ctx: click.Context):

generate_source_or_destination("source", api_client, workspace_id, definition_id, source_name)

update_resource(Source, api_client, workspace_id, source_id)
import_resource(Source, api_client, workspace_id, source_id)


@update.command(cls=OctaviaCommand, name="destinations", help="Get YAML for a destination")
@import_commands.command(cls=OctaviaCommand, name="destinations", help="Get YAML for a destination")
@click.pass_context
def destinations(ctx: click.Context):
api_client = ctx.obj["API_CLIENT"]
Expand All @@ -80,29 +80,29 @@ def destinations(ctx: click.Context):

generate_source_or_destination("destination", api_client, workspace_id, definition_id, destination_name)

update_resource(Destination, api_client, workspace_id, destination_id)
import_resource(Destination, api_client, workspace_id, destination_id)


@update.command(cls=OctaviaCommand, name="destination", help="Get YAML for a destination")
@import_commands.command(cls=OctaviaCommand, name="destination", help="Get YAML for a destination")
@click.argument("resource_id", type=click.STRING)
@click.pass_context
def destination(ctx: click.Context, resource_id: str):
update_resource(Destination, ctx.obj["API_CLIENT"], ctx.obj["WORKSPACE_ID"], resource_id)
import_resource(Destination, ctx.obj["API_CLIENT"], ctx.obj["WORKSPACE_ID"], resource_id)


@update.command(cls=OctaviaCommand, name="connection", help="Get YAML for a connection")
@import_commands.command(cls=OctaviaCommand, name="connection", help="Get YAML for a connection")
@click.argument("resource_id", type=click.STRING)
@click.pass_context
def connection(ctx: click.Context, resource_id: str):
update_resource(Connection, ctx.obj["API_CLIENT"], ctx.obj["WORKSPACE_ID"], resource_id)
import_resource(Connection, ctx.obj["API_CLIENT"], ctx.obj["WORKSPACE_ID"], resource_id)


AVAILABLE_COMMANDS: List[click.Command] = [source, destination, connection]


def add_commands_to_list():
for command in AVAILABLE_COMMANDS:
update.add_command(command)
import_commands.add_command(command)


add_commands_to_list()
3 changes: 0 additions & 3 deletions octavia-cli/octavia_cli/update/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion octavia-cli/unit_tests/test_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_available_commands():
assert entrypoint.AVAILABLE_COMMANDS == [
entrypoint.list_commands._list,
entrypoint.get_commands.get,
entrypoint.update_commands.update,
entrypoint.import_commands._import,
entrypoint.init_commands.init,
entrypoint.generate_commands.generate,
entrypoint.apply_commands.apply,
Expand Down
2 changes: 1 addition & 1 deletion octavia-cli/unit_tests/test_get/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

import pytest
Expand Down
2 changes: 1 addition & 1 deletion octavia-cli/unit_tests/test_get/test_resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

import pytest
Expand Down

0 comments on commit 48676c1

Please sign in to comment.