-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(routes): dedicate all routes to specific directory
- Loading branch information
1 parent
dbd2fc3
commit 12e95f6
Showing
25 changed files
with
205 additions
and
148 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from fastapi import FastAPI | ||
|
||
app = FastAPI() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,3 @@ | ||
|
||
from .gpt_services import gpt_service | ||
from .services import (write_basic, | ||
write_bugfix, | ||
write_installation, | ||
edit_directory_generator,execute_pythonfile) | ||
from app.models import (IaCBasicInput, | ||
IaCBugfixInput, | ||
Output, | ||
IaCInstallationInput,IaCTemplateGenerationDocker,HelmTemplateGeneration) | ||
|
||
from fastapi import FastAPI, HTTPException,Response | ||
from fastapi.responses import FileResponse | ||
from .prompt_generators import (IaC_basics_generator, | ||
IaC_bugfix_generator, | ||
IaC_installation_generator, | ||
helm_template_generator) | ||
|
||
from app.template_generators.terraform.docker import (IaC_template_generator_docker) | ||
|
||
import os | ||
app = FastAPI() | ||
|
||
|
||
@app.post("/IaC-basic/") | ||
async def IaC_basic_generation(request:IaCBasicInput) -> Output: | ||
|
||
generated_prompt = IaC_basics_generator(request) | ||
output = gpt_service(generated_prompt) | ||
return Output(output=output) | ||
|
||
@app.post("/IaC-bugfix/") | ||
async def IaC_bugfix_generation(request:IaCBugfixInput) -> Output: | ||
|
||
generated_prompt = IaC_bugfix_generator(request) | ||
output = gpt_service(generated_prompt) | ||
return Output(output=output) | ||
|
||
|
||
@app.post("/IaC-install/") | ||
async def IaC_install_generation(request:IaCInstallationInput) -> Output: | ||
|
||
generated_prompt = IaC_installation_generator(request) | ||
output = gpt_service(generated_prompt) | ||
return Output(output=output) | ||
|
||
@app.post("/IaC-template/docker") | ||
async def IaC_template_generation_docker(request:IaCTemplateGenerationDocker) -> Output: | ||
|
||
generated_prompt = IaC_template_generator_docker(request) | ||
output = gpt_service(generated_prompt) | ||
edit_directory_generator("terraform_generator",output) | ||
execute_pythonfile("MyTerraform","terraform_generator") | ||
return Output(output='output') | ||
|
||
@app.post("/Helm-template/") | ||
async def Helm_template_generation(request:HelmTemplateGeneration) -> Output: | ||
|
||
generated_prompt = helm_template_generator(request) | ||
output = gpt_service(generated_prompt) | ||
edit_directory_generator("helm_generator",output) | ||
execute_pythonfile("MyHelm","helm_generator") | ||
return Output(output='output') | ||
|
||
|
||
|
||
|
||
|
||
|
||
@app.get("/download/{filename}") | ||
def download_file(filename: str): | ||
folder = "app/media/MyTerraform" # specify your folder path here | ||
file_path = os.path.join(folder, filename) | ||
|
||
# Ensure the file exists | ||
if not os.path.isfile(file_path): | ||
raise HTTPException(status_code=404, detail="File not found.") | ||
|
||
# Return the file response for download | ||
return FileResponse(file_path, media_type='application/octet-stream', filename=filename) | ||
|
||
@app.get("/list-directory") | ||
def list_directory(folder: str): | ||
# Ensure the folder exists | ||
if not os.path.isdir(folder): | ||
raise HTTPException(status_code=404, detail=f"{folder} does not exist.") | ||
|
||
# List the contents of the directory | ||
contents = os.listdir(folder) | ||
return {"folder": folder, "contents": contents} | ||
from app.routes.utils import * | ||
from app.routes.terraform import * | ||
from app.routes.helm import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
|
||
provider "docker" { | ||
host = "unix:///var/run/docker.sock" | ||
} | ||
|
||
module "docker" { | ||
source = "./modules/docker" | ||
|
||
image_name = var.image_name | ||
image_force_remove = var.image_force_remove | ||
image_build = var.image_build | ||
image_count = var.image_count | ||
image_name = var.image_name | ||
image_force_remove = var.image_force_remove | ||
image_build = var.image_build | ||
image_count = var.image_count | ||
|
||
container_image = var.container_image | ||
container_name = var.container_name | ||
container_hostname = var.container_hostname | ||
container_restart = var.container_restart | ||
container_count = var.container_count | ||
container_count = var.container_count | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
resource "docker_image" "image" { | ||
count = var.image_count | ||
name = var.image_name | ||
force_remove = var.image_force_remove | ||
|
||
resource "docker_image" "app_image" { | ||
count = var.image_count | ||
name = var.image_name | ||
force_remove = var.image_force_remove | ||
|
||
build { | ||
context = var.image_build.context | ||
tag = var.image_build.tag | ||
} | ||
} | ||
|
||
resource "docker_container" "container" { | ||
count = var.container_count | ||
image = var.container_image | ||
name = var.container_name | ||
hostname = var.container_hostname | ||
restart = var.container_restart | ||
resource "docker_container" "app_container" { | ||
count = var.container_count | ||
image = var.container_image | ||
name = var.container_name | ||
hostname = var.container_hostname | ||
restart = var.container_restart | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
variable "image_name" { | ||
type = string | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
variable "image_name" { | ||
type = string | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from app.app_instance import app | ||
from app.gpt_services import gpt_service | ||
from app.services import (write_installation,edit_directory_generator,execute_pythonfile) | ||
from app.models import (HelmTemplateGeneration,Output) | ||
from app.prompt_generators import (helm_template_generator) | ||
|
||
@app.post("/Helm-template/") | ||
async def Helm_template_generation(request:HelmTemplateGeneration) -> Output: | ||
|
||
generated_prompt = helm_template_generator(request) | ||
output = gpt_service(generated_prompt) | ||
edit_directory_generator("helm_generator",output) | ||
execute_pythonfile("MyHelm","helm_generator") | ||
return Output(output='output') |
Oops, something went wrong.