summaryrefslogtreecommitdiff
path: root/lisp/service/octopus-environments-with-roles-service.lisp
diff options
context:
space:
mode:
authorBret Koppel <bret@olo.com>2025-10-07 09:00:37 -0400
committerGitHub <noreply@github.com>2025-10-07 09:00:37 -0400
commit910d7fd656b9e957181732b36761449de5a970d1 (patch)
tree0f8ee46af3e93aa489785d64d54c5e155ef0057b /lisp/service/octopus-environments-with-roles-service.lisp
parent9adba239b937df2830a5110adaa1dae17b7dd7d7 (diff)
parent0ad86ba37be273ee1fe4d9bdd5f7bb15c5701abf (diff)
Merge pull request #1 from ololabs/initial-commit
initial commit
Diffstat (limited to 'lisp/service/octopus-environments-with-roles-service.lisp')
-rw-r--r--lisp/service/octopus-environments-with-roles-service.lisp47
1 files changed, 47 insertions, 0 deletions
diff --git a/lisp/service/octopus-environments-with-roles-service.lisp b/lisp/service/octopus-environments-with-roles-service.lisp
new file mode 100644
index 0000000..8cd494e
--- /dev/null
+++ b/lisp/service/octopus-environments-with-roles-service.lisp
@@ -0,0 +1,47 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package :snow)
+
+(defclass octopus-environments-with-roles-service (rest-service)
+ ()
+ (:documentation ""))
+
+(defun octopus-environments-with-roles-json ()
+ (with-noauth (instance octopus-environments-with-roles-service)
+ t))
+
+(defclass octopus-environments-with-roles/view-service (octopus-environments-with-roles-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form)
+ (location-p :initform nil))
+ (:documentation ""))
+
+(defun octopus-environments-with-roles-view-json ()
+ (with-noauth (instance octopus-environments-with-roles/view-service)
+ (setf (form instance)
+ (make-form "octopus-environments-with-roles-form"
+ nil
+ t
+ `((:name "roles" :label "Roles (comma or space separated)" :field-type "text" :required "required" :value ,(or (session-value :octopus-roles) ""))
+ (:name "ode_only_p" :label "ODE only?" :field-type "checkbox")
+ (:label "Find Envs With Roles" :field-type "button" :onclick "on_octopus_environments_with_roles_results_clicked()"))))))
+
+(defclass octopus-environments-with-roles/results-service (octopus-environments-with-roles/view-service)
+ ((results :initarg :results
+ :initform nil
+ :accessor results)
+ (location-p :initform nil))
+ (:documentation ""))
+
+(defun octopus-environments-with-roles-results-json (ode_only_p roles)
+ (with-noauth (instance octopus-environments-with-roles/results-service)
+ (with-octopus (octopus)
+ (let ((environments (get-octopus-environments-with-roles octopus
+ :ode-only-p (string= "true" ode_only_p)
+ :roles (remove-if (lambda (x)
+ (org-ckons-core::null-or-empty-p x))
+ (cl-ppcre:split "[, ]" roles)))))
+ (setf (results instance) environments)
+ (setf (session-value :octopus-roles) roles)))))