@@ -1002,6 +1002,36 @@ def delete_acl_entry(self, service_id, acl_id, id):
10021002 content = self ._fetch ("/service/{}/acl/{}/entry/{}" .format (service_id , acl_id , id ), method = "DELETE" )
10031003 return self ._status (content )
10041004
1005+ # Dictionary related methods
1006+ def get_dic (self , service_id , version_number , name ):
1007+ content = self ._fetch ("/service/{}/version/{}/dictionary/{}" .format (service_id , version_number , name ))
1008+ return FastlyDictionary (self , content )
1009+
1010+ def create_dic (self , service_id , version_number , name ):
1011+ body = self ._formdata ({
1012+ "name" : name ,
1013+ }, ["name" ])
1014+
1015+ content = self ._fetch ("/service/{}/version/{}/dictionary" .format (service_id , version_number ), method = "POST" , body = body )
1016+ return FastlyDictionary (self , content )
1017+
1018+ def create_dic_item (self , service_id , dic_id , key , value ):
1019+ body = self ._formdata ({
1020+ "item_key" : key ,
1021+ "item_value" : value ,
1022+ }, ["item_key" , "item_value" ])
1023+
1024+ content = self ._fetch ("/service/{}/dictionary/{}/item" .format (service_id , dic_id ), method = "POST" , body = body )
1025+ return FastlyDictionaryItem (self , content )
1026+
1027+ def get_dic_item (self , service_id , dic_id , key ):
1028+ content = self ._fetch ("/service/{}/dictionary/{}/item/{}" .format (service_id , dic_id , key ))
1029+ return FastlyDictionaryItem (self , content )
1030+
1031+ def delete_dic_item (self , service_id , dic_id , key ):
1032+ content = self ._fetch ("/service/{}/dictionary/{}/item/{}" .format (service_id , dic_id , key ), method = "DELETE" )
1033+ return self ._status (content )
1034+
10051035 def _status (self , status ):
10061036 if not isinstance (status , FastlyStatus ):
10071037 status = FastlyStatus (self , status )
@@ -1592,6 +1622,37 @@ class FastlyACLEntry(FastlyObject, object):
15921622 ]
15931623
15941624
1625+ class FastlyDictionary (FastlyObject , object ):
1626+ """A Dictionary is a table that stores key value pairs accessible to VCL functions during VCL processing"""
1627+ FIELDS = [
1628+ "id" ,
1629+ "name" ,
1630+ "version" ,
1631+ "service_id" ,
1632+ "created_at" ,
1633+ "updated_at" ,
1634+ "deleted_at" ,
1635+ ]
1636+
1637+
1638+ class FastlyDictionaryItem (FastlyObject , object ):
1639+ """A DictionaryItem holds a key and value that make up an entry in a Dictionary"""
1640+ FIELDS = [
1641+ "item_key" ,
1642+ "item_value" ,
1643+ "dictionary_id" ,
1644+ "service_id" ,
1645+ ]
1646+
1647+ @property
1648+ def key (self ):
1649+ return self .item_key
1650+
1651+ @property
1652+ def value (self ):
1653+ return self .item_value
1654+
1655+
15951656def connect (token ):
15961657 conn = FastlyConnection (token )
15971658 return conn
0 commit comments