2 ;;;; Copyright (c) 2008 Zachary Beane, All Rights Reserved
4 ;;;; Redistribution and use in source and binary forms, with or without
5 ;;;; modification, are permitted provided that the following conditions
8 ;;;; * Redistributions of source code must retain the above copyright
9 ;;;; notice, this list of conditions and the following disclaimer.
11 ;;;; * Redistributions in binary form must reproduce the above
12 ;;;; copyright notice, this list of conditions and the following
13 ;;;; disclaimer in the documentation and/or other materials
14 ;;;; provided with the distribution.
16 ;;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
17 ;;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 ;;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ;;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 ;;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 ;;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 ;;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 ;;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 ;;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 ;;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 ;;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 (defclass logging-setup
()
34 :initarg
:target-bucket
35 :accessor target-bucket
)
37 :initarg
:target-prefix
38 :accessor target-prefix
)
40 :initarg
:target-grants
41 :accessor target-grants
))
47 (defclass logging
(response)
52 (defparameter *logging-binder
*
53 (make-binder '("BucketLoggingStatus"
56 ("TargetBucket" (bind :target-bucket
))
57 ("TargetPrefix" (bind :target-prefix
))
60 (sequence :target-grants
63 (elements-alist :grantee
))
64 ("Permission" (bind :permission
)))))))))))
67 (defun bindings-logging-setup (bindings)
68 (alist-bind (target-bucket target-prefix target-grants
)
70 (make-instance 'logging-setup
71 :target-bucket target-bucket
72 :target-prefix target-prefix
73 :target-grants
(mapcar 'alist-grant target-grants
))))
75 (defgeneric log-serialize
(object)
76 (:method
((logging-setup logging-setup
))
77 (cxml:with-xml-output
(cxml:make-octet-vector-sink
)
78 (cxml:with-element
"BucketLoggingStatus"
79 (when (target-bucket logging-setup
)
80 (cxml:with-element
"LoggingEnabled"
81 (simple-element "TargetBucket" (target-bucket logging-setup
))
82 (simple-element "TargetPrefix" (target-prefix logging-setup
))
83 (when (target-grants logging-setup
)
84 (cxml:with-element
"TargetGrants"
85 (dolist (grant (target-grants logging-setup
))
86 (acl-serialize grant
))))))))))
89 (set-element-class "BucketLoggingStatus" 'logging
)
91 (defmethod specialized-initialize ((response logging
) source
)
92 (let ((bindings (xml-bind *logging-binder
* source
)))
93 (setf (setup response
)
94 (bindings-logging-setup bindings
))