def site_all(request): """ Return list of all sites (datacenters and offline storage sites). """ return get_many_response(Site, SiteSerializer, "sites", request, default_order="name")
def user_many(request): """ List many users. If page is not specified as a query parameter, all instances are returned. If page is specified as a query parameter, page size must also be specified, and a page of users will be returned. """ return get_many_response( User, UserSerializer, "users", request, default_order="username", )
def log_many(request): """ List many logs. If page is not specified as a query parameter, all logs are returned. If page is specified as a query parameter, page size must also be specified, and a page of assets will be returned. """ return get_many_response( Log, LogSerializer, "logs", request, default_order="-date", )
def offline_storage_site_all(request): """ Return list of all offline storage sites. """ offline_storage_sites = Site.get_offline_storage_sites() return get_many_response( Site, SiteSerializer, "offline_storage_sites", request, premade_object_query=offline_storage_sites, default_order="name", )
def datacenter_all(request): """ Return list of all datacenters. """ datacenters = Site.get_datacenters() return get_many_response( Site, SiteSerializer, "datacenters", request, premade_object_query=datacenters, default_order="name", )
def change_plan_many(request): """ List many change plans. If page is not specified as a query parameter, all models are returned. If page is specified as a query parameter, page size must also be specified, and a page of models will be returned. """ user = request.user user_change_plans = ChangePlan.objects.filter(owner=user) return get_many_response( ChangePlan, GetChangePlanSerializer, "change-plans", request, premade_object_query=user_change_plans, )
def offline_storage_asset_many(request): """ List many assets in offline storage. If page is not specified as a query parameter, all assets are returned. If page is specified as a query parameter, page size must also be specified, and a page of assets will be returned. """ (change_plan, failure_response) = get_change_plan( request.query_params.get("change_plan") ) if failure_response: return failure_response if change_plan: return get_many_assets_response_for_cp(request, change_plan, stored=True) else: stored_assets = assets_offline_queryset() return get_many_response( Asset, RecursiveAssetSerializer, "assets", request, premade_object_query=stored_assets, )
def decommissioned_asset_many(request): """ List many decommissioned assets. If page is not specified as a query parameter, all assets are returned. If page is specified as a query parameter, page size must also be specified, and a page of assets will be returned. """ (change_plan, failure_response) = get_change_plan( request.query_params.get("change_plan")) if failure_response: return failure_response if change_plan: return get_many_assets_response_for_cp( request, change_plan, decommissioned=True, ) else: return get_many_response( DecommissionedAsset, GetDecommissionedAssetSerializer, "assets", request, )