def parse_package_sharing_policies()

in src/sfctl/custom_service.py [0:0]


def parse_package_sharing_policies(formatted_policies):
    """Parse package sharing policy description from a JSON encoded set of
    policies"""
    from azure.servicefabric.models import PackageSharingPolicyInfo
    if not formatted_policies:
        return None

    list_psps = []
    for policy in formatted_policies:
        policy_name = policy.get("name", None)
        if policy_name is None:
            raise CLIError('Could not find name of sharing policy element')
        policy_scope = policy.get("scope", None)
        if policy_scope not in [None, 'All', 'Code', 'Config', 'Data']:
            raise CLIError('Invalid policy scope specified')
        list_psps.append(PackageSharingPolicyInfo(shared_package_name=policy_name,
                                                  package_sharing_scope=policy_scope))
    return list_psps