use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.
the class NodesInfoResource method triggerNodeCommand.
@TimedResource
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Trigger a node command")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid node command supplied") })
public Response triggerNodeCommand(final NodeCommandJson json, @QueryParam(QUERY_LOCAL_NODE_ONLY) @DefaultValue("false") final Boolean localNodeOnly, @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, @javax.ws.rs.core.Context final UriInfo uriInfo) throws AccountApiException {
final NodeCommandMetadata metadata = toNodeCommandMetadata(json);
final NodeCommand nodeCommand = new NodeCommand() {
@Override
public boolean isSystemCommandType() {
return json.isSystemCommandType();
}
@Override
public String getNodeCommandType() {
return json.getNodeCommandType();
}
@Override
public NodeCommandMetadata getNodeCommandMetadata() {
return metadata;
}
};
killbillInfoApi.triggerNodeCommand(nodeCommand, localNodeOnly);
return Response.status(Status.CREATED).build();
}
use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.
the class OverdueResource method getOverdueConfigJson.
@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve the overdue config as JSON", response = OverdueJson.class)
@ApiResponses(value = {})
public Response getOverdueConfigJson(@javax.ws.rs.core.Context final HttpServletRequest request) throws Exception {
final TenantContext tenantContext = context.createContext(request);
final OverdueConfig overdueConfig = overdueApi.getOverdueConfig(tenantContext);
final OverdueJson result = new OverdueJson(overdueConfig);
return Response.status(Status.OK).entity(result).build();
}
use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.
the class OverdueResource method uploadOverdueConfigJson.
@TimedResource
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Upload the full overdue config as JSON")
@ApiResponses(value = {})
public Response uploadOverdueConfigJson(final OverdueJson overdueJson, @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, @javax.ws.rs.core.Context final UriInfo uriInfo) throws Exception {
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final OverdueConfig overdueConfig = OverdueJson.toOverdueConfigWithValidation(overdueJson);
overdueApi.uploadOverdueConfig(overdueConfig, callContext);
return uriBuilder.buildResponse(uriInfo, OverdueResource.class, null, null, request);
}
use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.
the class AccountResource method updateAccount.
@TimedResource
@PUT
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}")
@ApiOperation(value = "Update account")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account data supplied") })
public Response updateAccount(final AccountJson json, @PathParam("accountId") final String accountId, @QueryParam(QUERY_ACCOUNT_TREAT_NULL_AS_RESET) @DefaultValue("false") final Boolean treatNullValueAsReset, @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, "AccountJson body should be specified");
final UUID uuid = UUID.fromString(accountId);
final Account data = json.toAccount(uuid);
if (treatNullValueAsReset) {
accountUserApi.updateAccount(data, context.createContext(createdBy, reason, comment, request));
} else {
accountUserApi.updateAccount(uuid, data, context.createContext(createdBy, reason, comment, request));
}
return getAccount(accountId, false, false, new AuditMode(AuditLevel.NONE.toString()), request);
}
use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.
the class AccountResource method refreshPaymentMethods.
@TimedResource
@POST
@Path("/{accountId:" + UUID_PATTERN + "}/" + PAYMENT_METHODS + "/refresh")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Refresh account payment methods")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response refreshPaymentMethods(@PathParam("accountId") final String accountId, @QueryParam(QUERY_PAYMENT_PLUGIN_NAME) final String pluginName, @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString, @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, PaymentApiException {
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), callContext);
if (pluginName != null && !pluginName.isEmpty()) {
paymentApi.refreshPaymentMethods(account, pluginName, pluginProperties, callContext);
} else {
paymentApi.refreshPaymentMethods(account, pluginProperties, callContext);
}
return Response.status(Status.OK).build();
}
Aggregations