@@ -8,8 +8,12 @@ class Collection():
8
8
def __init__ (self , system , authenticatedUser , collectionID = "" , collectionName = "" ):
9
9
if collectionID :
10
10
self .url = system .url + '/api/v/1/data/' + collectionID
11
+ self .collectionID = collectionID
12
+ self .collectionName = None
11
13
elif collectionName :
12
14
self .url = system .url + '/api/v/1/collection/' + system .systemKey + "/" + collectionName
15
+ self .collectionName = collectionName
16
+ self .collectionID = None
13
17
else :
14
18
cbLogs .error ("You must supply either a collection name or id." ) # beep
15
19
exit (- 1 )
@@ -69,3 +73,37 @@ def updateItems(self, query, data):
69
73
70
74
def deleteItems (self , query ):
71
75
return restcall .delete (self .url , headers = self .headers , params = {"query" : json .dumps (query .filters )}, sslVerify = self .sslVerify )
76
+
77
+
78
+ ###########################
79
+ # DEVELOPER ENDPOINTS #
80
+ ###########################
81
+
82
+ def DEVnewCollection (developer , system , name ):
83
+ url = system .url + "/admin/collectionmanagement"
84
+ data = {
85
+ "appID" : system .systemKey ,
86
+ "name" : name
87
+ }
88
+ resp = restcall .post (url , headers = developer .headers , data = data , sslVerify = system .sslVerify )
89
+ cbLogs .info ("Successfully created collection: " + name )
90
+ newCollection = Collection (system , developer , collectionID = resp ["collectionID" ])
91
+ return newCollection
92
+
93
+ def DEVaddColumnToCollection (developer , system , collection , columnName , columnType ):
94
+ if not collection .collectionID :
95
+ cbLogs .error ("You must supply the collection id when adding a column to a collection." )
96
+ exit (- 1 )
97
+ url = system .url + "/admin/collectionmanagement"
98
+ data = {
99
+ "id" : collection .collectionID ,
100
+ "addColumn" : {
101
+ "id" : collection .collectionID ,
102
+ "name" : columnName ,
103
+ "type" : columnType
104
+ }
105
+ }
106
+ resp = restcall .put (url , headers = developer .headers , data = data , sslVerify = system .sslVerify )
107
+ cbLogs .info ("Successfully added column: " + columnName )
108
+ return resp
109
+
0 commit comments