Search in sources :

Example 1 with TenantKeyJson

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

the class TenantResource method getUserKeyValue.

@TimedResource
@GET
@Path("/" + USER_KEY_VALUE + "/{keyName:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a per tenant user key/value", response = TenantKeyJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid tenantId supplied") })
public Response getUserKeyValue(@PathParam("keyName") final String key, @javax.ws.rs.core.Context final HttpServletRequest request) throws TenantApiException {
    final TenantContext tenantContext = context.createContext(request);
    final List<String> values = tenantApi.getTenantValuesForKey(key, tenantContext);
    final TenantKeyJson result = new TenantKeyJson(key, values);
    return Response.status(Status.OK).entity(result).build();
}
Also used : TenantContext(org.killbill.billing.util.callcontext.TenantContext) TenantKeyJson(org.killbill.billing.jaxrs.json.TenantKeyJson) 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 TenantKeyJson

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

the class TenantResource method getAllPluginConfiguration.

@TimedResource
@GET
@Path("/" + UPLOAD_PER_TENANT_CONFIG + "/{keyPrefix:" + ANYTHING_PATTERN + "}" + "/" + SEARCH)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a per tenant key value based on key prefix", response = TenantKeyJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid tenantId supplied") })
public Response getAllPluginConfiguration(@PathParam("keyPrefix") final String keyPrefix, @javax.ws.rs.core.Context final HttpServletRequest request) throws TenantApiException {
    final TenantContext tenantContext = context.createContext(request);
    final Map<String, List<String>> apiResult = tenantApi.searchTenantKeyValues(keyPrefix, tenantContext);
    final List<TenantKeyJson> result = new ArrayList<TenantKeyJson>();
    for (final String cur : apiResult.keySet()) {
        result.add(new TenantKeyJson(cur, apiResult.get(cur)));
    }
    return Response.status(Status.OK).entity(result).build();
}
Also used : ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) List(java.util.List) ArrayList(java.util.ArrayList) TenantKeyJson(org.killbill.billing.jaxrs.json.TenantKeyJson) 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 3 with TenantKeyJson

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

the class TenantResource method getTenantKey.

private Response getTenantKey(final TenantKey key, @Nullable final String keyPostfix, final HttpServletRequest request) throws TenantApiException {
    final TenantContext tenantContext = context.createContext(request);
    final String tenantKey = keyPostfix != null ? key.toString() + keyPostfix : key.toString();
    final List<String> values = tenantApi.getTenantValuesForKey(tenantKey, tenantContext);
    final TenantKeyJson result = new TenantKeyJson(tenantKey, values);
    return Response.status(Status.OK).entity(result).build();
}
Also used : TenantContext(org.killbill.billing.util.callcontext.TenantContext) TenantKeyJson(org.killbill.billing.jaxrs.json.TenantKeyJson)

Aggregations

TenantKeyJson (org.killbill.billing.jaxrs.json.TenantKeyJson)3 TenantContext (org.killbill.billing.util.callcontext.TenantContext)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 TimedResource (org.killbill.commons.metrics.TimedResource)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1