How to use the pydomo.datasets.Policy function in pydomo

To help you get started, we’ve selected a few pydomo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github domoinc / domo-python-sdk / run_examples.py View on Github external
datasets.data_import_from_file(dataset['id'], csv_file_path)
        domo.logger.info("Uploaded data from a file to DataSet {}".format(
            dataset['id']))

        #########################################
        # Personalized Data Policies (PDPs)
        #########################################

        # Build a Policy Filter (hide sensitive columns/values from users)
        pdp_filter = PolicyFilter()
        pdp_filter.column = 'Attending'  # The DataSet column to filter on
        pdp_filter.operator = FilterOperator.EQUALS
        pdp_filter.values = ['TRUE']  # The DataSet row value to filter on

        # Build the Personalized Data Policy (PDP)
        pdp_request = Policy()
        pdp_request.name = 'Only show friends attending the party'
        # A single PDP can contain multiple filters
        pdp_request.filters = [pdp_filter]
        pdp_request.type = PolicyType.USER
        # The affected user ids (restricted access by filter)
        pdp_request.users = [998, 999]
        # The affected group ids (restricted access by filter)
        pdp_request.groups = [99, 100]

        # Create the PDP
        pdp = datasets.create_pdp(dataset['id'], pdp_request)
        domo.logger.info("Created a Personalized Data Policy (PDP): "
                         "{}, id: {}".format(pdp['name'], pdp['id']))

        # Get a Personalized Data Policy (PDP)
        pdp = datasets.get_pdp(dataset['id'], pdp['id'])