Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.comet.opik.api.sorting.SortingField;
import com.comet.opik.domain.AlertService;
import com.comet.opik.infrastructure.auth.RequestContext;
import com.comet.opik.infrastructure.auth.RequiredPermissions;
import com.comet.opik.infrastructure.auth.WorkspaceUserPermission;
import com.comet.opik.infrastructure.ratelimit.RateLimited;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -76,6 +78,7 @@ public class AlertResource {
@ApiResponse(responseCode = "409", description = "Conflict", content = @Content(schema = @Schema(implementation = io.dropwizard.jersey.errors.ErrorMessage.class)))
})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ALERT_UPDATE)
public Response createAlert(
@RequestBody(content = @Content(schema = @Schema(implementation = Alert.class))) @JsonView(Alert.View.Write.class) @Valid @NotNull Alert alert,
@Context UriInfo uriInfo) {
Expand Down Expand Up @@ -110,6 +113,7 @@ public Response createAlert(
@ApiResponse(responseCode = "409", description = "Conflict", content = @Content(schema = @Schema(implementation = io.dropwizard.jersey.errors.ErrorMessage.class)))
})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ALERT_UPDATE)
public Response updateAlert(@PathParam("id") UUID id,
@RequestBody(content = @Content(schema = @Schema(implementation = Alert.class))) @JsonView(Alert.View.Write.class) @Valid @NotNull Alert alert) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public Response getAnnotationQueueById(@PathParam("id") UUID id) {
@ApiResponse(responseCode = "409", description = "Conflict", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))
})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ANNOTATION_QUEUE_CREATE)
public Response createAnnotationQueueBatch(
@RequestBody(content = @Content(schema = @Schema(implementation = AnnotationQueueBatch.class))) @JsonView(AnnotationQueue.View.Write.class) @NotNull @Valid AnnotationQueueBatch batch) {

Expand All @@ -154,6 +155,7 @@ public Response createAnnotationQueueBatch(
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))
})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ANNOTATION_QUEUE_CREATE)
public Response createAnnotationQueue(
@RequestBody(content = @Content(schema = @Schema(implementation = AnnotationQueue.class))) @JsonView(AnnotationQueue.View.Write.class) @NotNull @Valid AnnotationQueue request,
@Context UriInfo uriInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.comet.opik.domain.evaluators.AutomationRuleEvaluatorService;
import com.comet.opik.domain.sorting.SortingQueryBuilder;
import com.comet.opik.infrastructure.auth.RequestContext;
import com.comet.opik.infrastructure.auth.RequiredPermissions;
import com.comet.opik.infrastructure.auth.WorkspaceUserPermission;
import com.comet.opik.infrastructure.ratelimit.RateLimited;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -162,6 +164,7 @@ private Set<UUID> extractAndValidateProjectIds(Set<UUID> projectIds, UUID projec
})
})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ONLINE_EVALUATION_RULE_UPDATE)
public Response createEvaluator(
@RequestBody(content = @Content(schema = @Schema(implementation = AutomationRuleEvaluator.class))) @JsonView(View.Write.class) @NotNull @Valid AutomationRuleEvaluator<?, ?> evaluator,
@Context UriInfo uriInfo) {
Expand Down Expand Up @@ -190,6 +193,7 @@ public Response createEvaluator(
@ApiResponse(responseCode = "204", description = "No content"),
})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ONLINE_EVALUATION_RULE_UPDATE)
public Response updateEvaluator(@PathParam("id") UUID id,
@RequestBody(content = @Content(schema = @Schema(implementation = AutomationRuleEvaluatorUpdate.class))) @NotNull @Valid AutomationRuleEvaluatorUpdate<?, ?> evaluatorUpdate) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.comet.opik.api.ManualEvaluationResponse;
import com.comet.opik.domain.evaluators.ManualEvaluationService;
import com.comet.opik.infrastructure.auth.RequestContext;
import com.comet.opik.infrastructure.auth.RequiredPermissions;
import com.comet.opik.infrastructure.auth.WorkspaceUserPermission;
import com.comet.opik.infrastructure.ratelimit.RateLimited;
import io.dropwizard.jersey.errors.ErrorMessage;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -51,6 +53,7 @@ public class ManualEvaluationResource {
@ApiResponse(responseCode = "400", description = "Bad Request - Invalid request or missing automation rules", content = @Content(schema = @Schema(implementation = ErrorMessage.class))),
@ApiResponse(responseCode = "404", description = "Not Found - Project not found", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ONLINE_EVALUATION_RULE_UPDATE)
public Response evaluateTraces(
@RequestBody(content = @Content(schema = @Schema(implementation = ManualEvaluationRequest.class))) @Valid @NonNull ManualEvaluationRequest request) {

Expand Down Expand Up @@ -80,6 +83,7 @@ public Response evaluateTraces(
@ApiResponse(responseCode = "400", description = "Bad Request - Invalid request or missing automation rules", content = @Content(schema = @Schema(implementation = ErrorMessage.class))),
@ApiResponse(responseCode = "404", description = "Not Found - Project not found", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ONLINE_EVALUATION_RULE_UPDATE)
public Response evaluateThreads(
@RequestBody(content = @Content(schema = @Schema(implementation = ManualEvaluationRequest.class))) @Valid @NonNull ManualEvaluationRequest request) {

Expand Down Expand Up @@ -109,6 +113,7 @@ public Response evaluateThreads(
@ApiResponse(responseCode = "400", description = "Bad Request - Invalid request or missing automation rules", content = @Content(schema = @Schema(implementation = ErrorMessage.class))),
@ApiResponse(responseCode = "404", description = "Not Found - Project not found", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.ONLINE_EVALUATION_RULE_UPDATE)
public Response evaluateSpans(
@RequestBody(content = @Content(schema = @Schema(implementation = ManualEvaluationRequest.class))) @Valid @NonNull ManualEvaluationRequest request) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class ProjectsResource {
@ApiResponse(responseCode = "200", description = "Project resource", content = @Content(schema = @Schema(implementation = ProjectPage.class)))
})
@JsonView({View.Public.class})
@RequiredPermissions(WorkspaceUserPermission.PROJECT_DATA_VIEW)
public Response find(
@QueryParam("page") @Min(1) @DefaultValue("1") int page,
@QueryParam("size") @Min(1) @DefaultValue(PAGE_SIZE) int size,
Expand All @@ -114,6 +115,7 @@ public Response find(
@Operation(operationId = "getProjectById", summary = "Get project by id", description = "Get project by id", responses = {
@ApiResponse(responseCode = "200", description = "Project resource", content = @Content(schema = @Schema(implementation = Project.class)))})
@JsonView({View.Public.class})
@RequiredPermissions(WorkspaceUserPermission.PROJECT_DATA_VIEW)
public Response getById(@PathParam("id") UUID id) {

String workspaceId = requestContext.get().getWorkspaceId();
Expand All @@ -135,6 +137,7 @@ public Response getById(@PathParam("id") UUID id) {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))
})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.PROJECT_CREATE)
public Response create(
@RequestBody(content = @Content(schema = @Schema(implementation = Project.class))) @JsonView(View.Write.class) @Valid Project project,
@Context UriInfo uriInfo) {
Expand Down Expand Up @@ -199,6 +202,7 @@ public Response deleteById(@PathParam("id") UUID id) {
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))
})
@JsonView({View.Detailed.class})
@RequiredPermissions(WorkspaceUserPermission.PROJECT_DATA_VIEW)
public Response retrieveProject(
@RequestBody(content = @Content(schema = @Schema(implementation = ProjectRetrieve.class))) @Valid ProjectRetrieve retrieve) {
String workspaceId = requestContext.get().getWorkspaceId();
Expand Down Expand Up @@ -232,6 +236,7 @@ public Response deleteProjectsBatch(
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(implementation = ErrorMessage.class)))
})
@JsonView({View.Public.class})
@RequiredPermissions(WorkspaceUserPermission.PROJECT_DATA_VIEW)
public Response getProjectMetrics(
@PathParam("id") UUID projectId,
@RequestBody(content = @Content(schema = @Schema(implementation = ProjectMetricRequest.class))) @Valid ProjectMetricRequest request) {
Expand Down Expand Up @@ -260,6 +265,7 @@ public Response getProjectMetrics(
@Operation(operationId = "findFeedbackScoreNamesByProjectIds", summary = "Find Feedback Score names By Project Ids", description = "Find Feedback Score names By Project Ids", responses = {
@ApiResponse(responseCode = "200", description = "Feedback Scores resource", content = @Content(schema = @Schema(implementation = FeedbackScoreNames.class)))
})
@RequiredPermissions(WorkspaceUserPermission.PROJECT_DATA_VIEW)
public Response findFeedbackScoreNames(
@QueryParam("project_ids") String projectIdsQueryParam) {

Expand Down Expand Up @@ -293,6 +299,7 @@ private void validate(ProjectMetricRequest request) {
@Operation(operationId = "getProjectStats", summary = "Get Project Stats", description = "Get Project Stats", responses = {
@ApiResponse(responseCode = "200", description = "Project Stats", content = @Content(schema = @Schema(implementation = ProjectStatsSummary.class))),
})
@RequiredPermissions(WorkspaceUserPermission.PROJECT_DATA_VIEW)
public Response getProjectStats(
@QueryParam("page") @Min(1) @DefaultValue("1") int page,
@QueryParam("size") @Min(1) @DefaultValue(PAGE_SIZE) int size,
Expand Down Expand Up @@ -320,6 +327,7 @@ public Response getProjectStats(
@Operation(operationId = "findTokenUsageNames", summary = "Find Token Usage names", description = "Find Token Usage names", responses = {
@ApiResponse(responseCode = "200", description = "Token Usage names resource", content = @Content(schema = @Schema(implementation = TokenUsageNames.class)))
})
@RequiredPermissions(WorkspaceUserPermission.PROJECT_DATA_VIEW)
public Response findTokenUsageNames(@PathParam("id") UUID projectId) {

String workspaceId = requestContext.get().getWorkspaceId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public Response deleteById(@PathParam("id") @NotNull String id) {
@Operation(operationId = "addSpanFeedbackScore", summary = "Add span feedback score", description = "Add span feedback score", responses = {
@ApiResponse(responseCode = "204", description = "No Content")})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.TRACE_SPAN_THREAD_ANNOTATE)
public Response addSpanFeedbackScore(@PathParam("id") UUID id,
@RequestBody(content = @Content(schema = @Schema(implementation = FeedbackScore.class))) @NotNull @Valid FeedbackScore score) {

Expand All @@ -318,6 +319,7 @@ public Response addSpanFeedbackScore(@PathParam("id") UUID id,
@Path("/{id}/feedback-scores/delete")
@Operation(operationId = "deleteSpanFeedbackScore", summary = "Delete span feedback score", description = "Delete span feedback score", responses = {
@ApiResponse(responseCode = "204", description = "No Content")})
@RequiredPermissions(WorkspaceUserPermission.TRACE_SPAN_THREAD_ANNOTATE)
public Response deleteSpanFeedbackScore(@PathParam("id") UUID id,
@RequestBody(content = @Content(schema = @Schema(implementation = DeleteFeedbackScore.class))) @NotNull @Valid DeleteFeedbackScore score) {

Expand All @@ -338,6 +340,7 @@ public Response deleteSpanFeedbackScore(@PathParam("id") UUID id,
@Operation(operationId = "scoreBatchOfSpans", summary = "Batch feedback scoring for spans", description = "Batch feedback scoring for spans", responses = {
@ApiResponse(responseCode = "204", description = "No Content")})
@RateLimited
@RequiredPermissions(WorkspaceUserPermission.TRACE_SPAN_THREAD_ANNOTATE)
public Response scoreBatchOfSpans(
@RequestBody(content = @Content(schema = @Schema(implementation = FeedbackScoreBatch.class))) @NotNull @Valid FeedbackScoreBatchContainer.FeedbackScoreBatch batch) {

Expand Down Expand Up @@ -474,6 +477,7 @@ public ChunkedOutput<JsonNode> searchSpans(
@Operation(operationId = "addSpanComment", summary = "Add span comment", description = "Add span comment", responses = {
@ApiResponse(responseCode = "201", description = "Created", headers = {
@Header(name = "Location", required = true, example = "${basePath}/v1/private/spans/{spanId}/comments/{commentId}", schema = @Schema(implementation = String.class))})})
@RequiredPermissions(WorkspaceUserPermission.COMMENT_WRITE)
public Response addSpanComment(@PathParam("id") UUID id,
@RequestBody(content = @Content(schema = @Schema(implementation = Comment.class))) @NotNull @Valid Comment comment,
@Context UriInfo uriInfo) {
Expand Down Expand Up @@ -519,6 +523,7 @@ public Response getSpanComment(@PathParam("commentId") @NotNull UUID commentId,
@Operation(operationId = "updateSpanComment", summary = "Update span comment by id", description = "Update span comment by id", responses = {
@ApiResponse(responseCode = "204", description = "No Content"),
@ApiResponse(responseCode = "404", description = "Not found")})
@RequiredPermissions(WorkspaceUserPermission.COMMENT_WRITE)
public Response updateSpanComment(@PathParam("commentId") UUID commentId,
@RequestBody(content = @Content(schema = @Schema(implementation = Comment.class))) @NotNull @Valid Comment comment) {

Expand All @@ -540,6 +545,7 @@ public Response updateSpanComment(@PathParam("commentId") UUID commentId,
@Operation(operationId = "deleteSpanComments", summary = "Delete span comments", description = "Delete span comments", responses = {
@ApiResponse(responseCode = "204", description = "No Content"),
})
@RequiredPermissions(WorkspaceUserPermission.COMMENT_WRITE)
public Response deleteSpanComments(
@NotNull @RequestBody(content = @Content(schema = @Schema(implementation = BatchDelete.class))) @Valid BatchDelete batchDelete) {

Expand Down
Loading
Loading