Inference endpoint and inference token routes leverage helper functions to get a dataset of relevant items.
30 lines
870 B
Ruby
30 lines
870 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Clover
|
|
hash_branch(:project_prefix, "inference-token") do |r|
|
|
r.web do
|
|
next unless @project.get_ff_inference_ui
|
|
|
|
r.get true do
|
|
@inference_tokens = Serializers::InferenceToken.serialize(inference_token_ds.all)
|
|
view "inference/token/index"
|
|
end
|
|
|
|
r.post true do
|
|
authorize("InferenceToken:create", @project.id)
|
|
it = DB.transaction { ApiKey.create_inference_token(@project) }
|
|
flash["notice"] = "Created inference token with id #{it.ubid}"
|
|
r.redirect "#{@project.path}/inference-token"
|
|
end
|
|
|
|
r.delete String do |ubid|
|
|
if (it = ApiKey.from_ubid(ubid))
|
|
authorize("InferenceToken:delete", it.id)
|
|
it.destroy
|
|
flash["notice"] = "Inference token deleted successfully"
|
|
end
|
|
204
|
|
end
|
|
end
|
|
end
|
|
end
|