From 35eb8836f39b21e5e4f7770936d5a5073ea2b783 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 11 Oct 2024 17:12:38 +0200 Subject: add cli command `collection schema COLLECTION` --- backend/lib/ACMS/API/REST/Collection.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'backend/lib') diff --git a/backend/lib/ACMS/API/REST/Collection.hs b/backend/lib/ACMS/API/REST/Collection.hs index ed0ae9a..375b20c 100644 --- a/backend/lib/ACMS/API/REST/Collection.hs +++ b/backend/lib/ACMS/API/REST/Collection.hs @@ -1,10 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} + module ACMS.API.REST.Collection where import Data.Aeson qualified as A import Data.Aeson.KeyMap qualified as AM import Data.ByteString.Lazy.UTF8 qualified as LB import Data.Function ((&)) +import Data.String (fromString) import Data.Text qualified as T import Network.HTTP.Simple import Text.Printf (printf) @@ -58,3 +60,10 @@ delete c i = (LB.fromString (printf "DELETE FROM %s WHERE %s.$fileName == \"%s\"" c c i)) & httpLBS >>= A.throwDecode . getResponseBody + +schema :: T.Text -> IO A.Value +schema c = + fromString (printf "http://localhost:8081/%s.schema.json" c) + & setRequestMethod "POST" + & httpLBS + >>= A.throwDecode . getResponseBody -- cgit v1.2.3