From 7fd83a7bf18fabf254dc679fe8d9b184747e7f70 Mon Sep 17 00:00:00 2001 From: Sarah Roberts Date: Thu, 22 Feb 2024 16:17:38 -0700 Subject: [PATCH 1/3] CORE-1983: suppress most OpenTelemetry errors that appear during development --- project.clj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/project.clj b/project.clj index cfbe4148..dc550da7 100644 --- a/project.clj +++ b/project.clj @@ -66,7 +66,8 @@ [jonase/eastwood "0.3.10"] [reifyhealth/lein-git-down "0.4.1"]] :profiles {:dev {:dependencies [[clj-http-fake "1.0.3"]] - :resource-paths ["conf/test" "test-resources"]} + :resource-paths ["conf/test" "test-resources"] + :jvm-opts ["-Dotel.javaagent.enabled=false"]} :uberjar {:aot :all}} :main ^:skip-aot terrain.core :ring {:handler terrain.core/dev-handler @@ -79,4 +80,6 @@ ["sonatype-releases" {:url "https://oss.sonatype.org/content/repositories/releases/"}] ["public-github" {:url "git://github.com" :protocol :https}]] - :jvm-opts ["-Dlogback.configurationFile=/etc/iplant/de/logging/terrain-logging.xml" "-javaagent:./opentelemetry-javaagent.jar" "-Dotel.resource.attributes=service.name=terrain"]) + :jvm-opts ["-Dlogback.configurationFile=/etc/iplant/de/logging/terrain-logging.xml" + "-javaagent:./opentelemetry-javaagent.jar" + "-Dotel.resource.attributes=service.name=terrain"]) From 09a507a6683454ecb715ff08f4ce3b884e2ebc52 Mon Sep 17 00:00:00 2001 From: Sarah Roberts Date: Thu, 22 Feb 2024 16:56:51 -0700 Subject: [PATCH 2/3] CORE-1983: change the version number in project.clj --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index dc550da7..f9de75c3 100644 --- a/project.clj +++ b/project.clj @@ -7,7 +7,7 @@ (string/trim (:out (sh "git" "rev-parse" "HEAD"))) "")) -(defproject org.cyverse/terrain "2.12.0-SNAPSHOT" +(defproject org.cyverse/terrain "3.0.0-SNAPSHOT" :description "Discovery Environment API gateway/API services catch-all project" :url "https://github.com/cyverse-de/terrain" :license {:name "BSD Standard License" From b5b118ee190238d81247befd7f50aba1a07328c6 Mon Sep 17 00:00:00 2001 From: Sarah Roberts Date: Thu, 22 Feb 2024 17:05:37 -0700 Subject: [PATCH 3/3] CORE-1983: added support for multi-year subscriptions to the QMS endpoints --- src/terrain/routes/qms.clj | 40 +++++++++++++++--------------- src/terrain/routes/schemas/qms.clj | 20 +++++++++------ 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/terrain/routes/qms.clj b/src/terrain/routes/qms.clj index 2001f7c3..23beac1a 100644 --- a/src/terrain/routes/qms.clj +++ b/src/terrain/routes/qms.clj @@ -92,10 +92,10 @@ :body [body schema/SubscriptionRequests] :return schema/BulkSubscriptionResponse (ok (handlers/add-subscriptions params body))) - + (context "/:subscription-uuid" [] :path-params [subscription-uuid :- schema/SubscriptionID] - + (context "/addons" [] (GET "/" [] :middleware [require-authentication] @@ -103,7 +103,7 @@ :description schema/ListSubscriptionAddonsDescription :return schema/SubscriptionAddonListResponse (ok (n/list-subscription-addons subscription-uuid))) - + (POST "/" [] :middleware [require-authentication] :summary schema/AddSubscriptionAddonSummary @@ -111,24 +111,24 @@ :body [body schema/AddonIDBody] :return schema/SubscriptionAddonResponse (ok (n/add-subscription-addon subscription-uuid (:uuid body)))) - + (context "/:uuid" [] :path-params [uuid :- schema/SubscriptionAddonID] - + (GET "/" [] :middleware [require-authentication] :summary schema/GetSubscriptionAddonSummary :description schema/GetSubscriptionAddonDescription :return schema/SubscriptionAddonResponse (ok (n/get-subscription-addon uuid))) - + (PUT "/" [] :middleware [require-authentication] :summary schema/UpdateSubscriptionAddonSummary :description schema/UpdateSubscriptionAddonDescription :body [body schema/UpdateSubscriptionAddon] (ok (n/update-subscription-addon (assoc body :uuid uuid)))) - + (DELETE "/" [] :middleware [require-authentication] :summary schema/DeleteSubscriptionAddonSummary @@ -151,7 +151,7 @@ :description schema/ListAddonsDescription :return schema/AddonListResponse (ok (n/list-addons))) - + (PUT "/" [] :middleware [require-authentication] :summary schema/UpdateAddonSummary @@ -159,7 +159,7 @@ :body [body schema/UpdateAddon] :return schema/AddonResponse (ok (n/update-addon body))) - + (DELETE "/:uuid" [] :middleware [require-authentication] :summary schema/DeleteAddonSummary @@ -216,7 +216,7 @@ (context "/users" [] (context "/:username" [] :path-params [username :- schema/Username] - + (context "/plan" [] (GET "/" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] @@ -224,7 +224,7 @@ :description schema/GetSubscriptionDescription :return schema/SubscriptionPlanResponse (ok (qms/subscription username))) - + (PUT "/:plan-name" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] :summary schema/UpdateSubscriptionSummary @@ -232,7 +232,7 @@ :path-params [plan-name :- schema/PlanName] :return schema/SuccessResponse (ok (qms/update-subscription username plan-name {:paid true})))))) - + (context "/addons" [] (GET "/" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] @@ -240,11 +240,11 @@ :description schema/ListAddonsDescription :return schema/AddonListResponse (ok (n/list-addons)))) - + (context "/subscriptions" [] (context "/:subscription-uuid" [] :path-params [subscription-uuid :- schema/SubscriptionID] - + (context "/addons" [] (GET "/" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] @@ -252,7 +252,7 @@ :description schema/ListSubscriptionAddonsDescription :return schema/SubscriptionAddonListResponse (ok (n/list-subscription-addons subscription-uuid))) - + (POST "/" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] :summary schema/AddSubscriptionAddonSummary @@ -260,27 +260,27 @@ :body [body schema/AddonIDBody] :return schema/SubscriptionAddonResponse (ok (n/add-subscription-addon subscription-uuid (:uuid body)))) - + (context "/:uuid" [] :path-params [uuid :- schema/SubscriptionAddonID] - + (GET "/" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] :summary schema/GetSubscriptionAddonSummary :description schema/GetSubscriptionAddonDescription :return schema/SubscriptionAddonResponse (ok (n/get-subscription-addon uuid))) - + (PUT "/" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] :summary schema/UpdateSubscriptionAddonSummary :description schema/UpdateSubscriptionAddonDescription :body [body schema/UpdateSubscriptionAddon] (ok (n/update-subscription-addon (assoc body :uuid uuid)))) - + (DELETE "/" [] :middleware [[require-service-account ["cyverse-subscription-updater"]]] :summary schema/DeleteSubscriptionAddonSummary :description schema/DeleteSubscriptionAddonDescription :return schema/SubscriptionAddonResponse - (ok (n/delete-subscription-addon uuid)))))))))) \ No newline at end of file + (ok (n/delete-subscription-addon uuid)))))))))) diff --git a/src/terrain/routes/schemas/qms.clj b/src/terrain/routes/schemas/qms.clj index ad6b72ce..591153f8 100644 --- a/src/terrain/routes/schemas/qms.clj +++ b/src/terrain/routes/schemas/qms.clj @@ -1,6 +1,6 @@ (ns terrain.routes.schemas.qms (:require [common-swagger-api.schema :refer [PagingParams describe]] - [schema.core :refer [defschema Any optional-key maybe enum]]) + [schema.core :as s :refer [defschema Any optional-key maybe enum]]) (:import [java.util UUID])) (def GetAllPlansSummary "Returns a list of all plans registered in QMS") @@ -61,9 +61,10 @@ :status (describe String "The status of the response")}) (defschema ResourceType - {:id ResourceID - :name ResourceTypeName - :unit (describe String "The unit of the resource type")}) + {:id ResourceID + :name ResourceTypeName + :unit (describe String "The unit of the resource type") + :consumable (describe Boolean "True if using the resource consumes it permanently")}) (defschema ResourceTypesResponse {:result (describe [ResourceType] "The list of resource types") @@ -160,7 +161,9 @@ (defschema SubscriptionRequest {(optional-key :username) (describe String "The username to associate with the subscription") (optional-key :plan_name) (describe String "The name of the plan to associate with the subscription") - :paid (describe Boolean "True if the user paid for the subscription")}) + :paid (describe Boolean "True if the user paid for the subscription") + (optional-key :periods) (describe Integer "The number of subscription periods") + (optional-key :end_date) (describe String "The end date of the subscription.")}) (defschema SubscriptionRequests {(optional-key :subscriptions) (describe (maybe [SubscriptionRequest]) "The list of subscription requests")}) @@ -169,8 +172,11 @@ {(optional-key :force) (describe String "True if the subscription should be created even if the user already has a higher level plan")}) +;; The :periods parameter uses s/Int so that we can get automatic coercion. (defschema AddSubscriptionParams - {:paid (describe Boolean "True if the user paid for the subscription")}) + {:paid (describe Boolean "True if the user paid for the subscription") + (optional-key :periods) (describe s/Int "The number of subscription periods") + (optional-key :end_date) (describe String "The end date of the subscription")}) (defschema ListSubscriptionsParams (merge PagingParams @@ -250,4 +256,4 @@ (optional-key :paid) (describe Boolean "Sets whether the subscription add-on needs to be charged for")}) (defschema SubscriptionAddonListResponse - {:subscription_addons (describe [SubscriptionAddon] "The returned list of subscription add-ons")}) \ No newline at end of file + {:subscription_addons (describe [SubscriptionAddon] "The returned list of subscription add-ons")})