@Override public void addSchedule(ScheduleId scheduleId, ScheduleDetail scheduleDetail) throws Exception { appFabricClient.addSchedule(scheduleId.getParent(), scheduleDetail); }
@Override public void addSchedule(ScheduleId scheduleId, ScheduleDetail scheduleDetail) throws Exception { appFabricClient.addSchedule(scheduleId.getParent(), scheduleDetail); }
public static Schedule fromEntityId(ScheduleId scheduleId) { return from(Id.Application.fromEntityId(scheduleId.getParent()), scheduleId.getSchedule()); } }
/** * Delete the given schedule * * @param scheduleId the schedule to delete * @throws NotFoundException if the schedule could not be found * @throws UnauthorizedException if the principal is not authorized to delete the schedule * @throws Exception if any other errors occurred while performing the authorization enforcement check */ public void delete(ScheduleId scheduleId) throws Exception { authorizationEnforcer.enforce(scheduleId.getParent(), authenticationContext.getPrincipal(), Action.ADMIN); scheduler.deleteSchedule(scheduleId); } }
public static Schedule fromEntityId(ScheduleId scheduleId) { return from(Id.Application.fromEntityId(scheduleId.getParent()), scheduleId.getSchedule()); } }
/** * Delete the given schedule * * @param scheduleId the schedule to delete * @throws NotFoundException if the schedule could not be found * @throws UnauthorizedException if the principal is not authorized to delete the schedule * @throws Exception if any other errors occurred while performing the authorization enforcement check */ public void delete(ScheduleId scheduleId) throws Exception { authorizationEnforcer.enforce(scheduleId.getParent(), authenticationContext.getPrincipal(), Action.ADMIN); scheduler.deleteSchedule(scheduleId); } }
/** * Enable a schedule in an application. * * @param scheduleId the id of the schedule to be enabled */ public void enableSchedule(ScheduleId scheduleId) throws ApplicationNotFoundException, IOException, UnauthenticatedException, UnauthorizedException, BadRequestException { String path = String.format("apps/%s/versions/%s/program-type/schedules/program-id/%s/action/enable", scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule()); HttpResponse response = restClient.execute(HttpMethod.PUT, config.resolveNamespacedURLV3(scheduleId.getParent().getParent(), path), config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND, HttpURLConnection.HTTP_BAD_REQUEST); int responseCode = response.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) { throw new ApplicationNotFoundException(scheduleId.getParent()); } else if (responseCode == HttpURLConnection.HTTP_BAD_REQUEST) { throw new BadRequestException(String.format("Bad Request. Reason: %s", response.getResponseBodyAsString())); } } }
public String getStatus(ScheduleId scheduleId) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException { String path = String.format("apps/%s/versions/%s/schedules/%s/status", scheduleId.getApplication(), scheduleId.getVersion(), scheduleId.getSchedule()); URL url = config.resolveNamespacedURLV3(scheduleId.getParent().getParent(), path); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(scheduleId); } Map<String, String> responseObject = ObjectResponse.<Map<String, String>>fromJsonBody(response, MAP_STRING_STRING_TYPE, GSON).getResponseObject(); return responseObject.get("status"); }
authorizationEnforcer.enforce(scheduleId.getParent(), authenticationContext.getPrincipal(), Action.ADMIN); ProgramSchedule existing = scheduler.getSchedule(scheduleId);
authorizationEnforcer.enforce(scheduleId.getParent(), authenticationContext.getPrincipal(), Action.ADMIN); ProgramSchedule existing = scheduler.getSchedule(scheduleId);
public void updateSchedule(ScheduleId scheduleId, ScheduleDetail scheduleDetail) throws Exception { MockResponder responder = new MockResponder(); ApplicationId application = scheduleId.getParent(); String uri = String.format("%s/apps/%s/versions/%s/schedules/%s/update", getNamespacePath(application.getNamespace()), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri); request.content().writeCharSequence(GSON.toJson(scheduleDetail), StandardCharsets.UTF_8); HttpUtil.setContentLength(request, request.content().readableBytes()); programLifecycleHttpHandler.updateSchedule(request, responder, application.getNamespace(), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Update schedule failed"); }
public void deleteSchedule(ScheduleId scheduleId) throws Exception { MockResponder responder = new MockResponder(); ApplicationId application = scheduleId.getParent(); String uri = String.format("%s/apps/%s/versions/%s/schedules/%s", getNamespacePath(application.getNamespace()), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, uri); programLifecycleHttpHandler.deleteSchedule(request, responder, application.getNamespace(), application.getApplication(), application.getVersion(), scheduleId.getSchedule()); verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Delete schedule failed"); } }