Ejemplo n.º 1
0
 @POST
 @ApiOperation(
     value = "Create a new tenant.",
     notes =
         "Clients are not required to create explicitly create a "
             + "tenant before starting to store metric data. It is recommended to do so however to ensure that there "
             + "are no tenant id naming collisions and to provide default data retention settings.")
 @ApiResponses(
     value = {
       @ApiResponse(code = 201, message = "Tenant has been succesfully created."),
       @ApiResponse(
           code = 400,
           message = "Missing or invalid retention properties. ",
           response = ApiError.class),
       @ApiResponse(
           code = 409,
           message = "Given tenant id has already been created.",
           response = ApiError.class),
       @ApiResponse(
           code = 500,
           message = "An unexpected error occured while trying to create a tenant.",
           response = ApiError.class)
     })
 public void createTenant(
     @Suspended AsyncResponse asyncResponse,
     @ApiParam(required = true) TenantDefinition tenantDefinition,
     @Context UriInfo uriInfo) {
   URI location = uriInfo.getBaseUriBuilder().path("/tenants").build();
   metricsService
       .createTenant(tenantDefinition.toTenant())
       .subscribe(new TenantCreatedObserver(asyncResponse, location));
 }
Ejemplo n.º 2
0
 @GET
 @ApiOperation(
     value = "Returns a list of tenants.",
     response = TenantDefinition.class,
     responseContainer = "List")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Returned a list of tenants successfully."),
       @ApiResponse(code = 204, message = "No tenants were found."),
       @ApiResponse(
           code = 500,
           message = "Unexpected error occurred while fetching tenants.",
           response = ApiError.class)
     })
 public void findTenants(@Suspended AsyncResponse asyncResponse) {
   metricsService
       .getTenants()
       .map(TenantDefinition::new)
       .toList()
       .subscribe(
           tenants -> asyncResponse.resume(collectionToResponse(tenants)),
           error -> asyncResponse.resume(serverError(error)));
 }