Search in sources :

Example 1 with PnfsManagerGetQuotaMessage

use of org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage in project dcache by dCache.

the class QuotaResources method getUserQuotas.

@GET
@ApiOperation("Get information about all user quotas known to the system." + " Results sorted lexicographically by user id.")
@ApiResponses({ @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 500, message = "Internal Server Error"), @ApiResponse(code = 503, message = "DCache not configured for quota management.") })
@Path("/user")
@Produces(MediaType.APPLICATION_JSON)
public List<QuotaInfo> getUserQuotas(@ApiParam(value = "Return user quota associated with " + "calling user only.") @DefaultValue("false") @QueryParam("user") boolean user) {
    checkAuthenticated();
    PnfsManagerGetQuotaMessage message;
    if (user) {
        message = new PnfsManagerGetQuotaMessage((int) Subjects.getUid(RequestUser.getSubject()), QuotaType.USER);
    } else {
        message = new PnfsManagerGetQuotaMessage(QuotaType.USER);
    }
    return getQuotas(message);
}
Also used : PnfsManagerGetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with PnfsManagerGetQuotaMessage

use of org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage in project dcache by dCache.

the class QuotaResources method getGroupQuotas.

@GET
@ApiOperation("Get information about all group quotas known to the system." + " Results sorted lexicographically by group id.")
@ApiResponses({ @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 500, message = "Internal Server Error"), @ApiResponse(code = 503, message = "DCache not configured for quota management.") })
@Path("/group")
@Produces(MediaType.APPLICATION_JSON)
public List<QuotaInfo> getGroupQuotas(@ApiParam(value = "Return group quota associated with " + "calling user only.") @DefaultValue("false") @QueryParam("user") boolean user) {
    checkAuthenticated();
    PnfsManagerGetQuotaMessage message;
    /*
         * REVISIT --- we may eventually want another option to return all the user's gids.
         */
    if (user) {
        message = new PnfsManagerGetQuotaMessage((int) Subjects.getPrimaryGid(RequestUser.getSubject()), QuotaType.GROUP);
    } else {
        message = new PnfsManagerGetQuotaMessage(QuotaType.GROUP);
    }
    return getQuotas(message);
}
Also used : PnfsManagerGetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 PnfsManagerGetQuotaMessage (org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage)2