Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
args = parser.parse_args()
record = Record.query.get(args.id)
if not record:
abort(404, message="Record {} doesn't exist".format(args.id),
help=api_utils.help(parser.args, RECORD_FIELDS))
keys = ['key', 'value', 'type']
updates = 0
for key in keys:
if getattr(args, key) is not None:
updates += 1
setattr(record, key, getattr(args, key))
if not updates:
abort(400, message="No parameters to update provided",
help=api_utils.help(parser.args, RECORD_FIELDS))
db.session.add(record)
db.session.commit()
return self.get(id=record.id)
"""
parser = self._get_parser()
if id is not None:
task = _find_tasks(id=id)
if task is None:
abort(404, message="Task {} doesn't exist".format(id),
help=api_utils.help(parser.args, TASK_FIELDS))
return marshal(task, TASK_FIELDS)
args = parser.parse_args()
tasks = _find_tasks(**args)
if not tasks:
abort(404, message="No tasks found for this query",
help=api_utils.help(parser.args, TASK_FIELDS))
return marshal(tasks, TASK_FIELDS)
def get(self, id=None):
"""
Retrieves one or many playbooks based on the request and the query
"""
parser = self._get_parser()
if id is not None:
playbook = _find_playbooks(id=id)
if playbook is None:
abort(404, message="Playbook {} doesn't exist".format(id),
help=api_utils.help(parser.args, PLAYBOOK_FIELDS))
return marshal(playbook, PLAYBOOK_FIELDS)
args = parser.parse_args()
playbooks = _find_playbooks(**args)
if not playbooks:
abort(404, message='No playbooks found for this query',
help=api_utils.help(parser.args, PLAYBOOK_FIELDS))
return marshal(playbooks, PLAYBOOK_FIELDS)
'id', dest='id',
type=int,
location='values',
required=False,
help='Search with the id of the host'
)
parser.add_argument(
'playbook_id', dest='playbook_id',
type=int,
location='values',
required=False,
help='Search hosts for a playbook id'
)
parser.add_argument(
'name', dest='name',
type=api_utils.encoded_input,
location='values',
required=False,
help='Search with the name (full or part) of a host'
)
return parser
def _post_parser():
parser = reqparse.RequestParser()
parser.add_argument(
'playbook_id', dest='playbook_id',
type=int,
location='json',
required=True,
help='The playbook_id of the host'
)
parser.add_argument(
'name', dest='name',
type=api_utils.encoded_input,
location='json',
required=True,
help='The name of the host'
)
parser.add_argument(
'facts', dest='facts',
type=dict,
location='json',
required=False,
default={},
help='The facts for the host'
)
parser.add_argument(
'changed', dest='changed',
type=int,
location='json',
parser = self._post_parser()
args = parser.parse_args()
# Validate and retrieve the task reference
task = Task.query.get(args.task_id)
if not task:
abort(404,
message="Task {} doesn't exist".format(args.task_id),
help=api_utils.help(parser.args, RESULT_FIELDS))
# Validate and retrieve the host reference
host = Host.query.get(args.host_id)
if not host:
abort(404,
message="Host {} doesn't exist".format(args.host_id),
help=api_utils.help(parser.args, RESULT_FIELDS))
result = Result(
playbook=task.playbook,
host=host,
play=task.play,
task=task,
status=args.status,
changed=args.changed,
failed=args.failed,
skipped=args.skipped,
unreachable=args.unreachable,
ignore_errors=args.ignore_errors,
result=args.result,
started=args.started,
ended=args.ended
)
'playbook_id', dest='playbook_id',
type=int,
location='json',
required=True,
help='The playbook_id of the file'
)
parser.add_argument(
'path', dest='path',
type=str,
location='json',
required=True,
help='The path of the file'
)
parser.add_argument(
'content', dest='content',
type=api_utils.encoded_input,
location='json',
required=True,
help='The content of the file'
)
return parser
"""
parser = self._get_parser()
if id is not None:
file_ = _find_files(id=id)
if file_ is None:
abort(404, message="File {} doesn't exist".format(id),
help=api_utils.help(parser.args, FILE_FIELDS))
return marshal(file_, FILE_FIELDS)
args = parser.parse_args()
files = _find_files(**args)
if not files:
abort(404, message='No files found for this query',
help=api_utils.help(parser.args, FILE_FIELDS))
return marshal(files, FILE_FIELDS)
'play_id', dest='play_id',
type=int,
location='values',
required=False,
help='Search tasks for a play id'
)
parser.add_argument(
'file_id', dest='file_id',
type=int,
location='values',
required=False,
help='Search tasks for a file id'
)
parser.add_argument(
'name', dest='name',
type=api_utils.encoded_input,
location='values',
required=False,
help='Search with the name (full or part) of a task'
)
parser.add_argument(
'action', dest='action',
type=str,
location='values',
required=False,
help='Search with the action (full or part) of a task'
)
parser.add_argument(
'lineno', dest='lineno',
type=int,
location='values',
required=False,
def get(self, id=None):
"""
Retrieves one or many plays based on the request and the query
"""
parser = self._get_parser()
if id is not None:
play = _find_plays(id=id)
if play is None:
abort(404, message="Play {} doesn't exist".format(id),
help=api_utils.help(parser.args, PLAY_FIELDS))
return marshal(play, PLAY_FIELDS)
args = parser.parse_args()
plays = _find_plays(**args)
if not plays:
abort(404, message="No plays found for this query",
help=api_utils.help(parser.args, PLAY_FIELDS))
return marshal(plays, PLAY_FIELDS)