use of io.swagger.annotations.ApiResponses in project pinot by linkedin.
the class TableSizeResource method getTableSize.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/tables/{tableName}/size")
@ApiOperation(value = "Show table storage size", notes = "Lists size of all the segments of the table")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error"), @ApiResponse(code = 404, message = "Table not found") })
public TableSizeInfo getTableSize(@ApiParam(value = "Table Name with type", required = true) @PathParam("tableName") String tableName, @ApiParam(value = "Provide detailed information", required = false) @DefaultValue("true") @QueryParam("detailed") boolean detailed) throws WebApplicationException {
InstanceDataManager dataManager = (InstanceDataManager) serverInstance.getInstanceDataManager();
if (dataManager == null) {
throw new WebApplicationException("Invalid server initialization", Response.Status.INTERNAL_SERVER_ERROR);
}
TableDataManager tableDataManager = dataManager.getTableDataManager(tableName);
if (tableDataManager == null) {
throw new WebApplicationException("Table: " + tableName + " is not found", Response.Status.NOT_FOUND);
}
TableSizeInfo tableSizeInfo = new TableSizeInfo();
tableSizeInfo.tableName = tableDataManager.getTableName();
tableSizeInfo.diskSizeInBytes = 0L;
ImmutableList<SegmentDataManager> segmentDataManagers = tableDataManager.acquireAllSegments();
try {
for (SegmentDataManager segmentDataManager : segmentDataManagers) {
IndexSegment segment = segmentDataManager.getSegment();
long segmentSizeBytes = segment.getDiskSizeBytes();
if (detailed) {
SegmentSizeInfo segmentSizeInfo = new SegmentSizeInfo(segment.getSegmentName(), segmentSizeBytes);
tableSizeInfo.segments.add(segmentSizeInfo);
}
tableSizeInfo.diskSizeInBytes += segmentSizeBytes;
}
} finally {
// executes fast so duration of holding segments is not a concern
for (SegmentDataManager segmentDataManager : segmentDataManagers) {
tableDataManager.releaseSegment(segmentDataManager);
}
}
//invalid to use the segmentDataManagers below
return tableSizeInfo;
}
use of io.swagger.annotations.ApiResponses in project pinot by linkedin.
the class TablesResource method listTableSegments.
@GET
@Path("/tables/{tableName}/segments")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "List table segments", notes = "List segments of table hosted on this server")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = TableSegments.class), @ApiResponse(code = 500, message = "Server initialization error", response = ErrorInfo.class) })
public TableSegments listTableSegments(@ApiParam(value = "Table name including type", required = true, example = "myTable_OFFLINE") @PathParam("tableName") String tableName) {
TableDataManager tableDataManager = checkGetTableDataManager(tableName);
ImmutableList<SegmentDataManager> segmentDataManagers = tableDataManager.acquireAllSegments();
List<String> segments = new ArrayList<>(segmentDataManagers.size());
for (SegmentDataManager segmentDataManager : segmentDataManagers) {
segments.add(segmentDataManager.getSegmentName());
tableDataManager.releaseSegment(segmentDataManager);
}
return new TableSegments(segments);
}
use of io.swagger.annotations.ApiResponses in project killbill by killbill.
the class AccountResource method setEmailNotificationsForAccount.
@TimedResource
@PUT
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Set account email notification")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response setEmailNotificationsForAccount(final InvoiceEmailJson json, @PathParam("accountId") final String accountIdString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
verifyNonNullOrEmpty(json, "InvoiceEmailJson body should be specified");
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID accountId = UUID.fromString(accountIdString);
final Account account = accountUserApi.getAccountById(accountId, callContext);
final MutableAccountData mutableAccountData = account.toMutableAccountData();
mutableAccountData.setIsNotifiedForInvoices(json.isNotifiedForInvoices());
accountUserApi.updateAccount(accountId, mutableAccountData, callContext);
return Response.status(Status.OK).build();
}
use of io.swagger.annotations.ApiResponses in project killbill by killbill.
the class AccountResource method getAccountBundles.
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + BUNDLES)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve bundles for account", response = BundleJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response getAccountBundles(@PathParam("accountId") final String accountId, @QueryParam(QUERY_EXTERNAL_KEY) final String externalKey, @QueryParam(QUERY_BUNDLES_FILTER) final String bundlesFilter, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, SubscriptionApiException {
final TenantContext tenantContext = context.createContext(request);
final UUID uuid = UUID.fromString(accountId);
final Account account = accountUserApi.getAccountById(uuid, tenantContext);
final List<SubscriptionBundle> bundles = (externalKey != null) ? subscriptionApi.getSubscriptionBundlesForAccountIdAndExternalKey(uuid, externalKey, tenantContext) : subscriptionApi.getSubscriptionBundlesForAccountId(uuid, tenantContext);
final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext);
boolean filter = (null != bundlesFilter && !bundlesFilter.isEmpty());
final Collection<BundleJson> result = Collections2.transform((filter) ? filterBundles(bundles, Arrays.asList(bundlesFilter.split(","))) : bundles, new Function<SubscriptionBundle, BundleJson>() {
@Override
public BundleJson apply(final SubscriptionBundle input) {
try {
return new BundleJson(input, account.getCurrency(), accountAuditLogs);
} catch (final CatalogApiException e) {
// Not the cleanest thing, but guava Api don't allow throw..
throw new RuntimeException(e);
}
}
});
return Response.status(Status.OK).entity(result).build();
}
use of io.swagger.annotations.ApiResponses in project killbill by killbill.
the class AccountResource method getChildrenAccounts.
// -------------------------------------
// Parent and child accounts
// -------------------------------------
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + CHILDREN)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "List children accounts", response = AccountJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid parent account id supplied"), @ApiResponse(code = 404, message = "Parent Account not found") })
public Response getChildrenAccounts(@PathParam("accountId") final String parentAccountId, @QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance, @QueryParam(QUERY_ACCOUNT_WITH_BALANCE_AND_CBA) @DefaultValue("false") final Boolean accountWithBalanceAndCBA, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
final TenantContext tenantContext = context.createContext(request);
final List<Account> accounts = accountUserApi.getChildrenAccounts(UUID.fromString(parentAccountId), tenantContext);
final List<AccountJson> accountJson = new ArrayList<AccountJson>();
for (final Account account : accounts) {
final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext);
accountJson.add(getAccount(account, accountWithBalance, accountWithBalanceAndCBA, accountAuditLogs, tenantContext));
}
return Response.status(Status.OK).entity(accountJson).build();
}
Aggregations