def parse_accounts_list_make_account_info(username, password, accounts_list): """ This function should accept a list of accounts as input and should return a list of """ debug.p('FUNC:::: parse_accounts_list_make_account_info ::::::::::::') ngin = cie_connect(username, password) newlist = [] for row in accounts_list['results']: if row['id']: totalSize, sub_info , next_href = number_of_subs_10(ngin, row['href']) if totalSize: for line in sub_info: newdict = defaultdict(dict) newdict['id'] = row['id'] newdict['href'] = row['href'] newdict['parent'] = row['parent'] newdict['totalSize'] = totalSize newdict['Subscription'] = line['id'] newdict['subHref'] = line['href'] newdict['subType'] = subscription_get_subType(ngin, line['href']) newlist.append(newdict) #debug.p('NEWLIST IN LOOP::::::') #debug.p(newlist) #debug.p('NEWLIST ::::::::::') #debug.p(newlist) return newlist, next_href
def modify_list_endpoints_all(username, password, accountRef): #json_data = open ('./templates/subs.json') #data = json.load (json_data) #json_data.close() """ FUNC: list_subs: This functon should accept an account name and return a list of endpoints from the account. Example of data returned. parent" : "/accounts/AGerry", "id" : "0019724025059", "uid" : null, "href" : "/accounts/AGerry/endpoints/0019724025059", "additionalInfo" : { } """ debug.p('FUNC:::: list_endpoints ::::::::::::' + 'Input Parameter is : ' + str(accountRef)) if accountRef[0] != '/': accountRef = '/' + accountRef if accountRef[:9] != '/accounts': accountRef = '/accounts' + accountRef ngin = cie_connect(username, password) json_obj = accountRef + '/endpoints' data = ngin.get_cie_object_all(json_obj) debug.p(data) if data == 100: return None elif data['results']: resultsOnly = data['results'] return resultsOnly else: return None
def modify_list_endpoints_all(username, password, accountRef): #json_data = open ('./templates/subs.json') #data = json.load (json_data) #json_data.close() """ FUNC: list_subs: This functon should accept an account name and return a list of endpoints from the account. Example of data returned. parent" : "/accounts/AGerry", "id" : "0019724025059", "uid" : null, "href" : "/accounts/AGerry/endpoints/0019724025059", "additionalInfo" : { } """ debug.p('FUNC:::: list_endpoints ::::::::::::' + 'Input Parameter is : ' + str(accountRef)) if accountRef[0] != '/': accountRef = '/'+ accountRef if accountRef[:9] != '/accounts': accountRef = '/accounts'+ accountRef ngin = cie_connect(username, password) json_obj = accountRef + '/endpoints' data = ngin.get_cie_object_all(json_obj) debug.p(data) if data == 100: return None elif data['results']: resultsOnly = data['results'] return resultsOnly else: return None
def get_endpoint_info(username, password, endpoint): """ This function should accept an endpoint and return the json. """ debug.p('FUNC:::: get_endpoint_info ::::::::::::') ngin = cie_connect(username, password) data = ngin.get_cie_object(endpoint) return data
def accounts_list_make_account_info(username, password, accounts_list): """ This function should accept a list of accounts as input and should return a list of parent account, account and link to subs for account """ debug.p('FUNC:::: accounts_list_make_account_info ::::::::::::') ngin = cie_connect(username, password) newlist = [] for row in accounts_list['results']: totalSize, sub_info , next_href = number_of_subs_10(ngin, row['href']) newdict = defaultdict(dict) newdict['id'] = row['id'] newdict['href'] = row['href'] newdict['parent'] = row['parent'] newdict['totalSize'] = totalSize newlist.append(newdict) return newlist
def list_subs(username, password, accountRef): """ FUNC: list_subs: This functon should accept an account name and return a list of subscriptions from the account. """ debug.p('FUNC:::: list_subs ::::::::::::') if accountRef[1] != '/': accountRef = '/'+ accountRef if accountRef[:9] != '/accounts': accountRef = '/accounts'+ accountRef ngin = cie_connect(username, password) json_obj = accountRef + '/subscriptions' data = ngin.get_cie_object(json_obj) if data == 100: return None elif data['results']: resultsOnly = data['results'] return resultsOnly else: return None
def changeBasicEndpoint(username, password, account_name, subNo, endpoint): ngin = cie_connect(username,password) debug.p('FUNC:::: get_changeNasicEndpoint ::::::::::::') attrib = Attributes() attrib.id = "basTransEpRef" attrib.value = endpoint subData, href = get_sub_details(username, password, account_name, subNo) lastModified = subData['lastModified'] attributes = attrib created = subData['created'] allowTags = subData['allowTags'] id_property = subData['id'] json_string = setSub(id_property, lastModified, created, allowTags, attributes) exitCode = ngin.put_cie_json_object(href, json_string) if exitCode == 0: return True else: return None
def list_accounts (username, password, home_account): debug.p('FUNC:::: list_accounts ::::::::::::') ngin = cie_connect(username, password) json_obj = (home_account + '/accounts') accounts_list = ngin.get_cie_object(json_obj) return accounts_list