Skip to content

Commit

Permalink
Merge pull request #291 from ianmcorvidae/user-instant-launches
Browse files Browse the repository at this point in the history
passthrough endpoints for new instant launch non-admin & updating paths for admin
  • Loading branch information
ianmcorvidae authored Oct 21, 2024
2 parents c0cedda + 9631caa commit f80f50e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
32 changes: 27 additions & 5 deletions src/terrain/clients/app_exposer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,45 @@

(defn add-instant-launch
[username il]
(-> (app-exposer-url ["instantlaunches/"] {} :no-user true)
(-> (app-exposer-url ["instantlaunches/"] {})
(client/put {:content-type :json
:as :json
:form-params (update il :added_by #(or %1 username))})
(:body)))

(defn update-instant-launch
[id il]
(-> (app-exposer-url ["instantlaunches" id] {} :no-user true)
(-> (app-exposer-url ["instantlaunches" id] {})
(client/post {:content-type :json
:as :json
:form-params il})
(:body)))

(defn delete-instant-launch
[id]
(-> (app-exposer-url ["instantlaunches" id] {} :no-user true)
(-> (app-exposer-url ["instantlaunches" id] {})
(client/delete {:as :json})
(:body)))

(defn admin-add-instant-launch
[username il]
(-> (app-exposer-url ["instantlaunches" "admin/"] {} :no-user true)
(client/put {:content-type :json
:as :json
:form-params (update il :added_by #(or %1 username))})
(:body)))

(defn admin-update-instant-launch
[id il]
(-> (app-exposer-url ["instantlaunches" "admin" id] {} :no-user true)
(client/post {:content-type :json
:as :json
:form-params il})
(:body)))

(defn admin-delete-instant-launch
[id]
(-> (app-exposer-url ["instantlaunches" "admin" id] {} :no-user true)
(client/delete {:as :json})
(:body)))

Expand Down Expand Up @@ -233,15 +255,15 @@

(defn upsert-metadata
[id data]
(-> (app-exposer-url ["instantlaunches" id "metadata"] {})
(-> (app-exposer-url ["instantlaunches" "admin" id "metadata"] {})
(client/post {:content-type :json
:as :json
:form-params data})
(:body)))

(defn reset-metadata
[id data]
(-> (app-exposer-url ["instantlaunches" id "metadata"] {})
(-> (app-exposer-url ["instantlaunches" "admin" id "metadata"] {})
(client/put {:content-type :json
:as :json
:form-params data})
Expand Down
27 changes: 23 additions & 4 deletions src/terrain/routes/instantlaunches.clj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,26 @@
:summary instantlaunch-schema/GetFullInstantLaunchSummary
:description instantlaunch-schema/GetFullInstantLaunchDescription
:return instantlaunch-schema/FullInstantLaunch
(ok (app-exposer/get-full-instant-launch id)))))))
(ok (app-exposer/get-full-instant-launch id)))

(POST "/" []
:summary instantlaunch-schema/UpdateInstantLaunchSummary
:description instantlaunch-schema/UpdateInstantLaunchDescription
:body [body instantlaunch-schema/InstantLaunch]
:return instantlaunch-schema/InstantLaunch
(ok (app-exposer/update-instant-launch id body)))

(DELETE "/" []
:summary instantlaunch-schema/DeleteInstantLaunchSummary
:description instantlaunch-schema/DeleteInstantLaunchDescription
(ok (app-exposer/delete-instant-launch id))))

(PUT "/" []
:summary instantlaunch-schema/AddInstantLaunchSummary
:description instantlaunch-schema/AddInstantLaunchDescription
:body [body instantlaunch-schema/InstantLaunch]
:return instantlaunch-schema/InstantLaunch
(ok (app-exposer/add-instant-launch (:username current-user) body))))))

(defn admin-instant-launch-routes
[]
Expand Down Expand Up @@ -129,12 +148,12 @@
:description instantlaunch-schema/UpdateInstantLaunchDescription
:body [body instantlaunch-schema/InstantLaunch]
:return instantlaunch-schema/InstantLaunch
(ok (app-exposer/update-instant-launch id body)))
(ok (app-exposer/admin-update-instant-launch id body)))

(DELETE "/" []
:summary instantlaunch-schema/DeleteInstantLaunchSummary
:description instantlaunch-schema/DeleteInstantLaunchDescription
(ok (app-exposer/delete-instant-launch id)))
(ok (app-exposer/admin-delete-instant-launch id)))

(context "/metadata" []
(GET "/" []
Expand Down Expand Up @@ -162,4 +181,4 @@
:description instantlaunch-schema/AddInstantLaunchDescription
:body [body instantlaunch-schema/InstantLaunch]
:return instantlaunch-schema/InstantLaunch
(ok (app-exposer/add-instant-launch (:username current-user) body))))))
(ok (app-exposer/admin-add-instant-launch (:username current-user) body))))))

0 comments on commit f80f50e

Please sign in to comment.