summaryrefslogtreecommitdiff
path: root/lisp/service/unhealthy-targetgroups-service.lisp
blob: 578fe9c60b0e387898bf4cc4fab1a2c22d1b8187 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))

(in-package :snow)

(defclass unhealthy-targetgroups-service (rest-service)
  ()
  (:documentation ""))

(defun unhealthy-targetgroups-json ()
  (with-noauth (instance unhealthy-targetgroups-service)
    t))

(defclass unhealthy-targetgroups/view-service (unhealthy-targetgroups-service)
  ((form :initarg :form
         :initform nil
         :accessor form)
   (location-p :initform nil))
  (:documentation ""))

(defun unhealthy-targetgroups-view-json ()
  (with-noauth (instance unhealthy-targetgroups/view-service)
    (setf (form instance)
          (make-form "unhealthy-targetgroups-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 :unhealthy-targetgroup-filter) ""))
                       (:label "Find Unhealthy Targetgroups" :field-type "button" :onclick "on_unhealthy_targetgroups_results_clicked()"))))))

(defclass unhealthy-targetgroups/results-service (unhealthy-targetgroups/view-service)
  ((stdout :initarg :stdout
           :initform nil
           :accessor stdout)
   (location-p :initform nil))
  (:documentation ""))

(defun unhealthy-targetgroups-results-json (profile region filter)
  (with-noauth (instance unhealthy-targetgroups/results-service)
    (cl-fad:with-output-to-temporary-file (f :template "/tmp/snow/temp-%")
      (get-aws-unhealthy-targetgroups (make-instance 'aws-targetgroup
                                                     :profile profile
                                                     :region region
                                                     :filter filter
                                                     :stdout (pathname f)))
      (setf (stdout instance) (uiop:native-namestring (pathname f))))
    (setf (session-value :profile) profile)
    (setf (session-value :region) region)
    (setf (session-value :unhealthy-targetgroup-filter) filter)))