diff options
| author | ckonstanski <carlos.konstanski@olo.com> | 2025-10-07 06:53:09 -0600 |
|---|---|---|
| committer | ckonstanski <carlos.konstanski@olo.com> | 2025-10-07 06:53:09 -0600 |
| commit | 50273c110856e18e3ba563b0f62b7273a4dc022b (patch) | |
| tree | cc58541bb299c659c5fd98774d3693aa99ff092a /lisp/service/tfcloud-apply-service.lisp | |
| parent | 9adba239b937df2830a5110adaa1dae17b7dd7d7 (diff) | |
initial commit
Diffstat (limited to 'lisp/service/tfcloud-apply-service.lisp')
| -rw-r--r-- | lisp/service/tfcloud-apply-service.lisp | 59 |
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)))) |
