@@ -31,14 +31,17 @@ def process_collection(headers, args, func):
3131
3232 # Iterate to the named Org
3333 for org in go_response ['data' ]:
34- if org ['attributes' ]['name' ] == args ["org_name" ]:
34+ if org ['attributes' ]['name' ] == args ["org_name" ] or org [ 'attributes' ][ 'slug' ] == args [ "org_name" ] :
3535
3636 # Find the collection id
3737 collection_id = find_collection (headers , args , org )
3838
3939 # Do the collection process within the passed function
4040 func (headers , args , org , collection_id )
4141
42+ # Now the named org has been processed, there's no need to continue
43+ return
44+
4245 # Next page?
4346 go_pagination = next_page (go_response )
4447 if go_pagination is None :
@@ -53,19 +56,26 @@ def find_collection(headers, args, org):
5356
5457 c_pagination = None
5558 collections = []
59+ response = None
60+
61+ try :
62+ while True :
63+ response = json .loads (utils .rest_api .get_collections (headers , args ["api_ver" ], org , c_pagination ))
64+ collections = collections + response ["data" ]
5665
57- while True :
58- response = json .loads (utils .rest_api .get_collections (headers , args ["api_ver" ], org , c_pagination ))
59- collections = collections + response ["data" ]
66+ # Next page?
67+ c_pagination = next_page (response )
68+ if c_pagination is None :
69+ break
6070
61- # Next page?
62- c_pagination = next_page (response )
63- if c_pagination is None :
64- break
71+ for coll in response ["data" ]:
72+ if coll ['attributes' ]['name' ] == args ["collection_name" ]:
73+ return coll ['id' ]
6574
66- for coll in response ["data" ]:
67- if coll ['attributes' ]['name' ] == args ["collection_name" ]:
68- return coll ['id' ]
75+ return utils .rest_api .create_a_collection (headers , args , org )
76+ except Exception :
77+ print ("GET call to /collections API returned no 'data'" )
78+ print (json .dumps (response , indent = 4 ))
79+ return
6980
70- return utils .rest_api .create_a_collection (headers , args , org )
7181
0 commit comments