from agentops.common.route_config import RouteConfig
from agentops.deploy.views.setup import (
    GithubListReposView,
    GithubOAuthCallbackView,
)
from agentops.deploy.views.deploy import (
    CreateUpdateSecretView,
    ListSecretsView,
    DeleteSecretView,
    UpdateDeploymentView,
    InitiateBuildView,
    InitiateDeploymentView,
    InitiateRunView,
    DeploymentStatusView,
    DeploymentBuildLogView,
    DeploymentHistoryView,
    ListUserDeploymentsView,
    DeleteDeploymentView,
)


route_config: list[RouteConfig] = [
    RouteConfig(
        name='github_auth',
        path="/github/auth",
        endpoint=GithubOAuthCallbackView,
        methods=["GET"],
        summary="Github authorization callback",
        description="Exchange github auth code for access_token and store in new or updated deploy project",
    ),
    RouteConfig(
        name='fetch_user_repos',
        path="/github/repos",
        endpoint=GithubListReposView,
        methods=["GET"],
        summary="List repositories user has access to",
        description="List the repositories the user has allowed the integration to have access to",
    ),
    RouteConfig(
        name='create_update_secret',
        path="/deployments/{project_id}/secrets",
        endpoint=CreateUpdateSecretView,
        methods=["POST"],
        summary="Create or update a secret for a project",
        description="Create or update a secret key-value pair for a specific project deployment",
    ),
    RouteConfig(
        name='list_secrets',
        path="/deployments/{project_id}/secrets",
        endpoint=ListSecretsView,
        methods=["GET"],
        summary="List secrets for a project",
        description="Get all secret names for a specific project deployment (values are not returned for security)",
    ),
    RouteConfig(
        name='delete_secret',
        path="/deployments/{project_id}/secrets/{secret_name}",
        endpoint=DeleteSecretView,
        methods=["DELETE"],
        summary="Delete a secret for a project",
        description="Delete a specific secret key-value pair for a project deployment",
    ),
    RouteConfig(
        name='initiate_build',
        path="/deployments/{project_id}/build",
        endpoint=InitiateBuildView,
        methods=["POST"],
        summary="Build image only",
        description="Build and push Docker image without creating deployment resources",
    ),
    RouteConfig(
        name='initiate_deployment',
        path="/deployments/{project_id}/launch",
        endpoint=InitiateDeploymentView,
        methods=["POST"],
        summary="Initiate a project deployment",
        description="Start the deployment process for a specific project",
    ),
    RouteConfig(
        name='initiate_run',
        path="/deployments/{project_id}/run",
        endpoint=InitiateRunView,
        methods=["POST"],
        summary="Run agent job",
        description="Build image and run as one-time job with input data",
    ),
    RouteConfig(
        name='deployment_status',
        path="/deployments/{project_id}/jobs/{job_id}/status",
        endpoint=DeploymentStatusView,
        methods=["GET"],
        summary="Get deployment job status and events",
        description="Get the current status and event history for a specific deployment job",
    ),
    RouteConfig(
        name='deployment_build_logs',
        path="/deployments/{project_id}/jobs/{job_id}/logs",
        endpoint=DeploymentBuildLogView,
        methods=["GET"],
        summary="Stream build logs from builder pod",
        description="Stream real-time build logs from the builder pod for a specific deployment job",
    ),
    RouteConfig(
        name='deployment_history',
        path="/deployments/{project_id}/history",
        endpoint=DeploymentHistoryView,
        methods=["GET"],
        summary="Get project deployment history",
        description="Get all deployment jobs and their status for a project",
    ),
    RouteConfig(
        name='update_deployment',
        path="/deployments/{project_id}",
        endpoint=UpdateDeploymentView,
        methods=["POST"],
        summary="Update deployment configuration",
        description="Update the deployment configuration for a specific project",
    ),
    RouteConfig(
        name='update_deployment',
        path="/deployments",
        endpoint=ListUserDeploymentsView,
        methods=["GET"],
        summary="Get a list of all deployments (projects)",
        description="Get a list of all the projects a user has access ",
    ),
    RouteConfig(
        name='delete_deployment',
        path="/deployments/{project_id}",
        endpoint=DeleteDeploymentView,
        methods=["DELETE"],
        summary="Delete a deployment",
        description="Delete a deployment and clean up associated resources for a specific project",
    ),
]
