Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passthrough endpoints for new instant launch non-admin & updating paths for admin #291

Merged
merged 2 commits into from
Oct 21, 2024
Merged
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
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))))))