我知道Admin SDK Directory API中的Users list endpoint。但是,它实际上很慢,因为您必须遍历所有用户来计算计数。
我也了解管理设置API中的currentNumberOfUsers endpoint。但是,该API没有只读范围,并且包含许多其他可能敏感的信息。
是否有用于检索域上当前帐户数的只读API?
答案 0 :(得分:1)
如果您传递"字段"用户列表端点并不那么慢参数而不是请求所有用户数据。一个好的"领域"值可以是" users / primaryEmail"。
答案 1 :(得分:0)
如果你只需要计数,你实际上可以只迭代userList
morsedict = {'A': '.-',
'E': '.',
'I': '..',
'O': '---',
'U': '..-'}
def countcombinations(codelist):
# Generate the DP array to match the size of the codeword
maxcombinations = [0] * (len(codelist))
# How many unique strings can I create with access to j elements: j = current index
# j = 0: access to nothing (1 because we need somewhere to start)
maxcombinations[0] = 1
# Brute force calculate the first case due to its simplicity
if codelist[0: 2] in morsedict.values():
maxcombinations[1] = 1
else:
maxcombinations[1] = 0
# For the rest of the indices, we look back in the DP array to see how good we can do given a certain length string
for i in range(1, len(codelist)):
firststr = codelist[i]
secondstr = codelist[(i - 1): i + 1]
thirdstr = codelist[(i - 2): i + 1]
if len(firststr) is 1 and firststr in morsedict.values():
maxcombinations[i] += maxcombinations[i - 1]
if len(secondstr) is 2 and secondstr in morsedict.values():
maxcombinations[i] += maxcombinations[i - 2]
if len(thirdstr) is 3 and thirdstr in morsedict.values():
maxcombinations[i] += maxcombinations[i - 3]
print(maxcombinations[-1])
if __name__ == "__main__":
input()
codelist = input()
countcombinations(codelist)