;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- (declaim (optimize (speed 0) (safety 3) (debug 3))) (in-package :snow) (defclass asg-recycle-service (rest-service) () (:documentation "")) (defun asg-recycle-json () (with-noauth (instance asg-recycle-service) t)) (defclass asg-recycle/view-service (asg-recycle-service) ((form :initarg :form :initform nil :accessor form) (location-p :initform nil)) (:documentation "")) (defun asg-recycle-view-json () (with-noauth (instance asg-recycle/view-service) (setf (form instance) (make-form "asg-recycle-form" nil t `((:name "profile" :label "Profile" :field-type "text" :required "required" :value ,(or (session-value :profile) "")) (:name "region" :label "Region" :field-type "text" :required "required" :value ,(or (session-value :region) (region *webapp*))) (:name "filter" :label "Filter" :field-type "text" :required "required" :value ,(or (session-value :asg-recycle-filter) "")) (:label "Find Matching ASGs" :field-type "button" :onclick "on_asg_recycle_results_clicked()")))))) (defclass asg-recycle/results-service (asg-recycle/view-service) ((results :initarg :results :initform nil :accessor results) (location-p :initform nil)) (:documentation "")) (defun asg-recycle-results-json (profile region filter) (with-noauth (instance asg-recycle/results-service) (let* ((aws (make-instance 'aws :profile profile :region region)) (asgs (get-asgs aws filter))) (setf (results instance) (mapcar (lambda (asg) (sanitize-json asg)) asgs)) (setf (session-value :profile) profile) (setf (session-value :region) region) (setf (session-value :asg-recycle-filter) filter) (setf (session-value :asg-recycle-asgs) asgs) (setf (form instance) (make-form "asg-recycle-submit-form" nil t `((:label "Recycle All Hosts in ASGs" :field-type "button" :onclick "on_asg_recycle_results_submit_clicked('all')") (:label "Recycle One Host in ASGs" :field-type "button" :onclick "on_asg_recycle_results_submit_clicked('one')"))))))) (defclass asg-recycle/results-submit-service (asg-recycle-service) ((location-p :initform nil)) (:documentation "")) (defun asg-recycle-results-submit-json (howmany) (with-noauth (instance asg-recycle/results-submit-service) (loop for asg in (session-value :asg-recycle-asgs) do (setf (howmany asg) howmany) (recycle-asg asg))))