summaryrefslogtreecommitdiff
path: root/lisp/service/tfcloud-apply-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/tfcloud-apply-service.lisp
parent9adba239b937df2830a5110adaa1dae17b7dd7d7 (diff)
parent0ad86ba37be273ee1fe4d9bdd5f7bb15c5701abf (diff)
Merge pull request #1 from ololabs/initial-commit
initial commit
Diffstat (limited to 'lisp/service/tfcloud-apply-service.lisp')
-rw-r--r--lisp/service/tfcloud-apply-service.lisp59
1 files changed, 59 insertions, 0 deletions
diff --git a/lisp/service/tfcloud-apply-service.lisp b/lisp/service/tfcloud-apply-service.lisp
new file mode 100644
index 0000000..ac5f6f0
--- /dev/null
+++ b/lisp/service/tfcloud-apply-service.lisp
@@ -0,0 +1,59 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package :snow)
+
+(defclass tfcloud-apply-service (rest-service)
+ ()
+ (:documentation ""))
+
+(defun tfcloud-apply-json ()
+ (with-noauth (instance tfcloud-apply-service)
+ t))
+
+(defclass tfcloud-apply/view-service (tfcloud-apply-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form)
+ (location-p :initform nil))
+ (:documentation ""))
+
+(defun tfcloud-apply-view-json ()
+ (with-noauth (instance tfcloud-apply/view-service)
+ (setf (form instance)
+ (make-form "tfcloud-apply-form"
+ nil
+ t
+ `((:name "filter" :label "Filter" :field-type "text" :required "required" :value ,(or (session-value :tfcloud-apply-filter) ""))
+ (:label "Find Matching Workspaces" :field-type "button" :onclick "on_tfcloud_apply_results_clicked()"))))))
+
+(defclass tfcloud-apply/results-service (tfcloud-apply/view-service)
+ ((results :initarg :results
+ :initform nil
+ :accessor results)
+ (location-p :initform nil))
+ (:documentation ""))
+
+(defun tfcloud-apply-results-json (filter)
+ (with-noauth (instance tfcloud-apply/results-service)
+ (with-tfcloud (tfcloud)
+ (let ((workspaces (get-tfcloud-workspaces tfcloud filter)))
+ (setf (results instance) (mapcar (lambda (workspace)
+ (sanitize-json workspace))
+ workspaces))
+ (setf (session-value :tfcloud-apply-filter) filter)
+ (setf (session-value :tfcloud-apply-workspaces) workspaces)
+ (setf (form instance)
+ (make-form "tfcloud-apply-submit-form"
+ nil
+ t
+ `((:label "Apply Workspaces" :field-type "button" :onclick "on_tfcloud_apply_results_submit_clicked()"))))))))
+
+(defclass tfcloud-apply/results-submit-service (tfcloud-apply-service)
+ ((location-p :initform nil))
+ (:documentation ""))
+
+(defun tfcloud-apply-results-submit-json ()
+ (with-noauth (instance tfcloud-apply/results-submit-service)
+ (loop for workspace in (session-value :tfcloud-apply-workspaces)
+ do (apply-tfcloud-workspace workspace))))