From 50273c110856e18e3ba563b0f62b7273a4dc022b Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Tue, 7 Oct 2025 06:53:09 -0600 Subject: initial commit --- lisp/service/tfcloud-apply-service.lisp | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lisp/service/tfcloud-apply-service.lisp (limited to 'lisp/service/tfcloud-apply-service.lisp') 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)))) -- cgit v1.3