Add project.type

Add response scheme when creating a project
Add body to project update
Fix create/update project not saving some fields.
Add demo flag to Project Request
This commit is contained in:
Brian Zoetewey 2024-10-29 10:00:45 -04:00
parent 7681dfbf0b
commit c38dbca84e
2 changed files with 28 additions and 8 deletions

View File

@ -136,7 +136,7 @@ definitions:
ProjectBackup:
type: object
example: {"meta":{"name":"homelab","alert":true,"alert_chat":"Test","max_parallel_tasks":0},"templates":[{"inventory":"Build","repository":"Demo","environment":"Empty","name":"Build","playbook":"build.yml","arguments":"[]","allow_override_args_in_task":false,"description":"Build Job","vault_key":null,"type":"build","start_version":"1.0.0","build_template":null,"view":"Build","autorun":false,"survey_vars":[],"suppress_success_alerts":false,"cron":"* * * * *"}],"repositories":[{"name":"Demo","git_url":"https://github.com/semaphoreui/demo-project.git","git_branch":"main","ssh_key":"None"}],"keys":[{"name":"None","type":"none"},{"name":"Vault Password","type":"login_password"}],"views":[{"title":"Build","position":0}],"inventories":[{"name":"Build","inventory":"","ssh_key":"None","become_key":"None","type":"static"},{"name":"Dev","inventory":"","ssh_key":"None","become_key":"None","type":"file"},{"name":"Prod","inventory":"","ssh_key":"None","become_key":"None","type":"file"}],"environments":[{"name":"Empty","password":null,"json":"{}","env":null}]}
example: {"meta":{"name":"homelab","alert":true,"alert_chat":"Test","max_parallel_tasks":0,"type":null},"templates":[{"inventory":"Build","repository":"Demo","environment":"Empty","name":"Build","playbook":"build.yml","arguments":"[]","allow_override_args_in_task":false,"description":"Build Job","vault_key":null,"type":"build","start_version":"1.0.0","build_template":null,"view":"Build","autorun":false,"survey_vars":[],"suppress_success_alerts":false,"cron":"* * * * *"}],"repositories":[{"name":"Demo","git_url":"https://github.com/semaphoreui/demo-project.git","git_branch":"main","ssh_key":"None"}],"keys":[{"name":"None","type":"none"},{"name":"Vault Password","type":"login_password"}],"views":[{"title":"Build","position":0}],"inventories":[{"name":"Build","inventory":"","ssh_key":"None","become_key":"None","type":"static"},{"name":"Dev","inventory":"","ssh_key":"None","become_key":"None","type":"file"},{"name":"Prod","inventory":"","ssh_key":"None","become_key":"None","type":"file"}],"environments":[{"name":"Empty","password":null,"json":"{}","env":null}]}
properties:
meta:
type: object
@ -152,6 +152,10 @@ definitions:
max_parallel_tasks:
type: integer
minimum: 0
type:
type:
- string
- 'null'
templates:
type: array
items:
@ -304,6 +308,13 @@ definitions:
max_parallel_tasks:
type: integer
minimum: 0
type:
type:
- string
- 'null'
demo:
description: Create Demo project resources?
type: boolean
Project:
type: object
properties:
@ -326,6 +337,10 @@ definitions:
max_parallel_tasks:
type: integer
minimum: 0
type:
type:
- string
- 'null'
AccessKeyRequest:
type: object
@ -1283,6 +1298,8 @@ paths:
responses:
201:
description: Created project
schema:
$ref: "#/definitions/Project"
/projects/restore:
post:
tags:
@ -1344,10 +1361,12 @@ paths:
in: body
required: true
schema:
type: object
properties:
name:
type: string
allOf:
- $ref: '#/definitions/ProjectRequest'
- properties:
id:
type: integer
minimum: 1
responses:
204:
description: Project saved

View File

@ -11,8 +11,8 @@ func (d *SqlDb) CreateProject(project db.Project) (newProject db.Project, err er
insertId, err := d.insert(
"id",
"insert into project(name, created, type) values (?, ?, ?)",
project.Name, project.Created, project.Type)
"insert into project(name, created, type, alert, alert_chat, max_parallel_tasks) values (?, ?, ?, ?, ?, ?)",
project.Name, project.Created, project.Type, project.Alert, project.AlertChat, project.MaxParallelTasks)
if err != nil {
return
@ -110,11 +110,12 @@ func (d *SqlDb) DeleteProject(projectID int) error {
func (d *SqlDb) UpdateProject(project db.Project) error {
_, err := d.exec(
"update project set name=?, alert=?, alert_chat=?, max_parallel_tasks=? where id=?",
"update project set name=?, alert=?, alert_chat=?, max_parallel_tasks=?, type=? where id=?",
project.Name,
project.Alert,
project.AlertChat,
project.MaxParallelTasks,
project.Type,
project.ID)
return err
}