mirror of
https://github.com/Phundrak/appwrite.el.git
synced 2025-05-09 10:24:56 +00:00
Add ability to update buckets
This commit is contained in:
parent
15fcf95fa1
commit
03b73f6fbb
@ -1,3 +1,5 @@
|
|||||||
|
#+startup: overview
|
||||||
|
|
||||||
* TODO Implement API [0/8]
|
* TODO Implement API [0/8]
|
||||||
** TODO Accounts [0/20]
|
** TODO Accounts [0/20]
|
||||||
*** TODO Get Account
|
*** TODO Get Account
|
||||||
@ -86,14 +88,15 @@
|
|||||||
*** TODO Update Document
|
*** TODO Update Document
|
||||||
*** TODO Delete Document
|
*** TODO Delete Document
|
||||||
|
|
||||||
** TODO Storage [4/13]
|
** TODO Storage [5/13]
|
||||||
*** DONE Create bucket
|
*** DONE Create bucket
|
||||||
CLOSED: [2022-07-13 Wed 14:28]
|
CLOSED: [2022-07-13 Wed 14:28]
|
||||||
*** DONE List buckets
|
*** DONE List buckets
|
||||||
CLOSED: [2022-07-13 Wed 15:33]
|
CLOSED: [2022-07-13 Wed 15:33]
|
||||||
*** DONE Get Bucket
|
*** DONE Get Bucket
|
||||||
CLOSED: [2022-07-13 Wed 15:34]
|
CLOSED: [2022-07-13 Wed 15:34]
|
||||||
*** TODO Update Bucket
|
*** DONE Update Bucket
|
||||||
|
CLOSED: [2022-07-13 Wed 16:35]
|
||||||
*** DONE Delete Bucket
|
*** DONE Delete Bucket
|
||||||
CLOSED: [2022-07-13 Wed 14:28]
|
CLOSED: [2022-07-13 Wed 14:28]
|
||||||
*** TODO Create File
|
*** TODO Create File
|
||||||
|
81
appwrite.el
81
appwrite.el
@ -184,15 +184,18 @@ Content-Type in the headers is \"application/json\"."
|
|||||||
|
|
||||||
;;; Storage
|
;;; Storage
|
||||||
|
|
||||||
(cl-defun appwrite-storage-create-bucket (id
|
(cl-defun appwrite--storage-update-bucket (id
|
||||||
name
|
name
|
||||||
&key
|
&key
|
||||||
(permission "bucket")
|
updatep
|
||||||
read write (enabled t)
|
(permission "bucket")
|
||||||
maximum-file-size allowed-file-extensions
|
read write (enabled t)
|
||||||
(encryption t) (antivirus t))
|
maximum-file-size allowed-file-extensions
|
||||||
"Create bucket.
|
(encryption t) (antivirus t))
|
||||||
Create bucket named NAME with id ID.
|
"Create or update a storage bucket.
|
||||||
|
Create or update a storage bucket named NAME with id ID.
|
||||||
|
|
||||||
|
If UPDATEP is t, update the bucket, else create it.
|
||||||
|
|
||||||
PERMISSION is the permissioin type model to use for reading files
|
PERMISSION is the permissioin type model to use for reading files
|
||||||
in this bucket. By default, PERMISSION is \"bucket\". For more
|
in this bucket. By default, PERMISSION is \"bucket\". For more
|
||||||
@ -217,7 +220,8 @@ larger than 20MB are skipped. t by default.
|
|||||||
|
|
||||||
If ANTIVIRUS is t, enable antivirus for the bucket. Files larger
|
If ANTIVIRUS is t, enable antivirus for the bucket. Files larger
|
||||||
than 20MB are skipped. t by default."
|
than 20MB are skipped. t by default."
|
||||||
(let ((payload `(bucketId ,id name ,name permission ,permission)))
|
(let ((payload `(bucketId ,id name ,name permission ,permission))
|
||||||
|
(method (if updatep "PUT" "POST")))
|
||||||
(when read
|
(when read
|
||||||
(setq payload (append payload `(read ,read))))
|
(setq payload (append payload `(read ,read))))
|
||||||
(when write
|
(when write
|
||||||
@ -230,13 +234,62 @@ than 20MB are skipped. t by default."
|
|||||||
(setq payload (append payload `(encryption ,(if encryption t :json-false))))
|
(setq payload (append payload `(encryption ,(if encryption t :json-false))))
|
||||||
(setq payload (append payload `(antivirus ,(if antivirus t :json-false))))
|
(setq payload (append payload `(antivirus ,(if antivirus t :json-false))))
|
||||||
;; (json-encode-plist payload)
|
;; (json-encode-plist payload)
|
||||||
(let ((response (appwrite--query-api :method "POST"
|
(let ((response (appwrite--query-api :method method
|
||||||
:api "/v1/storage/buckets"
|
:api (concat "/v1/storage/buckets/"
|
||||||
|
(if updatep id ""))
|
||||||
:payload (json-encode-plist payload))))
|
:payload (json-encode-plist payload))))
|
||||||
(appwrite--process-response (concat "Failed to create bucket " id)
|
(appwrite--process-response (format "Failed to %s bucket %s"
|
||||||
201
|
(if updatep "update" "create")
|
||||||
|
id)
|
||||||
|
(if updatep 200 201)
|
||||||
response))))
|
response))))
|
||||||
|
|
||||||
|
(cl-defun appwrite-storage-create-bucket (id
|
||||||
|
name
|
||||||
|
&key
|
||||||
|
(permission "bucket")
|
||||||
|
read write (enabled t)
|
||||||
|
maximum-file-size allowed-file-extensions
|
||||||
|
(encryption t) (antivirus t))
|
||||||
|
"Create storage bucket.
|
||||||
|
For documentation on ID, NAME, PERMISSION, READ, WRITE, ENABLED,
|
||||||
|
MAXIMUM-FILE-SIZE, ALLOWED-FILE-EXTENSIONS, ENCRYPTION, and
|
||||||
|
ANTIVIRUS, check `appwrite--storage-update-bucket'."
|
||||||
|
(appwrite--storage-update-bucket id
|
||||||
|
name
|
||||||
|
:updatep nil
|
||||||
|
:permission permission
|
||||||
|
:read read
|
||||||
|
:write write
|
||||||
|
:enabled enabled
|
||||||
|
:maximum-file-size maximum-file-size
|
||||||
|
:allowed-file-extensions allowed-file-extensions
|
||||||
|
:encryption encryption
|
||||||
|
:antivirus antivirus))
|
||||||
|
|
||||||
|
(cl-defun appwrite-storage-update-bucket (id
|
||||||
|
name
|
||||||
|
&key
|
||||||
|
(permission "bucket")
|
||||||
|
read write (enabled t)
|
||||||
|
maximum-file-size allowed-file-extensions
|
||||||
|
(encryption t) (antivirus t))
|
||||||
|
"Create storage bucket.
|
||||||
|
For documentation on ID, NAME, PERMISSION, READ, WRITE, ENABLED,
|
||||||
|
MAXIMUM-FILE-SIZE, ALLOWED-FILE-EXTENSIONS, ENCRYPTION, and
|
||||||
|
ANTIVIRUS, check `appwrite--storage-update-bucket'."
|
||||||
|
(appwrite--storage-update-bucket id
|
||||||
|
name
|
||||||
|
:updatep t
|
||||||
|
:permission permission
|
||||||
|
:read read
|
||||||
|
:write write
|
||||||
|
:enabled enabled
|
||||||
|
:maximum-file-size maximum-file-size
|
||||||
|
:allowed-file-extensions allowed-file-extensions
|
||||||
|
:encryption encryption
|
||||||
|
:antivirus antivirus))
|
||||||
|
|
||||||
(cl-defun appwrite-storage-list-buckets (&key search (limit 25) offset cursor cursor-direction order-type)
|
(cl-defun appwrite-storage-list-buckets (&key search (limit 25) offset cursor cursor-direction order-type)
|
||||||
"List of all storage buckets.
|
"List of all storage buckets.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user