Package coprs :: Package rest_api :: Package resources :: Module mock_chroot
[hide private]
[frames] | no frames]

Source Code for Module coprs.rest_api.resources.mock_chroot

 1  # coding: utf-8 
 2   
 3  from flask import url_for 
 4  from flask_restful import Resource 
 5   
 6  from ...logic.coprs_logic import MockChrootsLogic 
 7   
 8  from ..schemas import MockChrootSchema 
 9  from ..util import get_one_safe, get_request_parser, arg_bool 
10 11 12 -def render_mock_chroot(chroot):
13 return { 14 "chroot": MockChrootSchema().dump(chroot)[0], 15 "_links": { 16 "self": {"href": url_for(".mockchrootr", name=chroot.name)}, 17 }, 18 }
19
20 21 -class MockChrootListR(Resource):
22 23 @classmethod
24 - def get(cls):
25 parser = get_request_parser() 26 parser.add_argument('active_only', type=arg_bool) 27 req_args = parser.parse_args() 28 active_only = False 29 if req_args["active_only"]: 30 active_only = True 31 32 chroots = MockChrootsLogic.get_multiple(active_only=active_only).all() 33 34 self_extra = {} 35 if active_only: 36 self_extra["active_only"] = active_only 37 return { 38 "_links": { 39 "self": {"href": url_for(".mockchrootlistr", **self_extra)}, 40 }, 41 "chroots": [ 42 render_mock_chroot(chroot) 43 for chroot in chroots 44 ] 45 }
46
47 48 -class MockChrootR(Resource):
49 @classmethod
50 - def get(cls, name):
53