Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: swagger yaml defination #209

Draft
wants to merge 1 commit into
base: python-3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions API/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
attrs==23.1.0
blinker==1.6.3
certifi==2023.7.22
charset-normalizer==3.3.0
click==8.1.7
clickclick==20.10.2
connexion==3.0.5
Flask==2.2.2
flask-marshmallow==0.14.0
Flask-SQLAlchemy==3.0.3
greenlet==3.0.0
idna==3.4
inflection==0.5.1
itsdangerous==2.1.2
Jinja2==3.1.2
jsonschema==4.19.1
jsonschema-specifications==2023.7.1
MarkupSafe==2.1.3
marshmallow==3.20.1
marshmallow-sqlalchemy==0.29.0
packaging==23.2
PyYAML==6.0.1
referencing==0.30.2
requests==2.31.0
rpds-py==0.10.3
six==1.16.0
SQLAlchemy==2.0.22
swagger-ui-bundle==0.0.9
typing_extensions==4.8.0
urllib3==2.0.6
Werkzeug==2.2.2
14 changes: 14 additions & 0 deletions API/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[metadata]
name = bkr.api

[options]
package_dir=
=src
packages = find:
zip_safe = False
python_requires = >= 3
[options.packages.find]
where = src
exclude =
tests*
.gitignore
2 changes: 2 additions & 0 deletions API/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from setuptools import setup
setup()
Empty file added API/src/bkr/api/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions API/src/bkr/api/arches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from flask import abort

ARCHES = {}

def post(arch):
if arch and arch not in ARCHES:
ARCHES[arch] = {
"arch": arch,
}
return ARCHES[arch], 201
else:
abort(
406,
f"{arch} already exists",
)

def search(offset=0, limit=None):
start = 0
end = len(ARCHES.values())
if offset and limit:
start = offset * limit
end = start + limit
return list(ARCHES.values())[start:end]
14 changes: 14 additions & 0 deletions API/src/bkr/api/distros/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def post(distro):
pass

def search(offset=0, limit=None):
pass

def get(id):
pass

def put(id):
pass

def delete(id):
pass
14 changes: 14 additions & 0 deletions API/src/bkr/api/distros/tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def search():
pass

def post():
pass

def put():
pass

def get():
pass

def delete():
pass
3 changes: 3 additions & 0 deletions API/src/bkr/api/health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def search():
return {'msg': 'ok'}, 200

14 changes: 14 additions & 0 deletions API/src/bkr/api/jobs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def search():
pass

def post():
pass

def put():
pass

def get():
pass

def delete():
pass
2 changes: 2 additions & 0 deletions API/src/bkr/api/jobs/actions/cancel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def put():
pass
14 changes: 14 additions & 0 deletions API/src/bkr/api/jobs/sets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def search():
pass

def post():
pass

def put():
pass

def get():
pass

def delete():
pass
2 changes: 2 additions & 0 deletions API/src/bkr/api/jobs/sets/actions/cancel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def put():
pass
8 changes: 8 additions & 0 deletions API/src/bkr/api/jobs/sets/recipes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def search():
pass

def get():
pass

def patch():
pass
34 changes: 34 additions & 0 deletions API/src/bkr/api/lab_controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from flask import abort

LABCONTROLLERS = {}

def post(lab_controller):
fqdn = lab_controller.get("fqdn")
user_name = lab_controller.get("user_name", "")
email_address = lab_controller.get("email_address", "")
password = lab_controller.get("password", "")

if fqdn and fqdn not in LABCONTROLLERS:
LABCONTROLLERS[fqdn] = {
"fqdn": fqdn,
"user_name": user_name,
"email_address": email_address,
"password": password,
}
return LABCONTROLLERS[fqdn], 201
else:
abort(
406,
f"Lab Controller with fqdn {fqdn} already exists",
)

def search(offset=0, limit=None):
start = 0
end = len(LABCONTROLLERS.values())
if offset and limit:
start = offset * limit
end = start + limit
return list(LABCONTROLLERS.values())[start:end]

def get(lab_controller):
pass
14 changes: 14 additions & 0 deletions API/src/bkr/api/lab_controllers/distro_trees/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def post(distro_tree):
pass

