Search in sources :

Example 46 with TimedResource

use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.

the class TransactionResource method getTags.

@TimedResource
@GET
@Path("/{transactionId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve payment transaction tags", response = TagJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid transaction id supplied"), @ApiResponse(code = 404, message = "Invoice not found") })
public Response getTags(@PathParam(ID_PARAM_NAME) final String id, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @QueryParam(QUERY_TAGS_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException, PaymentApiException {
    final TenantContext tenantContext = context.createContext(request);
    final Payment payment = paymentApi.getPaymentByTransactionId(UUID.fromString(id), false, false, ImmutableList.<PluginProperty>of(), tenantContext);
    return super.getTags(payment.getAccountId(), UUID.fromString(id), auditMode, includedDeleted, tenantContext);
}
Also used : Payment(org.killbill.billing.payment.api.Payment) TenantContext(org.killbill.billing.util.callcontext.TenantContext) Path(javax.ws.rs.Path) 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 47 with TimedResource

use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.

the class UsageResource method getUsage.

@TimedResource
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}/{unitType}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve usage for a subscription and unit type", response = RolledUpUsageJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Missing start date or end date") })
public Response getUsage(@PathParam("subscriptionId") final String subscriptionId, @PathParam("unitType") final String unitType, @QueryParam(QUERY_START_DATE) final String startDate, @QueryParam(QUERY_END_DATE) final String endDate, @javax.ws.rs.core.Context final HttpServletRequest request) {
    if (startDate == null || endDate == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    final TenantContext tenantContext = context.createContext(request);
    final LocalDate usageStartDate = LOCAL_DATE_FORMATTER.parseLocalDate(startDate);
    final LocalDate usageEndDate = LOCAL_DATE_FORMATTER.parseLocalDate(endDate);
    final RolledUpUsage usage = usageUserApi.getUsageForSubscription(UUID.fromString(subscriptionId), unitType, usageStartDate, usageEndDate, tenantContext);
    final RolledUpUsageJson result = new RolledUpUsageJson(usage);
    return Response.status(Status.OK).entity(result).build();
}
Also used : RolledUpUsageJson(org.killbill.billing.jaxrs.json.RolledUpUsageJson) RolledUpUsage(org.killbill.billing.usage.api.RolledUpUsage) TenantContext(org.killbill.billing.util.callcontext.TenantContext) LocalDate(org.joda.time.LocalDate) Path(javax.ws.rs.Path) 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 48 with TimedResource

use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.

the class UsageResource method getAllUsage.

@TimedResource
@GET
@Path("/{subscriptionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve usage for a subscription", response = RolledUpUsageJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Missing start date or end date") })
public Response getAllUsage(@PathParam("subscriptionId") final String subscriptionId, @QueryParam(QUERY_START_DATE) final String startDate, @QueryParam(QUERY_END_DATE) final String endDate, @javax.ws.rs.core.Context final HttpServletRequest request) {
    if (startDate == null || endDate == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    final TenantContext tenantContext = context.createContext(request);
    final LocalDate usageStartDate = LOCAL_DATE_FORMATTER.parseLocalDate(startDate);
    final LocalDate usageEndDate = LOCAL_DATE_FORMATTER.parseLocalDate(endDate);
    // The current JAXRS API only allows to look for one transition
    final List<LocalDate> startEndDate = ImmutableList.<LocalDate>builder().add(usageStartDate).add(usageEndDate).build();
    final List<RolledUpUsage> usage = usageUserApi.getAllUsageForSubscription(UUID.fromString(subscriptionId), startEndDate, tenantContext);
    final RolledUpUsageJson result = new RolledUpUsageJson(usage.get(0));
    return Response.status(Status.OK).entity(result).build();
}
Also used : RolledUpUsageJson(org.killbill.billing.jaxrs.json.RolledUpUsageJson) RolledUpUsage(org.killbill.billing.usage.api.RolledUpUsage) TenantContext(org.killbill.billing.util.callcontext.TenantContext) LocalDate(org.joda.time.LocalDate) Path(javax.ws.rs.Path) 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 49 with TimedResource

use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.

the class InvoicePaymentResource method getTags.

@TimedResource
@GET
@Path("/{paymentId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve payment tags", response = TagJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid payment id supplied"), @ApiResponse(code = 404, message = "Payment not found") })
public Response getTags(@PathParam(ID_PARAM_NAME) final String paymentIdString, @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @QueryParam(QUERY_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException, PaymentApiException {
    final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
    final UUID paymentId = UUID.fromString(paymentIdString);
    final TenantContext tenantContext = context.createContext(request);
    final Payment payment = paymentApi.getPayment(paymentId, false, false, pluginProperties, tenantContext);
    return super.getTags(payment.getAccountId(), paymentId, auditMode, includedDeleted, tenantContext);
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) InvoicePayment(org.killbill.billing.invoice.api.InvoicePayment) Payment(org.killbill.billing.payment.api.Payment) TenantContext(org.killbill.billing.util.callcontext.TenantContext) UUID(java.util.UUID) Path(javax.ws.rs.Path) 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 50 with TimedResource

use of org.killbill.commons.metrics.TimedResource in project killbill by killbill.

the class InvoiceResource method createMigrationInvoice.

@TimedResource
@POST
@Path("/" + MIGRATION + "/{accountId:" + UUID_PATTERN + "}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Create a migration invoice", response = InvoiceJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id or target datetime supplied") })
public Response createMigrationInvoice(final Iterable<InvoiceItemJson> items, @PathParam("accountId") final String accountId, @Nullable @QueryParam(QUERY_TARGET_DATE) final String targetDate, @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, InvoiceApiException {
    final CallContext callContext = context.createContext(createdBy, reason, comment, request);
    final Account account = accountUserApi.getAccountById(UUID.fromString(accountId), callContext);
    final Iterable<InvoiceItem> sanitizedInvoiceItems = validateSanitizeAndTranformInputItems(account.getCurrency(), items);
    final LocalDate resolvedTargetDate = toLocalDateDefaultToday(account, targetDate, callContext);
    final UUID invoiceId = invoiceApi.createMigrationInvoice(UUID.fromString(accountId), resolvedTargetDate, sanitizedInvoiceItems, callContext);
    return uriBuilder.buildResponse(uriInfo, InvoiceResource.class, "getInvoice", invoiceId, request);
}
Also used : Account(org.killbill.billing.account.api.Account) InvoiceItem(org.killbill.billing.invoice.api.InvoiceItem) UUID(java.util.UUID) CallContext(org.killbill.billing.util.callcontext.CallContext) LocalDate(org.joda.time.LocalDate) Path(javax.ws.rs.Path) 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)

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