private HttpResponse putTenant(RestApi.RequestContext context) {
        TenantName name = TenantName.from(context.pathParameters().getStringOrThrow("tenant"));
        if (tenantRepository.checkThatTenantExists(name))
            return new MessageResponse("Tenant '" + name + "' already exists");
        if ( ! name.value().matches(TENANT_NAME_REGEXP))
            throw new RestApiException.BadRequest("Illegal tenant name: " + name);

        tenantRepository.addTenant(name);
        return new TenantCreateResponse(name);
    }
Handler to create, get and delete a tenant, and listing of tenants.

@author jonmv
configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/TenantHandler.java