def search(offset=0, limit=None):
pass

def get(id):
pass

def put(id):
pass

def delete(id):
pass
14 changes: 14 additions & 0 deletions API/src/bkr/api/lab_controllers/distro_trees/images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def search():
pass

def post():
pass

def put():
pass

def get():
pass

def delete():
pass
14 changes: 14 additions & 0 deletions API/src/bkr/api/lab_controllers/distro_trees/repos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def search():
pass

def post():
pass

def put():
pass

def get():
pass

def delete():
pass
23 changes: 23 additions & 0 deletions API/src/bkr/api/osmajors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from flask import abort

ARCHES = {}

def post(arch):
if arch and arch not in ARCHES:
ARCHES[arch] = {
"arch": arch,
}
return ARCHES[arch], 201
else:
abort(
406,
f"{arch} already exists",
)

def search(offset=0, limit=None):
start = 0
end = len(ARCHES.values())
if offset and limit:
start = offset * limit
end = start + limit
return list(ARCHES.values())[start:end]
23 changes: 23 additions & 0 deletions API/src/bkr/api/osversions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from flask import abort

ARCHES = {}

def post(arch):
if arch and arch not in ARCHES:
ARCHES[arch] = {
"arch": arch,
}
return ARCHES[arch], 201
else:
abort(
406,
f"{arch} already exists",
)

def search(offset=0, limit=None):
start = 0
end = len(ARCHES.values())
if offset and limit:
start = offset * limit
end = start + limit
return list(ARCHES.values())[start:end]
78 changes: 78 additions & 0 deletions API/src/bkr/api/systems/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from flask import abort
from bkr.api.lab_controllers import LABCONTROLLERS
from bkr.api.arches import ARCHES
#from bkr.model import System

SYSTEMS = {}

def post(system):
fqdn = system.get("fqdn")
owner = system.get("owner")
status = system.get("status", "unavailable")
status_reason = system.get("status_reason", "")
arches = system.get("arches", [])
power = system.get("power", {})
location = system.get("location", "")
lender = system.get("lender", "")
vender = system.get("vender", "")
model = system.get("model", "")
serial = system.get("serial", "")
lab_controller = system.get("lab_controller", "")

if lab_controller and lab_controller not in LABCONTROLLERS:
abort(
406,
f"Lab Controller {lab_controller} doesn't exist",
)

for arch in arches:
if arch not in ARCHES:
abort(
406,
f"{arch} doesn't exist, create it first.",
)

if fqdn and fqdn not in SYSTEMS:
SYSTEMS[fqdn] = {
"fqdn": fqdn,
"owner": owner,
"status": status,
"status_reason": status_reason,
"arches": arches,
"power": power,
"location": location,
"lender": lender,
"vender": vender,
"model": model,
"serial": serial,
"lab_controller": lab_controller,
}
return SYSTEMS[fqdn], 201
else:
abort(
406,
f"System with fqdn {fqdn} already exists",
)

def search(offset=0, limit=None):
start = 0
end = len(SYSTEMS.values())
if offset and limit:
start = offset * limit
end = start + limit
return list(SYSTEMS.values())[start:end]

def get(fqdn):
if fqdn in SYSTEMS:
return SYSTEMS[fqdn]
else:
abort(
404,
f"System with fqdn {fqdn} not found",
)

def put(fqdn):
pass

def delete(fqdn):
pass
11 changes: 11 additions & 0 deletions API/src/bkr/api/systems/access_policies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def search():
pass

def post():
pass

def get():
pass

def delete():
pass
2 changes: 2 additions & 0 deletions API/src/bkr/api/systems/actions/off.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def put():
pass
2 changes: 2 additions & 0 deletions API/src/bkr/api/systems/actions/on.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def put():
pass
2 changes: 2 additions & 0 deletions API/src/bkr/api/systems/actions/request_loan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def put():
pass
2 changes: 2 additions & 0 deletions API/src/bkr/api/systems/actions/reset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def put():
pass
11 changes: 11 additions & 0 deletions API/src/bkr/api/systems/activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def search():
pass

def post():
pass

def get():
pass

def delete():
pass
Loading
Loading