Java 类io.swagger.annotations.Authorization 实例源码

项目:mid-tier    文件:VirtualAccountServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=virtualaccount;v=1"})
@ApiOperation(value = "lists accounts", response = VirtualAccountsRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        extensions = {@Extension(name = "roles", properties = {
                @ExtensionProperty(name = "advisor", value = "advisors are allowed getting every virtualaccount"),
                @ExtensionProperty(name = "customer", value = "customer only allowed getting own locations")}
        )},
        produces = "application/hal+json, application/hal+json;concept=locations;v=1",
        notes = "List all locations in a default projection, which is VirtualAccount version 1" +
                "Supported projections and versions are: " +
                "VirtualAccounts in version 1 " +
                "The Accept header for the default version is application/hal+json;concept=virtualaccount;v=1.0.0.... " +
                "The format for the default version is {....}", nickname = "listVirtualAccounts")
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response list(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return accountsProducer.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
项目:mid-tier    文件:CustomerServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=customers;v=1"})
@ApiOperation(value = "lists customers", response = CustomersRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        extensions = {@Extension(name = "roles", properties = {
                @ExtensionProperty(name = "advisor", value = "advisors are allowed getting every customer"),
                @ExtensionProperty(name = "customer", value = "customer only allowed getting own information")}
        )},
        produces = "application/hal+json, application/hal+json;concept=customers;v=1",
        notes = "List all customers in a default projection, which is Customers version 1" +
                "Supported projections and versions are: " +
                "Customers in version 1 " +
                "The Accept header for the default version is application/hal+json;concept=customers;v=1.0.0.... " +
                "The format for the default version is {....}", nickname = "listCustomers")
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response list(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return customersProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
项目:mid-tier    文件:CustomerEventServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=events;v=1"})
@ApiOperation(
        value = "obtain all events emitted by the customer-event service", response = EventsRepresentation.class,
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the customers service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the customers service",
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        tags = {"interval", "events"},
        produces = "application/hal+json,  application/hal+json;concept=events;v=1",
        nickname = "listAllCustomerEvents"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response listAllCustomerEvents(@Context UriInfo uriInfo, @Context Request request,
                        @HeaderParam("Accept") String accept, @QueryParam("interval") String interval) {
    return eventsProducers.getOrDefault(accept, this::handleUnsupportedContentType)
            .getResponse(uriInfo, request, interval);
}
项目:mid-tier    文件:CustomerEventFeedMetadataServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=metadata;v=1"})
@ApiOperation(
        value = "metadata for the events endpoint", response = EventsMetadataRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the customer service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the customer service",
        tags = {"events"},
        produces = "application/hal+json,  application/hal+json;concept=metadata;v=1",
        nickname = "getCustomerMetadata"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response getCustomerServiceMetadata(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return eventMetadataProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
项目:mid-tier    文件:AccountEventServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=events;v=1"})
@ApiOperation(
        value = "obtain all events emitted by the account-event service", response = EventsRepresentation.class,
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the account service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the account service",
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        tags = {"interval", "events"},
        produces = "application/hal+json,  application/hal+json;concept=events;v=1",
        nickname = "listAccountAllEvents"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response listAll(@Context UriInfo uriInfo, @Context Request request,
                        @HeaderParam("Accept") String accept, @QueryParam("interval") String interval) {
    return eventsProducers.getOrDefault(accept, this::handleUnsupportedContentType)
            .getResponse(uriInfo, request, interval);
}
项目:mid-tier    文件:AccountServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=accountoverview;v=1"})
@ApiOperation(value = "lists accounts", response = AccountsRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        extensions = {@Extension(name = "roles", properties = {
                @ExtensionProperty(name = "advisor", value = "advisors are allowed getting every account"),
                @ExtensionProperty(name = "customer", value = "customer only allowed getting own accounts")}
        )},
        produces = "application/hal+json, application/hal+json;concept=accountoverview;v=1",
        notes = "List all accounts in a default projection, which is AccountOverview version 1" +
                "Supported projections and versions are: " +
                "AccountOverview in version 1 " +
                "The Accept header for the default version is application/hal+json;concept=AccountOverview;v=1.0.0.... " +
                "The format for the default version is {....}", nickname = "listAccounts")
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response list(@Context UriInfo uriInfo, @Context Request request, @QueryParam("customer") @DefaultValue("0") String customer, @HeaderParam("Accept") String accept) {
    return accountsProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request, customer);
}
项目:mid-tier    文件:AccountEventFeedMetadataServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=metadata;v=1"})
@ApiOperation(
        value = "metadata for the events endpoint", response = EventsMetadataRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the account service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the account service",
        tags = {"events"},
        produces = "application/hal+json,  application/hal+json;concept=metadata;v=1",
        nickname = "getAccountMetadata"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response getMetadata(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return eventMetadataProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
项目:mid-tier    文件:LocationServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=location;v=1"})
@ApiOperation(value = "lists locations", response = LocationsRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        extensions = {@Extension(name = "roles", properties = {
                @ExtensionProperty(name = "advisor", value = "advisors are allowed getting every location"),
                @ExtensionProperty(name = "customer", value = "customer only allowed getting own locations")}
        )},
        produces = "application/hal+json, application/hal+json;concept=locations;v=1",
        notes = "List all locations in a default projection, which is Location version 1" +
                "Supported projections and versions are: " +
                "Locations in version 1 " +
                "The Accept header for the default version is application/hal+json;concept=location;v=1.0.0.... " +
                "The format for the default version is {....}", nickname = "listLocations")
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response list(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return locationsProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
项目:mid-tier    文件:LocationEventServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=events;v=1"})
@ApiOperation(
        value = "obtain all events emitted by the customer-event service", response = EventsRepresentation.class,
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the customers service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the customers service",
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        tags = {"interval", "events"},
        produces = "application/hal+json,  application/hal+json;concept=events;v=1",
        nickname = "listLocationAllEvents"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response listAll(@Context UriInfo uriInfo, @Context Request request,
                        @HeaderParam("Accept") String accept, @QueryParam("interval") String interval) {
    return eventsProducers.getOrDefault(accept, this::handleUnsupportedContentType)
            .getResponse(uriInfo, request, interval);
}
项目:mid-tier    文件:LocationEventFeedMetadataServiceExposure.java   
@GET
@Produces({"application/hal+json", "application/hal+json;concept=metadata;v=1"})
@ApiOperation(
        value = "metadata for the events endpoint", response = EventsMetadataRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the customer service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the customer service",
        tags = {"events"},
        produces = "application/hal+json,  application/hal+json;concept=metadata;v=1",
        nickname = "getLocationMetadata"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response getMetadata(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return eventMetadataProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
项目:datacollector    文件:AdminResource.java   
@POST
@Path("/shutdown")
@ApiOperation(value = "Shutdown SDC", authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({AuthzRole.ADMIN, AuthzRole.ADMIN_REMOTE})
public Response shutdown() throws PipelineStoreException {
  Thread thread = new Thread("Shutdown Request") {
    @Override
    public void run() {
      // sleeping  500ms to allow the HTTP response to go back
      ThreadUtil.sleep(500);
      runtimeInfo.shutdown(0);
    }
  };
  thread.setDaemon(true);
  thread.start();
  return Response.ok().build();
}
项目:datacollector    文件:AdminResource.java   
@POST
@Path("/restart")
@ApiOperation(value = "Restart SDC", authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({AuthzRole.ADMIN, AuthzRole.ADMIN_REMOTE})
public Response restart() throws PipelineStoreException {
  Thread thread = new Thread("Shutdown Request") {
    @Override
    public void run() {
      // sleeping  500ms to allow the HTTP response to go back
      ThreadUtil.sleep(500);
      runtimeInfo.shutdown(88);
    }
  };
  thread.setDaemon(true);
  thread.start();
  return Response.ok().build();
}
项目:datacollector    文件:AdminResource.java   
@GET
@Path("/threads")
@ApiOperation(value = "Returns Thread Dump along with stack trace", response = Map.class, responseContainer = "List",
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({AuthzRole.ADMIN, AuthzRole.ADMIN_REMOTE})
public Response getThreadsDump() throws IOException {
  ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
  ThreadInfo[] threads = threadMXBean.dumpAllThreads(true, true);
  List<Map> augmented = new ArrayList<>(threads.length);
  for (ThreadInfo thread : threads) {
    Map<String, Object> map = new LinkedHashMap<>();
    map.put("threadInfo", thread);
    map.put("userTimeNanosecs", threadMXBean.getThreadUserTime(thread.getThreadId()));
    map.put("cpuTimeNanosecs", threadMXBean.getThreadCpuTime(thread.getThreadId()));
    augmented.add(map);
  }
  return Response.ok(augmented).build();
}
项目:datacollector    文件:AdminResource.java   
@GET
@Path("/users")
@ApiOperation(
    value = "Returns All Users Info",
    response = UserJson.class,
    responseContainer = "List",
    authorizations = @Authorization(value = "basic")
)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.ADMIN,
    AuthzRole.ADMIN_REMOTE,
    AuthzRole.CREATOR,
    AuthzRole.CREATOR_REMOTE
})
public Response getUsers() throws IOException {
  return Response.ok(userGroupManager.getUsers()).build();
}
项目:datacollector    文件:AdminResource.java   
@GET
@Path("/groups")
@ApiOperation(
    value = "Returns All Group names",
    response = UserJson.class,
    responseContainer = "List",
    authorizations = @Authorization(value = "basic")
)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.ADMIN,
    AuthzRole.ADMIN_REMOTE,
    AuthzRole.CREATOR,
    AuthzRole.CREATOR_REMOTE
})
public Response getGroups() throws IOException {
  return Response.ok(userGroupManager.getGroups()).build();
}
项目:datacollector    文件:AdminResource.java   
@GET
@Path("/bundle/list")
@ApiOperation(
    value = "Return list of available content generators for support bundles.",
    response = SupportBundleContentDefinitionJson.class,
    responseContainer = "List",
    authorizations = @Authorization(value = "basic")
)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.ADMIN,
    AuthzRole.ADMIN_REMOTE
})
public Response getSupportBundlesContentGenerators() throws IOException {
  return Response.ok(BeanHelper.wrapSupportBundleDefinitions(supportBundleManager.getContentDefinitions())).build();
}
项目:datacollector    文件:AdminResource.java   
@GET
@Path("/bundle/generate")
@ApiOperation(
    value = "Generates a new support bundle.",
    response = Object.class,
    authorizations = @Authorization(value = "basic")
)
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/octet-stream")
@RolesAllowed({
    AuthzRole.ADMIN,
    AuthzRole.ADMIN_REMOTE
})
public Response createSupportBundlesContentGenerators(
  @QueryParam("generators") @DefaultValue("") String generators
) throws IOException {
  SupportBundle bundle = supportBundleManager.generateNewBundle(getGeneratorList(generators));

  return Response
    .ok()
    .header("content-disposition", "attachment; filename=\"" + bundle.getBundleName() + "\"")
    .entity(bundle.getInputStream())
    .build();
}
项目:datacollector    文件:AdminResource.java   
@GET
@Path("/bundle/upload")
@ApiOperation(
    value = "Generates new support bundle and uploads it to StreamSets.",
    response = Object.class,
    authorizations = @Authorization(value = "basic")
)
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.ADMIN,
    AuthzRole.ADMIN_REMOTE
})
public Response uploadSupportBundlesContentGenerators(
  @QueryParam("generators") @DefaultValue("") String generators
) throws IOException {
  // The call with throw IOException on any error that will be propagated to the client
  supportBundleManager.uploadNewBundle(getGeneratorList(generators));

  return Response
    .ok()
    .build();
}
项目:datacollector    文件:StageLibraryResource.java   
@GET
@Path("/definitions/stages/{library}/{stageName}/icon")
@ApiOperation(value = "Return stage icon for library and stage name", response = Object.class,
    authorizations = @Authorization(value = "basic"))
@Produces({SVG_MEDIA_TYPE, PNG_MEDIA_TYPE})
@PermitAll
public Response getIcon(@PathParam("library") String library, @PathParam("stageName") String name) {
  StageDefinition stage = Utils.checkNotNull(stageLibrary.getStage(library, name, false),
      Utils.formatL("Could not find stage library: {}, name: {}", library, name));
  String iconFile = DEFAULT_ICON_FILE;
  String responseType = SVG_MEDIA_TYPE;

  if(stage.getIcon() != null && !stage.getIcon().isEmpty()) {
    iconFile = stage.getIcon();
  }

  final InputStream resourceAsStream = stage.getStageClassLoader().getResourceAsStream(iconFile);

  if(iconFile.endsWith(".svg"))
    responseType = SVG_MEDIA_TYPE;
  else if(iconFile.endsWith(".png"))
    responseType = PNG_MEDIA_TYPE;

  return Response.ok().type(responseType).entity(resourceAsStream).build();
}
项目:datacollector    文件:StageLibraryResource.java   
@POST
@Path("/stageLibraries/uninstall")
@ApiOperation(value = "Uninstall Stage libraries", response = Object.class,
    authorizations = @Authorization(value = "basic"))
@RolesAllowed({AuthzRole.ADMIN, AuthzRole.ADMIN_REMOTE})
public Response uninstallLibraries(
    List<String> libraryList
) throws IOException {
  String runtimeDir = runtimeInfo.getRuntimeDir();
  for (String libraryId : libraryList) {
    if (!libraryId.matches("[a-zA-Z0-9_-]+")) {
      throw new RuntimeException(Utils.format(ContainerError.CONTAINER_01301.getMessage(), libraryId));
    }

    File libraryDirectory = new File(runtimeDir + STREAMSETS_LIBS_PATH + libraryId);
    if (libraryDirectory.exists()) {
      FileUtils.deleteDirectory(libraryDirectory);
    }
  }
  return Response.ok().build();
}
项目:datacollector    文件:StageLibraryResource.java   
@POST
@Path("/stageLibraries/extras/delete")
@ApiOperation(value = "Delete additional drivers", response = Object.class,
    authorizations = @Authorization(value = "basic"))
@RolesAllowed({AuthzRole.ADMIN, AuthzRole.ADMIN_REMOTE})
public Response deleteExtras(
    List<StageLibraryExtrasJson> extrasList
) throws IOException {
  String libsExtraDir = runtimeInfo.getLibsExtraDir();
  if (StringUtils.isEmpty(libsExtraDir)) {
    throw new RuntimeException(ContainerError.CONTAINER_01300.getMessage());
  }
  for (StageLibraryExtrasJson extrasJson : extrasList) {
    File additionalLibraryFile = new File(libsExtraDir + "/"    +
        extrasJson.getLibraryId() + "/" + STAGE_LIB_JARS_DIR, extrasJson.getFileName());
    if (additionalLibraryFile.exists()) {
      FileUtils.forceDelete(additionalLibraryFile);
    }
  }
  return Response.ok().build();
}
项目:datacollector    文件:PreviewResource.java   
@Path("/pipeline/{pipelineId}/preview/{previewerId}/status")
@GET
@ApiOperation(value = "Return Preview status by previewer ID", response = PreviewInfoJson.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.CREATOR, AuthzRole.ADMIN, AuthzRole.CREATOR_REMOTE, AuthzRole.ADMIN_REMOTE
})
public Response getPreviewStatus(
    @PathParam("pipelineId") String pipelineId,
    @PathParam("previewerId") String previewerId
) throws PipelineException, StageException {
  Previewer previewer = manager.getPreviewer(previewerId);
  if(previewer == null) {
    return Response.status(Response.Status.NOT_FOUND).entity("Cannot find previewer with id " + previewerId).build();
  }
  PipelineInfo pipelineInfo = store.getInfo(previewer.getName());
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  PreviewInfoJson previewInfoJson = new PreviewInfoJson(previewer.getId(), previewer.getStatus());
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(previewInfoJson).build();
}
项目:datacollector    文件:PreviewResource.java   
@Path("/pipeline/{pipelineId}/preview/{previewerId}")
@GET
@ApiOperation(value = "Return Preview Data by previewer ID", response = PreviewOutputJson.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.CREATOR, AuthzRole.ADMIN, AuthzRole.CREATOR_REMOTE, AuthzRole.ADMIN_REMOTE
})
public Response getPreviewData(
    @PathParam("pipelineId") String pipelineId,
    @PathParam("previewerId") String previewerId
) throws PipelineException, StageException {
  Previewer previewer = manager.getPreviewer(previewerId);
  if(previewer == null) {
    return Response.status(Response.Status.NOT_FOUND).entity("Cannot find previewer with id " + previewerId).build();
  }
  PipelineInfo pipelineInfo = store.getInfo(previewer.getName());
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  PreviewOutput previewOutput = previewer.getOutput();
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(BeanHelper.wrapPreviewOutput(previewOutput)).build();
}
项目:datacollector    文件:PreviewResource.java   
@Path("/pipeline/{pipelineId}/preview/{previewerId}")
@DELETE
@ApiOperation(value = "Stop Preview by previewer ID", response = PreviewInfoJson.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.CREATOR, AuthzRole.ADMIN, AuthzRole.CREATOR_REMOTE, AuthzRole.ADMIN_REMOTE
})
public Response stopPreview(
    @PathParam("pipelineId") String pipelineId,
    @PathParam("previewerId") String previewerId
) throws PipelineException, StageException {
  Previewer previewer = manager.getPreviewer(previewerId);
  if(previewer == null) {
    return Response.status(Response.Status.NOT_FOUND).entity("Cannot find previewer with id " + previewerId).build();
  }
  PipelineInfo pipelineInfo = store.getInfo(previewer.getName());
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  previewer.stop();
  PreviewInfoJson previewInfoJson = new PreviewInfoJson(previewer.getId(), previewer.getStatus());
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(previewInfoJson).build();
}
项目:datacollector    文件:PreviewResource.java   
@Path("/pipeline/{pipelineId}/rawSourcePreview")
@GET
@ApiOperation(value = "Get raw source preview data for pipeline name and revision", response = RawPreview.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.CREATOR, AuthzRole.ADMIN, AuthzRole.CREATOR_REMOTE, AuthzRole.ADMIN_REMOTE
})
public Response rawSourcePreview(
    @PathParam("pipelineId") String pipelineId,
    @QueryParam("rev") String rev,
    @Context UriInfo uriInfo
) throws PipelineException, IOException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  MultivaluedMap<String, String> previewParams = uriInfo.getQueryParameters();
  Previewer previewer = manager.createPreviewer(this.user, pipelineId, rev);
  RawPreview rawPreview = previewer.getRawSource(4 * 1024, previewParams);
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(rawPreview).build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/status")
@GET
@ApiOperation(value = "Returns Pipeline Status for the given pipeline", response = PipelineStateJson.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
public Response getPipelineStatus(
  @PathParam("pipelineId") String pipelineId,
  @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  if(pipelineId != null) {
    return Response.ok()
        .type(MediaType.APPLICATION_JSON)
        .entity(BeanHelper.wrapPipelineState(manager.getPipelineState(pipelineId, rev))).build();
  }
  return Response.noContent().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/committedOffsets")
@GET
@ApiOperation(value = "Return Committed Offsets. Note: Returned offset format will change between releases.",
    response = SourceOffsetJson.class,
    authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response getCommittedOffsets(
    @PathParam("pipelineId") String pipelineId,
    @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(pipelineId, rev);
  return Response.ok()
      .type(MediaType.APPLICATION_JSON)
      .entity(BeanHelper.wrapSourceOffset(runner.getCommittedOffsets()))
      .build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/committedOffsets")
@POST
@ApiOperation(value = "Update Pipeline Committed Offsets.",
    authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response updateCommittedOffsets(
    @PathParam("pipelineId") String pipelineId,
    @QueryParam("rev") @DefaultValue("0") String rev,
    SourceOffsetJson sourceOffset
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(pipelineId, rev);
  runner.updateCommittedOffsets(BeanHelper.unwrapSourceOffset(sourceOffset));
  return Response.ok().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/resetOffset")
@POST
@ApiOperation(value = "Reset Origin Offset", authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response resetOffset(
    @PathParam("pipelineId") String name,
    @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(name);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  if (manager.isRemotePipeline(name, rev)) {
    throw new PipelineException(ContainerError.CONTAINER_01101, "RESET_OFFSET", name);
  }
  Runner runner = manager.getRunner(name, rev);
  runner.resetOffset("user");
  return Response.ok().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipelines/resetOffsets")
@POST
@ApiOperation(value = "Reset Origin Offset for multiple pipelines", authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response resetOffsets(List<String> pipelineIds) throws PipelineException {
  for (String pipelineId: pipelineIds) {
    PipelineInfo pipelineInfo = store.getInfo(pipelineId);
    RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
    if (manager.isRemotePipeline(pipelineId, "0")) {
      throw new PipelineException(ContainerError.CONTAINER_01101, "RESET_OFFSETS", pipelineId);
    }
    Runner runner = manager.getRunner(pipelineId, "0");
    runner.resetOffset(user);
  }
  return Response.ok().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/snapshot/{snapshotName}")
@PUT
@ApiOperation(value = "Capture Snapshot", authorizations = @Authorization(value = "basic"))
@RolesAllowed({ AuthzRole.MANAGER, AuthzRole.ADMIN, AuthzRole.MANAGER_REMOTE, AuthzRole.ADMIN_REMOTE })
public Response captureSnapshot(
    @PathParam("pipelineId") String pipelineId,
    @PathParam("snapshotName") String snapshotName,
    @QueryParam("snapshotLabel") String snapshotLabel,
    @QueryParam("rev") @DefaultValue("0") String rev,
    @QueryParam("batches") @DefaultValue("1") int batches,
    @QueryParam("batchSize") @DefaultValue("10") int batchSize,
    @QueryParam("startPipeline") @DefaultValue("false") boolean startPipeline,
    Map<String, Object> runtimeParameters
) throws PipelineException, StageException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(pipelineId, rev);
  if (startPipeline && runner != null) {
    runner.startAndCaptureSnapshot(user, runtimeParameters, snapshotName, snapshotLabel, batches, batchSize);
  } else {
    Utils.checkState(runner != null && runner.getState().getStatus() == PipelineStatus.RUNNING,
        "Pipeline doesn't exist or it is not running currently");
    runner.captureSnapshot(user, snapshotName, snapshotLabel, batches, batchSize);
  }
  return Response.ok().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/snapshot/{snapshotName}")
@POST
@ApiOperation(value = "Update Snapshot Label", authorizations = @Authorization(value = "basic"))
@RolesAllowed({ AuthzRole.MANAGER, AuthzRole.ADMIN, AuthzRole.MANAGER_REMOTE, AuthzRole.ADMIN_REMOTE })
public Response updateSnapshotLabel(
    @PathParam("pipelineId") String pipelineId,
    @PathParam("snapshotName") String snapshotName,
    @QueryParam("snapshotLabel") String snapshotLabel,
    @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(pipelineId, rev);
  runner.updateSnapshotLabel(snapshotName, snapshotLabel);
  return Response.ok().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipelines/snapshots")
@GET
@ApiOperation(value = "Returns all Snapshot Info", response = SnapshotInfoJson.class, responseContainer = "List",
  authorizations = @Authorization(value = "basic"))
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.CREATOR,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.CREATOR_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response getAllSnapshotsInfo() throws PipelineException {
  RestAPIUtils.injectPipelineInMDC("*");
  List<SnapshotInfo> snapshotInfoList = new ArrayList<>();
  for(PipelineState pipelineState: manager.getPipelines()) {
    if (!pipelineState.getExecutionMode().equals(ExecutionMode.EDGE)) {
      Runner runner = manager.getRunner(pipelineState.getPipelineId(), pipelineState.getRev());
      if(runner != null) {
        snapshotInfoList.addAll(runner.getSnapshotsInfo());
      }
    }
  }
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(BeanHelper.wrapSnapshotInfoNewAPI(
    snapshotInfoList)).build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/snapshots")
@GET
@ApiOperation(value = "Returns Snapshot Info for the given pipeline", response = SnapshotInfoJson.class,
  responseContainer = "List", authorizations = @Authorization(value = "basic"))
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.CREATOR,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.CREATOR_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response getSnapshotsInfo(
    @PathParam("pipelineId") String pipelineId,
    @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(pipelineId, rev);
  if(runner != null) {
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(BeanHelper.wrapSnapshotInfoNewAPI(
      runner.getSnapshotsInfo())).build();
  }
  return Response.noContent().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/snapshot/{snapshotName}/status")
@GET
@ApiOperation(value = "Return Snapshot status", response = SnapshotInfoJson.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response getSnapshotStatus(
  @PathParam("pipelineId") String pipelineId,
  @PathParam("snapshotName") String snapshotName,
  @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(pipelineId, rev);
  if(runner != null) {
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(
      BeanHelper.wrapSnapshotInfoNewAPI(runner.getSnapshot(snapshotName).getInfo())).build();
  }
  return Response.noContent().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/snapshot/{snapshotName}")
@DELETE
@ApiOperation(value = "Delete Snapshot data", authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response deleteSnapshot(
    @PathParam("pipelineId") String pipelineId,
    @PathParam("snapshotName") String snapshotName,
    @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(pipelineId, rev);
  if(runner != null) {
    runner.deleteSnapshot(snapshotName);
  }
  return Response.ok().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/history")
@DELETE
@ApiOperation(value = "Delete history by pipeline name", authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response deleteHistory(
  @PathParam("pipelineId") String pipelineId,
  @QueryParam("rev") @DefaultValue("0") String rev
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  if (manager.isRemotePipeline(pipelineId, rev)) {
    throw new PipelineException(ContainerError.CONTAINER_01101, "DELETE_HISTORY", pipelineId);
  }
  Runner runner = manager.getRunner(pipelineId, rev);
  if(runner != null) {
    runner.deleteHistory();
  }
  return Response.ok().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/history")
@GET
@ApiOperation(value = "Find history by pipeline name", response = PipelineStateJson.class, responseContainer = "List",
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
public Response getHistory(
  @PathParam("pipelineId") String name,
  @QueryParam("rev") @DefaultValue("0") String rev,
  @QueryParam("fromBeginning") @DefaultValue("false") boolean fromBeginning) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(name);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  Runner runner = manager.getRunner(name, rev);
  if(runner != null) {
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(
      BeanHelper.wrapPipelineStatesNewAPI(runner.getHistory(), false)).build();
  }
  return Response.noContent().build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipelines/alerts")
@GET
@ApiOperation(value = "Returns alerts triggered for all pipelines", response = AlertInfoJson.class,
  responseContainer = "List", authorizations = @Authorization(value = "basic"))
@PermitAll
public Response getAllAlerts()
  throws PipelineException {
  RestAPIUtils.injectPipelineInMDC("*");
  List<AlertInfo> alertInfoList = new ArrayList<>();
  if (store.getPipelines().size() < 100) {
    // get alerts for all pipelines only if number of pipelines is less than 100
    for(PipelineState pipelineState: manager.getPipelines()) {
      if (pipelineState.getExecutionMode() != ExecutionMode.EDGE) {
        Runner runner = manager.getRunner(pipelineState.getPipelineId(), pipelineState.getRev());
        if(runner != null && runner.getState().getStatus().isActive()) {
          alertInfoList.addAll(runner.getAlerts());
        }
      }
    }
  }
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(BeanHelper.wrapAlertInfoList(
    alertInfoList)).build();
}
项目:datacollector    文件:ManagerResource.java   
@Path("/pipeline/{pipelineId}/alerts")
@DELETE
@ApiOperation(value = "Delete alert by Pipeline name, revision and Alert ID", response = Boolean.class,
  authorizations = @Authorization(value = "basic"))
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed({
    AuthzRole.MANAGER,
    AuthzRole.ADMIN,
    AuthzRole.MANAGER_REMOTE,
    AuthzRole.ADMIN_REMOTE
})
public Response deleteAlert(
  @PathParam("pipelineId") String pipelineId,
  @QueryParam("rev") @DefaultValue("0") String rev,
  @QueryParam("alertId") String alertId
) throws PipelineException {
  PipelineInfo pipelineInfo = store.getInfo(pipelineId);
  RestAPIUtils.injectPipelineInMDC(pipelineInfo.getTitle(), pipelineInfo.getPipelineId());
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(
    manager.getRunner(pipelineId, rev).deleteAlert(alertId)).build();
}