Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validators=(colander_querystring_validator, validate_packages,))
@stacks.get(accept=('application/json', 'text/json'),
error_handler=bodhi.server.services.errors.json_handler,
schema=bodhi.server.schemas.ListStackSchema,
validators=(colander_querystring_validator, validate_packages,), renderer='json')
def query_stacks(request):
"""
Return a paginated list of filtered stacks.
Args:
request (pyramid.request): The current web request.
Returns:
dict: A dictionary with the following keys: "stacks" indexing a list of Stacks that match
the query, "page" indexing the current page, "pages" indexing the total number of pages,
"rows_per_page" indexing how many rows are in a page, and "total" indexing the total
number of matched Stacks.
"""
validators=(colander_querystring_validator,))
def query_packages(request):
"""
Search for packages via query string parameters.
The following query string parameters may be used to limit the packages returned by the service:
name: The name of the Packages you wish to retrieve.
like: Search for Packages with names like the given string.
search: Search for Packages with names like the given string, with case insensitivity.
page: Retrieve the specified page of search results.
rows_per_page: Specify how many rows per page are desired.
Args:
request (pyramid.request): The current web request.
Returns:
dict: A dictionary with the following key value mappings:
packages: An iterable of packages that match the search criteria.
validators=(colander_querystring_validator, validate_releases, validate_updates,
validate_packages))
def query_builds(request):
"""
Search for Builds by given criteria.
The following criteria can be provided via query string parameters to search for Builds:
nvr: The dash-separated name-version-release of a Build.
updates: A space or comma separated list of updates to limit the search by.
packages: A space or comma separated list of packages to search for builds by.
releases: A space or comma separated list of release ids to limit builds by.
page: Which page of search results are desired.
rows_per_pags: How many results per page are desired.
Args:
request (pyramid.request): The current request, containing the search criteria documented
above.
return
try:
update.set_request(request.db, action, request.user.name)
except BodhiException as e:
log.info("Failed to set the request: %s", e)
request.errors.add('body', 'request', str(e))
except Exception as e:
log.exception("Unhandled exception in set_request")
request.errors.add('body', 'request', str(e))
return dict(update=update)
validators = (
colander_querystring_validator,
validate_release,
validate_releases,
validate_enums,
validate_username,
validate_bugs,
)
@updates_rss.get(schema=bodhi.server.schemas.ListUpdateSchema, renderer='rss',
error_handler=bodhi.server.services.errors.html_handler,
validators=validators)
@updates.get(schema=bodhi.server.schemas.ListUpdateSchema, renderer='rss',
accept=('application/atom+xml',),
error_handler=bodhi.server.services.errors.html_handler,
validators=validators)
@updates.get(schema=bodhi.server.schemas.ListUpdateSchema,
Return JSON for a release given by name.
Args:
request (pyramid.json): The current request.
Returns:
bodhi.server.models.Release: The matched Release.
"""
id = request.matchdict.get('name')
release = Release.get(id)
if not release:
request.errors.add('body', 'name', 'No such release')
request.errors.status = HTTPNotFound.code
return release
releases_get_validators = (colander_querystring_validator, validate_release, validate_updates,
validate_packages)
@releases.get(accept="text/html", schema=bodhi.server.schemas.ListReleaseSchema,
renderer='releases.html',
error_handler=bodhi.server.services.errors.html_handler,
validators=releases_get_validators)
def query_releases_html(request):
"""
Return all releases, collated by state, rendered as HTML.
Args:
request (pyramid.request): The current request.
Returns:
dict: A dictionary with a single key, releases, mapping another dictionary that maps release
states to a list of Release objects that are in that state.
if not build:
request.errors.add('url', 'nvr', 'No such build')
request.errors.status = HTTPNotFound.code
return
if not build.override:
request.errors.add('url', 'nvr',
'No buildroot override for this build')
request.errors.status = HTTPNotFound.code
return
return dict(override=build.override)
validators = (
colander_querystring_validator,
validate_packages,
validate_releases,
validate_username,
)
@overrides_rss.get(schema=bodhi.server.schemas.ListOverrideSchema, renderer='rss',
error_handler=bodhi.server.services.errors.html_handler,
validators=validators)
@overrides.get(schema=bodhi.server.schemas.ListOverrideSchema, renderer='rss',
accept=('application/atom+xml',),
error_handler=bodhi.server.services.errors.html_handler,
validators=validators)
@overrides.get(schema=bodhi.server.schemas.ListOverrideSchema,
accept=("application/json", "text/json"), renderer="json",
error_handler=bodhi.server.services.errors.json_handler,
urls = {
'comments_by': rurl('comments') + '?user=%s' % id,
'comments_on': rurl('comments') + '?update_owner=%s' % id,
'recent_updates': rurl('updates') + '?user=%s' % id,
'recent_overrides': rurl('overrides') + '?user=%s' % id,
'comments_by_rss': rurl('comments_rss') + '?user=%s' % id,
'comments_on_rss': rurl('comments_rss') + '?update_owner=%s' % id,
'recent_updates_rss': rurl('updates_rss') + '?user=%s' % id,
'recent_overrides_rss': rurl('overrides_rss') + '?user=%s' % id,
}
return dict(user=user, urls=urls)
validators = (
colander_querystring_validator,
validate_groups,
validate_updates,
)
@users.get(schema=bodhi.server.schemas.ListUserSchema,
accept=("application/json", "text/json"), renderer="json",
error_handler=bodhi.server.services.errors.json_handler,
validators=validators)
@users.get(schema=bodhi.server.schemas.ListUserSchema,
accept=("application/javascript"), renderer="jsonp",
error_handler=bodhi.server.services.errors.jsonp_handler,
validators=validators)
@users.get(schema=bodhi.server.schemas.ListUserSchema, renderer="rss",
accept=('application/atom+xml',),
error_handler=bodhi.server.services.errors.html_handler,
@comment.get(accept="text/html", renderer="comment.html",
error_handler=bodhi.server.services.errors.html_handler)
def get_comment(request):
"""
Return a single comment from an id.
Args:
request (pyramid.request): The current request.
Return:
dict: A dictionary with key "comment" indexing the requested comment.
"""
return dict(comment=request.validated['comment'])
validators = (
colander_querystring_validator,
validate_username,
validate_update_owner,
validate_ignore_user,
validate_updates,
validate_packages,
)
@comments_rss.get(
schema=bodhi.server.schemas.ListCommentSchema, renderer='rss',
error_handler=bodhi.server.services.errors.html_handler, validators=validators)
@comments.get(
schema=bodhi.server.schemas.ListCommentSchema, renderer='rss',
accept=('application/atom+xml',),
error_handler=bodhi.server.services.errors.html_handler, validators=validators)
@comments.get(