anchor.diff:      (bindings-lifecycle-rules
        (xml-bind 'lifecycle-configuration (body response)))))
   
  -(defun delete-bucket-lifecycle (bucket)
  +(defun delete-bucket-lifecycle (bucket
  +                                &key
  +                                ((:credentials *credentials*) *credentials*))
     "Delete the lifecycle configuration of BUCKET."
     (submit-request (make-instance 'request
                                    :method :delete
                                    :bucket bucket
                                    :sub-resource "lifecycle")))
   
  -(defun (setf bucket-lifecycle) (rules bucket)
  +(defun (setf bucket-lifecycle) (rules bucket
  +                                &key
  +                                ((:credentials *credentials*) *credentials*))
     "Set the lifecycle configuration of BUCKET to RULES. RULES is
   coerced to a list if needed. If RULES is NIL, the lifecycle
   configuration is deleted with DELETE-BUCKET-LIFECYCLE."
  
positive.code:     :initarg :enabledp
      :accessor enabledp)
     (days
      :initarg :days
      :accessor days)))
  
  (defmethod print-object ((rule lifecycle-rule) stream)
    (print-unreadable-object (rule stream :type t)
      (format stream "~S expire prefix ~S in ~D day~:P (~:[disabled~;enabled~])"
              (id rule)
              (prefix rule)
              (days rule)
              (enabledp rule))))
  
  ;;; FIXME: The GFs for ENABLE and DISABLE should really be moved
  
negative.code: (defmethod enable ((rule lifecycle-rule))
    (setf (enabledp rule) t))
  
  (defun lifecycle-rule (&key id prefix (enabled t) days date
                         (action :expire))
    (unless id
      (setf id (string (gensym))))
    (unless prefix
      (error "Missing PREFIX argument"))
    (when (or (not (or days date))
              (and days date))
      (error "Exactly one of :DAYS or :DATE must be provided"))
    (make-instance 'lifecycle-rule
                   :id id
                   :prefix prefix
                   :enabledp enabled
                   :days days
                   :date date
                   :action action))
  
  (defun lifecycle-document (rules)
    "Return an XML document that can be posted as the lifecycle
  configuration of a bucket. See
  http://docs.amazonwebservices.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html#intro-lifecycle-rules
  for details."
    (flet ((timeframe-element (rule)
             (if (days rule)
                 (with-element "Days"
                   (text (princ-to-string (days rule))))
                 (with-element "Date"
                   (text (date rule))))))
      (with-xml-output
        (with-element "LifecycleConfiguration"
          (dolist (rule rules)
            (with-element "Rule"
              (with-element "ID"
                (text (id rule)))
              (with-element "Prefix"
                (text (prefix rule)))
              (with-element "Status"
                (text (if (enabledp rule)
                          "Enabled"
                          "Disabled")))
              (ecase (action rule)
                (:expire
                 (with-element "Expiration"
                   (timeframe-element rule)))
                (:transition
                 (with-element "Transition"
                   (timeframe-element rule)
                   (with-element "StorageClass"
                     (text "GLACIER")))))))))))
  
  (defun bindings-lifecycle-rules (bindings)
    "Create a list of lifecycle rules from BINDINGS, which are obtained
  by xml-binding the LIFECYCLE-CONFIGURATION binder with a document."
    (let ((rules '()))
      (dolist (rule-bindings (bvalue :rules bindings) (nreverse rules))
        (alist-bind (id prefix status days date storage-class)
            rule-bindings
          (push (make-instance 'lifecycle-rule
                               :id id
                               :prefix prefix
                               :enabledp (string= status "Enabled")
                               :action (if storage-class
                                           :transition
                                           :expire)
                               :date date
                               :days (and days (parse-integer days)))
                rules)))))
  
  (define-specific-error (no-such-lifecycle-configuration
                          "NoSuchLifecycleConfiguration")
      () ())
  
  (defun bucket-lifecycle (bucket
                           &key ((:credentials *credentials*) *credentials*))
    "Return the bucket lifecycle rules for BUCKET. Signals
  NO-SUCH-LIFECYCLE-CONFIGURATION if the bucket has no lifecycle
  configuration."
  