Search in sources :

Example 1 with TagDefinitionJson

use of org.killbill.billing.jaxrs.json.TagDefinitionJson in project killbill by killbill.

the class TagDefinitionResource method getTagDefinition.

@TimedResource
@GET
@Path("/{tagDefinitionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a tag definition", response = TagDefinitionJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid tagDefinitionId supplied") })
public Response getTagDefinition(@PathParam("tagDefinitionId") final String tagDefId, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException {
    final TenantContext tenantContext = context.createContext(request);
    final TagDefinition tagDefinition = tagUserApi.getTagDefinition(UUID.fromString(tagDefId), tenantContext);
    final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(tagDefinition.getId(), ObjectType.TAG_DEFINITION, auditMode.getLevel(), tenantContext);
    final TagDefinitionJson json = new TagDefinitionJson(tagDefinition, auditLogs);
    return Response.status(Status.OK).entity(json).build();
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) TenantContext(org.killbill.billing.util.callcontext.TenantContext) TagDefinitionJson(org.killbill.billing.jaxrs.json.TagDefinitionJson) AuditLog(org.killbill.billing.util.audit.AuditLog) 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 2 with TagDefinitionJson

use of org.killbill.billing.jaxrs.json.TagDefinitionJson in project killbill by killbill.

the class TagDefinitionResource method getTagDefinitions.

@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "List tag definitions", response = TagDefinitionJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getTagDefinitions(@javax.ws.rs.core.Context final HttpServletRequest request, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode) {
    final TenantContext tenantContext = context.createTenantContextNoAccountId(request);
    final List<TagDefinition> tagDefinitions = tagUserApi.getTagDefinitions(tenantContext);
    final Collection<TagDefinitionJson> result = new LinkedList<TagDefinitionJson>();
    for (final TagDefinition tagDefinition : tagDefinitions) {
        final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(tagDefinition.getId(), ObjectType.TAG_DEFINITION, auditMode.getLevel(), tenantContext);
        result.add(new TagDefinitionJson(tagDefinition, auditLogs));
    }
    return Response.status(Status.OK).entity(result).build();
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) TenantContext(org.killbill.billing.util.callcontext.TenantContext) TagDefinitionJson(org.killbill.billing.jaxrs.json.TagDefinitionJson) LinkedList(java.util.LinkedList) AuditLog(org.killbill.billing.util.audit.AuditLog) 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 3 with TagDefinitionJson

use of org.killbill.billing.jaxrs.json.TagDefinitionJson in project killbill by killbill.

the class TagDefinitionResource method getTagDefinition.

@TimedResource
@GET
@Path("/{tagDefinitionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a tag definition", response = TagDefinitionJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid tagDefinitionId supplied") })
public Response getTagDefinition(@PathParam("tagDefinitionId") final UUID tagDefId, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException {
    final TenantContext tenantContext = context.createTenantContextNoAccountId(request);
    final TagDefinition tagDefinition = tagUserApi.getTagDefinition(tagDefId, tenantContext);
    final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(tagDefinition.getId(), ObjectType.TAG_DEFINITION, auditMode.getLevel(), tenantContext);
    final TagDefinitionJson json = new TagDefinitionJson(tagDefinition, auditLogs);
    return Response.status(Status.OK).entity(json).build();
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) TenantContext(org.killbill.billing.util.callcontext.TenantContext) TagDefinitionJson(org.killbill.billing.jaxrs.json.TagDefinitionJson) AuditLog(org.killbill.billing.util.audit.AuditLog) 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)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 GET (javax.ws.rs.GET)3 Produces (javax.ws.rs.Produces)3 TagDefinitionJson (org.killbill.billing.jaxrs.json.TagDefinitionJson)3 AuditLog (org.killbill.billing.util.audit.AuditLog)3 TenantContext (org.killbill.billing.util.callcontext.TenantContext)3 TagDefinition (org.killbill.billing.util.tag.TagDefinition)3 TimedResource (org.killbill.commons.metrics.TimedResource)3 Path (javax.ws.rs.Path)2 LinkedList (java.util.LinkedList)1