-
-
Save nmcspadden/ab25e3dece43ee80069084b62b9735de to your computer and use it in GitHub Desktop.
adobe_tools - Add/Remove products (Public)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_products(desired_products, target_user): | |
"""Add products to specific user.""" | |
(config_data, jwt_token, access_token) = generate_config() | |
productlist = _product_list(config_data, access_token) | |
userlist = _user_list(config_data, access_token) | |
names = [] | |
for user in userlist: | |
names.append(user['email']) | |
products = [] | |
for product in productlist: | |
products.append(product['groupName']) | |
if target_user not in names: | |
print("Didn't find %s in userlist" % target_user) | |
return False | |
for product in desired_products: | |
if product not in products: | |
print("Didn't find %s in product list" % product) | |
return False | |
result = _add_product_to_user( | |
config_data, | |
desired_products, | |
target_user, | |
access_token, | |
) | |
return result | |
def remove_products(removed_products, target_user): | |
"""Remove products from specific user.""" | |
(config_data, jwt_token, access_token) = generate_config() | |
productlist = _product_list(config_data, access_token) | |
userlist = _user_list(config_data, access_token) | |
names = [] | |
for user in userlist: | |
names.append(user['email']) | |
products = [] | |
for product in productlist: | |
products.append(product['groupName']) | |
if target_user not in names: | |
print("Didn't find %s in userlist" % target_user) | |
return False | |
for product in removed_products: | |
if product not in products: | |
print("Didn't find %s in product list" % product) | |
return False | |
result = _remove_product_from_user( | |
config_data, | |
removed_products, | |
target_user, | |
access_token, | |
) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment