@Test public void testGetAuthorizedExperimentOrThrow() { try { experimentsResource.getAuthorizedExperimentOrThrow(experiment.getID(), USER); Assert.fail("Should throw ExperimentNotFoundException if experiment does not exist."); } catch (ExperimentNotFoundException ignored) { } doReturn(experiment).when(experiments).getExperiment(experiment.getID()); Experiment actualExperiment = experimentsResource.getAuthorizedExperimentOrThrow(experiment.getID(), USER); Assert.assertEquals("Wrong experiment returned.", experiment, actualExperiment); doThrow(AuthenticationException.class).when(authorization).checkUserPermissions(USER, experiment.getApplicationName(), Permission.READ); try { experimentsResource.getAuthorizedExperimentOrThrow(experiment.getID(), USER); Assert.fail("Should throw AuthenticationException if user has no permission."); } catch (AuthenticationException ignored) { } }
Experiment getAuthorizedExperimentOrThrow(Experiment.ID experimentID, Username username) { Experiment experiment; if ((experiment = experiments.getExperiment(experimentID)) == null) { throw new ExperimentNotFoundException(experimentID); } authorization.checkUserPermissions(username, experiment.getApplicationName(), READ); experiment = Experiment.from(experiment).build(); return experiment; }
ExperimentsResource { Experiment getAuthorizedExperimentOrThrow(Experiment.ID experimentID, Username username) { Experiment experiment; if ((experiment = experiments.getExperiment(experimentID)) == null) { throw new ExperimentNotFoundException(experimentID); } authorization.checkUserPermissions(username, experiment.getApplicationName(), READ); experiment = Experiment.from(experiment).build(); return experiment; } }
ExperimentsResource { Experiment getAuthorizedExperimentOrThrow(Experiment.ID experimentID, Username username) { Experiment experiment; if ((experiment = experiments.getExperiment(experimentID)) == null) { throw new ExperimentNotFoundException(experimentID); } authorization.checkUserPermissions(username, experiment.getApplicationName(), READ); experiment = Experiment.from(experiment).build(); return experiment; } @Inject  ExperimentsResource(final Experiments experiments, final EventsExport export, final Assignments assignments,
                        final Authorization authorization, final Buckets buckets, final Mutex mutex,
                        final Pages pages, final Priorities priorities, final Favorites favorites,
                        final @Named(DEFAULT_TIME_ZONE) String defaultTimezone,
                        final @Named(DEFAULT_TIME_FORMAT) String defaultTimeFormat,
                        final HttpHeader httpHeader, final PaginationHelper<Experiment> experimentPaginationHelper
    ); }
ExperimentsResource { Experiment getAuthorizedExperimentOrThrow(Experiment.ID experimentID, Username username) { Experiment experiment; if ((experiment = experiments.getExperiment(experimentID)) == null) { throw new ExperimentNotFoundException(experimentID); } authorization.checkUserPermissions(username, experiment.getApplicationName(), READ); experiment = Experiment.from(experiment).build(); return experiment; } @Inject  ExperimentsResource(final Experiments experiments, final EventsExport export, final Assignments assignments,
                        final Authorization authorization, final Buckets buckets, final Mutex mutex,
                        final Pages pages, final Priorities priorities, final Favorites favorites,
                        final @Named(DEFAULT_TIME_ZONE) String defaultTimezone,
                        final @Named(DEFAULT_TIME_FORMAT) String defaultTimeFormat,
                        final HttpHeader httpHeader, final PaginationHelper<Experiment> experimentPaginationHelper
    ); @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Return details of all the experiments, with respect to the authorization", response = ExperimentList.class) @Timed Response getExperiments(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader,

            @QueryParam("page")
            @DefaultValue(DEFAULT_PAGE)
            @ApiParam(name = "page", defaultValue = DEFAULT_PAGE, value = DOC_PAGE)
            final int page,

            @QueryParam("per_page")
            @DefaultValue(DEFAULT_PER_PAGE)
            @ApiParam(name = "per_page", defaultValue = DEFAULT_PER_PAGE, value = DOC_PER_PAGE)
            final int perPage,

            @QueryParam("filter")
            @DefaultValue("")
            @ApiParam(name = "filter", defaultValue = DEFAULT_FILTER, value = DOC_FILTER)
            final String filter,

            @QueryParam("sort")
            @DefaultValue("")
            @ApiParam(name = "sort", defaultValue = DEFAULT_SORT, value = DOC_SORT)
            final String sort,

            @QueryParam("timezone")
            @DefaultValue(DEFAULT_TIMEZONE)
            @ApiParam(name = "timezone", defaultValue = DEFAULT_TIMEZONE, value = DOC_TIMEZONE)
            final String timezoneOffset,

            @QueryParam("all")
            @DefaultValue("false")
            @ApiParam(name = "all", defaultValue = DEFAULT_ALL, value = DOC_All)
            final Boolean all); @POST @Consumes(APPLICATION_JSON) @ApiOperation(value = "Create an experiment", response = Experiment.class) @Timed Response postExperiment(
            @ApiParam(required = true)
            final NewExperiment newExperiment,

            @QueryParam("createNewApplication")
            @DefaultValue("false")
            final boolean createNewApplication,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return details of a single experiment", response = Experiment.class) @Timed Response getExperiment(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update an experiment", notes = "Can update an experiment that is in DRAFT state to change the experiment state, or " + "to change sampling percentage or to enable personalization and more.", response = Experiment.class) @Timed Response putExperiment(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @ApiParam(value = "Please read the implementation notes above", required = true)
            final Experiment experimentEntity,

            @QueryParam("createNewApplication")
            @DefaultValue("false")
            final boolean createNewApplication,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("{experimentID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Delete an experiment", notes = "Can only delete an experiment that is in DRAFT or TERMINATED state. The default call is " + "safe to use, but other than that please only delete experiments which you have created.") @Timed Response deleteExperiment(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/buckets") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return all buckets for an experiment", response = BucketList.class) @Timed Response getBuckets(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/buckets") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Modify a bucket for an experiment", notes = "Can only modify buckets for an experiment that is in DRAFT state.", response = Bucket.class) @Timed Response postBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @ApiParam(required = true, defaultValue = DEFAULT_MODBUCK)
            final Bucket newBucketEntity,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}/buckets") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Modify buckets for an experiment", notes = "Can only modify buckets for an experiment that is in DRAFT state.", response = Bucket.class) @Timed Response putBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @ApiParam(required = true, defaultValue = DEFAULT_MODBUCK)
            final BucketList bucketList,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/buckets/{bucketLabel}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return a single bucket for an experiment", response = Bucket.class) @Timed Response getBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}/buckets/{bucketLabel}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a bucket in an experiment", notes = "Can only update buckets for an experiment that is in DRAFT state.", response = Bucket.class) @Timed Response putBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @ApiParam(required = true, defaultValue = DEFAULT_PUTBUCK)
            final Bucket bucketEntity,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}/buckets/{bucketLabel}/state/{desiredState}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a bucket state", notes = "Can only close a bucket which is not in DRAFT state", response = Bucket.class) @Timed Response putBucketState(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @PathParam("desiredState")
            @ApiParam(value = "Desired Bucket State")
            final Bucket.State desiredState,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("{experimentID}/buckets/{bucketLabel}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Delete a bucket in an experiment", notes = "Can only delete a bucket for experiment that is in DRAFT state. The default call is " + "safe to use, but other than that please only delete buckets which you have created.") @Timed Response deleteBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/events") @Produces(TEXT_PLAIN) @ApiOperation(value = "Export all event records for an experiment", notes = "A wrapper for POST API with default parameters", response = StreamingOutput.class) @Timed Response exportActions_get(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/events") @Produces(TEXT_PLAIN) @ApiOperation(value = "Export all event records for an experiment", notes = "Download all event records for a given experiment in a tab-delimited text format.", response = StreamingOutput.class) @Timed Response exportActions(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            final Parameters parameters,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/exclusions") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Create mutual exclusion rules for an experiment", notes = "Can only create mutual exclusion rules for experiments in DRAFT, " + "RUNNING, and PAUSED states within+" + "the same application") // response = ??, //todo: update with proper object in @ApiOperation @Timed Response createExclusions(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            final ExperimentIDList experimentIDList,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("/exclusions/experiment1/{experimentID_1}/experiment2/{experimentID_2}") @ApiOperation(value = "Delete a mutual exclusion relation", notes = "Can only delete mutual exclusion relations that currently " + "exists. This operation is symmetric") // response = ??, //todo: update with proper object in @ApiOperation @Timed Response removeExclusions(
            @PathParam("experimentID_1")
            @ApiParam(value = "Experiment ID 1")
            final Experiment.ID experimentID_1,

            @PathParam("experimentID_2")
            @ApiParam(value = "Experiment ID 2")
            final Experiment.ID experimentID_2,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/exclusions") @Produces(APPLICATION_JSON) @ApiOperation(value = "Get list of mutually exclusive experiments", notes = "Shows list of all experiments, in all states, that are " + "mutually exclusive with input experiment.") // response = ??, //todo: update with proper object in @ApiOperation @Timed Response getExclusions(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @QueryParam("showAll")
            @DefaultValue("true")
            final Boolean showAll,

            @QueryParam("exclusive")
            @DefaultValue("true")
            final Boolean exclusive,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/priority/{priorityPosition}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Insert an experiment into an application's priority list", notes = "Experiments can only be placed in a priority list DRAFT, RUNNING, and PAUSED states within" + "the same application") @Timed Response setPriority(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("priorityPosition")
            final int priorityNum,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/assignments") @Produces(TEXT_PLAIN) @ApiOperation(value = "Download a list of user assignments for a given experiment ID", notes = "Shows list of all user assignments for a given experiment ID. Returns both null" + "assignments as well as bucket assignments.", response = StreamingOutput.class) @Timed Response exportAssignments(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @QueryParam("ignoreNullBucket")
            @DefaultValue("false")
            @ApiParam(value = "Filtering on the null bucket")
            final String ignoreStringNullBucket,

            @QueryParam("fromDate")
            @ApiParam(value = "from date to download assignments")
            final String fromStringDate,

            @QueryParam("toDate")
            @ApiParam(value = "to date to download assignments")
            final String toStringDate,

            @QueryParam("timeZone")
            @ApiParam(value = "value of the time zone")
            final String timeZoneString,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/pages") @Consumes(APPLICATION_JSON) @ApiOperation(value = "Post a list of pages to an experiment", notes = "Pages can only be added to an experiment with DRAFT, RUNNING, or PAUSED states") @Timed Response postPages(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            final ExperimentPageList experimentPageList,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("{experimentID}/pages/{pageName}") @ApiOperation(value = "Remove a page from an experiment", notes = "Pages can only be added to an experiment with DRAFT, RUNNING, or PAUSED states") @Timed Response deletePage(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("pageName")
            @ApiParam(value = "Page name where the experiment will appear")
            final Page.Name pageName,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/pages") @ApiOperation(value = "Get the associated pages information for a given experiment ID") @Timed Response getExperimentPages(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("/applications/{applicationName}/pages/{pageName}") @ApiOperation(value = "Return all experiments for page for app", response = ExperimentList.class) @Timed Response getPageExperiments(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("pageName")
            @ApiParam(value = "Page name where the experiment will appear")
            final Page.Name pageName); }
ExperimentsResource { Experiment getAuthorizedExperimentOrThrow(Experiment.ID experimentID, Username username) { Experiment experiment; if ((experiment = experiments.getExperiment(experimentID)) == null) { throw new ExperimentNotFoundException(experimentID); } authorization.checkUserPermissions(username, experiment.getApplicationName(), READ); experiment = Experiment.from(experiment).build(); return experiment; } @Inject  ExperimentsResource(final Experiments experiments, final EventsExport export, final Assignments assignments,
                        final Authorization authorization, final Buckets buckets, final Mutex mutex,
                        final Pages pages, final Priorities priorities, final Favorites favorites,
                        final @Named(DEFAULT_TIME_ZONE) String defaultTimezone,
                        final @Named(DEFAULT_TIME_FORMAT) String defaultTimeFormat,
                        final HttpHeader httpHeader, final PaginationHelper<Experiment> experimentPaginationHelper
    ); @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Return details of all the experiments, with respect to the authorization", response = ExperimentList.class) @Timed Response getExperiments(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader,

            @QueryParam("page")
            @DefaultValue(DEFAULT_PAGE)
            @ApiParam(name = "page", defaultValue = DEFAULT_PAGE, value = DOC_PAGE)
            final int page,

            @QueryParam("per_page")
            @DefaultValue(DEFAULT_PER_PAGE)
            @ApiParam(name = "per_page", defaultValue = DEFAULT_PER_PAGE, value = DOC_PER_PAGE)
            final int perPage,

            @QueryParam("filter")
            @DefaultValue("")
            @ApiParam(name = "filter", defaultValue = DEFAULT_FILTER, value = DOC_FILTER)
            final String filter,

            @QueryParam("sort")
            @DefaultValue("")
            @ApiParam(name = "sort", defaultValue = DEFAULT_SORT, value = DOC_SORT)
            final String sort,

            @QueryParam("timezone")
            @DefaultValue(DEFAULT_TIMEZONE)
            @ApiParam(name = "timezone", defaultValue = DEFAULT_TIMEZONE, value = DOC_TIMEZONE)
            final String timezoneOffset,

            @QueryParam("all")
            @DefaultValue("false")
            @ApiParam(name = "all", defaultValue = DEFAULT_ALL, value = DOC_All)
            final Boolean all); @POST @Consumes(APPLICATION_JSON) @ApiOperation(value = "Create an experiment", response = Experiment.class) @Timed Response postExperiment(
            @ApiParam(required = true)
            final NewExperiment newExperiment,

            @QueryParam("createNewApplication")
            @DefaultValue("false")
            final boolean createNewApplication,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return details of a single experiment", response = Experiment.class) @Timed Response getExperiment(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update an experiment", notes = "Can update an experiment that is in DRAFT state to change the experiment state, or " + "to change sampling percentage or to enable personalization and more.", response = Experiment.class) @Timed Response putExperiment(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @ApiParam(value = "Please read the implementation notes above", required = true)
            final Experiment experimentEntity,

            @QueryParam("createNewApplication")
            @DefaultValue("false")
            final boolean createNewApplication,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("{experimentID}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Delete an experiment", notes = "Can only delete an experiment that is in DRAFT or TERMINATED state. The default call is " + "safe to use, but other than that please only delete experiments which you have created.") @Timed Response deleteExperiment(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/buckets") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return all buckets for an experiment", response = BucketList.class) @Timed Response getBuckets(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/buckets") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Modify a bucket for an experiment", notes = "Can only modify buckets for an experiment that is in DRAFT state.", response = Bucket.class) @Timed Response postBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @ApiParam(required = true, defaultValue = DEFAULT_MODBUCK)
            final Bucket newBucketEntity,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}/buckets") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Modify buckets for an experiment", notes = "Can only modify buckets for an experiment that is in DRAFT state.", response = Bucket.class) @Timed Response putBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @ApiParam(required = true, defaultValue = DEFAULT_MODBUCK)
            final BucketList bucketList,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/buckets/{bucketLabel}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Return a single bucket for an experiment", response = Bucket.class) @Timed Response getBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}/buckets/{bucketLabel}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a bucket in an experiment", notes = "Can only update buckets for an experiment that is in DRAFT state.", response = Bucket.class) @Timed Response putBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @ApiParam(required = true, defaultValue = DEFAULT_PUTBUCK)
            final Bucket bucketEntity,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @PUT @Path("{experimentID}/buckets/{bucketLabel}/state/{desiredState}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a bucket state", notes = "Can only close a bucket which is not in DRAFT state", response = Bucket.class) @Timed Response putBucketState(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @PathParam("desiredState")
            @ApiParam(value = "Desired Bucket State")
            final Bucket.State desiredState,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("{experimentID}/buckets/{bucketLabel}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Delete a bucket in an experiment", notes = "Can only delete a bucket for experiment that is in DRAFT state. The default call is " + "safe to use, but other than that please only delete buckets which you have created.") @Timed Response deleteBucket(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("bucketLabel")
            @ApiParam(value = "Bucket Label")
            final Bucket.Label bucketLabel,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/events") @Produces(TEXT_PLAIN) @ApiOperation(value = "Export all event records for an experiment", notes = "A wrapper for POST API with default parameters", response = StreamingOutput.class) @Timed Response exportActions_get(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/events") @Produces(TEXT_PLAIN) @ApiOperation(value = "Export all event records for an experiment", notes = "Download all event records for a given experiment in a tab-delimited text format.", response = StreamingOutput.class) @Timed Response exportActions(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            final Parameters parameters,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/exclusions") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Create mutual exclusion rules for an experiment", notes = "Can only create mutual exclusion rules for experiments in DRAFT, " + "RUNNING, and PAUSED states within+" + "the same application") // response = ??, //todo: update with proper object in @ApiOperation @Timed Response createExclusions(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            final ExperimentIDList experimentIDList,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("/exclusions/experiment1/{experimentID_1}/experiment2/{experimentID_2}") @ApiOperation(value = "Delete a mutual exclusion relation", notes = "Can only delete mutual exclusion relations that currently " + "exists. This operation is symmetric") // response = ??, //todo: update with proper object in @ApiOperation @Timed Response removeExclusions(
            @PathParam("experimentID_1")
            @ApiParam(value = "Experiment ID 1")
            final Experiment.ID experimentID_1,

            @PathParam("experimentID_2")
            @ApiParam(value = "Experiment ID 2")
            final Experiment.ID experimentID_2,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/exclusions") @Produces(APPLICATION_JSON) @ApiOperation(value = "Get list of mutually exclusive experiments", notes = "Shows list of all experiments, in all states, that are " + "mutually exclusive with input experiment.") // response = ??, //todo: update with proper object in @ApiOperation @Timed Response getExclusions(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @QueryParam("showAll")
            @DefaultValue("true")
            final Boolean showAll,

            @QueryParam("exclusive")
            @DefaultValue("true")
            final Boolean exclusive,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/priority/{priorityPosition}") @Produces(APPLICATION_JSON) @ApiOperation(value = "Insert an experiment into an application's priority list", notes = "Experiments can only be placed in a priority list DRAFT, RUNNING, and PAUSED states within" + "the same application") @Timed Response setPriority(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("priorityPosition")
            final int priorityNum,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/assignments") @Produces(TEXT_PLAIN) @ApiOperation(value = "Download a list of user assignments for a given experiment ID", notes = "Shows list of all user assignments for a given experiment ID. Returns both null" + "assignments as well as bucket assignments.", response = StreamingOutput.class) @Timed Response exportAssignments(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @QueryParam("context")
            @DefaultValue("PROD")
            @ApiParam(value = "context for the experiment, eg QA, PROD")
            final Context context,

            @QueryParam("ignoreNullBucket")
            @DefaultValue("false")
            @ApiParam(value = "Filtering on the null bucket")
            final String ignoreStringNullBucket,

            @QueryParam("fromDate")
            @ApiParam(value = "from date to download assignments")
            final String fromStringDate,

            @QueryParam("toDate")
            @ApiParam(value = "to date to download assignments")
            final String toStringDate,

            @QueryParam("timeZone")
            @ApiParam(value = "value of the time zone")
            final String timeZoneString,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Path("{experimentID}/pages") @Consumes(APPLICATION_JSON) @ApiOperation(value = "Post a list of pages to an experiment", notes = "Pages can only be added to an experiment with DRAFT, RUNNING, or PAUSED states") @Timed Response postPages(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            final ExperimentPageList experimentPageList,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @DELETE @Path("{experimentID}/pages/{pageName}") @ApiOperation(value = "Remove a page from an experiment", notes = "Pages can only be added to an experiment with DRAFT, RUNNING, or PAUSED states") @Timed Response deletePage(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @PathParam("pageName")
            @ApiParam(value = "Page name where the experiment will appear")
            final Page.Name pageName,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("{experimentID}/pages") @ApiOperation(value = "Get the associated pages information for a given experiment ID") @Timed Response getExperimentPages(
            @PathParam("experimentID")
            @ApiParam(value = "Experiment ID")
            final Experiment.ID experimentID,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("/applications/{applicationName}/pages/{pageName}") @ApiOperation(value = "Return all experiments for page for app", response = ExperimentList.class) @Timed Response getPageExperiments(
            @PathParam("applicationName")
            @ApiParam(value = "Application Name")
            final Application.Name applicationName,

            @PathParam("pageName")
            @ApiParam(value = "Page name where the experiment will appear")
            final Page.Name pageName);  }