Search in sources :

Example 86 with TimedResource

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();
}
Also used : NodeCommandMetadata(org.killbill.billing.util.nodes.NodeCommandMetadata) PluginNodeCommandMetadata(org.killbill.billing.util.nodes.PluginNodeCommandMetadata) NodeCommand(org.killbill.billing.util.nodes.NodeCommand) TimedResource(org.killbill.commons.metrics.TimedResource) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 87 with TimedResource

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();
}
Also used : OverdueJson(org.killbill.billing.jaxrs.json.OverdueJson) TenantContext(org.killbill.billing.util.callcontext.TenantContext) OverdueConfig(org.killbill.billing.overdue.api.OverdueConfig) DefaultOverdueConfig(org.killbill.billing.overdue.config.DefaultOverdueConfig) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 88 with TimedResource

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);
}
Also used : OverdueConfig(org.killbill.billing.overdue.api.OverdueConfig) DefaultOverdueConfig(org.killbill.billing.overdue.config.DefaultOverdueConfig) CallContext(org.killbill.billing.util.callcontext.CallContext) TimedResource(org.killbill.commons.metrics.TimedResource) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 89 with TimedResource

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);
}
Also used : Account(org.killbill.billing.account.api.Account) UUID(java.util.UUID) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 90 with TimedResource

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();
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) Account(org.killbill.billing.account.api.Account) CallContext(org.killbill.billing.util.callcontext.CallContext) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)112 TimedResource (org.killbill.commons.metrics.TimedResource)112 ApiResponses (io.swagger.annotations.ApiResponses)111 Produces (javax.ws.rs.Produces)109 Path (javax.ws.rs.Path)95 UUID (java.util.UUID)59 GET (javax.ws.rs.GET)58 TenantContext (org.killbill.billing.util.callcontext.TenantContext)54 Consumes (javax.ws.rs.Consumes)48 CallContext (org.killbill.billing.util.callcontext.CallContext)48 Account (org.killbill.billing.account.api.Account)47 POST (javax.ws.rs.POST)36 PluginProperty (org.killbill.billing.payment.api.PluginProperty)35 AccountAuditLogs (org.killbill.billing.util.audit.AccountAuditLogs)31 Payment (org.killbill.billing.payment.api.Payment)19 LocalDate (org.joda.time.LocalDate)16 URI (java.net.URI)15 Invoice (org.killbill.billing.invoice.api.Invoice)15 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)11