public AssignmentScope persist(DeviceCommandInvocationCreateRequest.Builder builder) throws SiteWhereException { DeviceCommandInvocationCreateRequest request = builder.build(); IDeviceCommand command = deviceManagement.getDeviceCommandByToken(request.getCommandToken()); events.addDeviceCommandInvocation(getAssignmentToken(), command, request); return this; }
@RequestMapping(value = "/{token}/invocations/schedules/{scheduleToken}", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "Schedule command invocation") @Secured({ SiteWhereRoles.REST }) @Documented(examples = { @Example(stage = Stage.Request, json = Assignments.CreateCommandInvocationRequest.class, description = "scheduleCommandInvocationRequest.md"), @Example(stage = Stage.Response, json = Schedules.CreateScheduledJobResponse.class, description = "scheduleCommandInvocationResponse.md") }) public IScheduledJob scheduleCommandInvocation(@RequestBody DeviceCommandInvocationCreateRequest request, @ApiParam(value = "Assignment token", required = true) @PathVariable String token, @ApiParam(value = "Schedule token", required = true) @PathVariable String scheduleToken, HttpServletRequest servletRequest) throws SiteWhereException { Tracer.start(TracerCategory.RestApiCall, "scheduleCommandInvocation", LOGGER); try { assureDeviceCommand(request.getCommandToken(), servletRequest); IScheduledJobCreateRequest job = ScheduledJobHelper.createCommandInvocationJob(UUID.randomUUID().toString(), token, request.getCommandToken(), request.getParameterValues(), scheduleToken); return SiteWhere.getServer().getScheduleManagement(getTenant(servletRequest)).createScheduledJob(job); } finally { Tracer.stop(LOGGER); } }
/** * Create command invocation to be associated with a device assignment. * * @param input * @param token * @return * @throws SiteWhereException */ @RequestMapping(value = "/{token}/invocations", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "Create command invocation event for assignment") @Secured({ SiteWhereRoles.REST }) @Documented(examples = { @Example(stage = Stage.Request, json = Assignments.CreateCommandInvocationRequest.class, description = "createCommandInvocationRequest.md"), @Example(stage = Stage.Response, json = Assignments.CreateCommandInvocationResponse.class, description = "createCommandInvocationResponse.md") }) public DeviceCommandInvocation createCommandInvocation(@RequestBody DeviceCommandInvocationCreateRequest request, @ApiParam(value = "Assignment token", required = true) @PathVariable String token, HttpServletRequest servletRequest) throws SiteWhereException { Tracer.start(TracerCategory.RestApiCall, "createCommandInvocation", LOGGER); try { IDeviceCommand command = assureDeviceCommand(request.getCommandToken(), servletRequest); IDeviceCommandInvocation result = SiteWhere.getServer().getDeviceEventManagement(getTenant(servletRequest)) .addDeviceCommandInvocation(token, command, request); DeviceCommandInvocationMarshalHelper helper = new DeviceCommandInvocationMarshalHelper( getTenant(servletRequest)); return helper.convert(result); } finally { Tracer.stop(LOGGER); } }