Get/resolve the list of policies into a list of policies with config.  This operation is
done asynchronously so that plugins can be downloaded if needed.  Any errors in resolving
the policies will be reported back via the policyErrorHandler.
768506
private void loadPolicies(final IAsyncHandler<List<PolicyWithConfiguration>> handler) {
        final Set<Integer> totalCounter = new HashSet<>();
        final Set<Integer> errorCounter = new TreeSet<>();
        final List<PolicyWithConfiguration> rval = new ArrayList<>(policies.size());
        final List<Throwable> errors = new ArrayList<>(policies.size());
        final int numPolicies = policies.size();
        int index = 0;

        // If there aren't any policies, then no need to asynchronously load them!
        if (policies.isEmpty()) {
            handler.handle(policyImpls);
            return;
        }

        for (final Policy policy : policies) {
            rval.add(null);
            errors.add(null);
            final int localIdx = index++;
            policyFactory.loadPolicy(policy.getPolicyImpl(), (IAsyncResult<IPolicy> result) -> {
                if (result.isSuccess()) {
                    IPolicy policyImpl = result.getResult();
                    // Test whether pipeline contains any data policies. Connectors can use this for Content-Length pass-through.
                    if (policyImpl instanceof IDataPolicy) {
                        hasDataPolicy = true;
                    }
                    try {
                        Object policyConfig = policyFactory.loadConfig(policyImpl, policy.getPolicyImpl(), policy.getPolicyJsonConfig());
                        PolicyWithConfiguration pwc = new PolicyWithConfiguration(policyImpl, policyConfig);
                        rval.set(localIdx, pwc);
                    } catch (Throwable t) {
                        errors.set(localIdx, t);
                        errorCounter.add(localIdx);
                    }
                } else {
                    Throwable error = result.getError();
                    errors.set(localIdx, error);
                    errorCounter.add(localIdx);
                }
                totalCounter.add(localIdx);
                // Have we done them all?
                if (totalCounter.size() == numPolicies) {
                    // Did we get any errors?  If yes, report the first one. If no, then send back
                    // the fully resolved list of policies.
                    if (!errorCounter.isEmpty()) {
                        int errorIdx = errorCounter.iterator().next();
                        Throwable error = errors.get(errorIdx);
                        // TODO add some logging here to indicate which policy error'd out
                        //Policy errorPolicy = policies.get(errorIdx);
                        policyErrorHandler.handle(error);
                    } else {
                        handler.handle(rval);
                    }
                }
            });
        }
    }
334408
function retrievePolicyArn(identifier, context, searchParams) {
  if (/arn:aws:iam::\d{12}:policy\/?[a-zA-Z_0-9+=,.@\-_/]+]/.test(identifier)) {
    return Promise.resolve(identifier);
  }

  // @TODO make this code more beautiful
  // Try ENV_PolicyName_stage
  let policyIdentifier = context.environment + '_' + identifier + '_' + context.stage;
  return getPolicyByName(policyIdentifier, searchParams)
  .then(policy => {
    if (!policy) {
      // Try ENV_PolicyName
      policyIdentifier = context.environment + '_' + identifier;
      return getPolicyByName(policyIdentifier, searchParams)
      .then(policy => {
        if (!policy) {
          // Try PolicyName
          return getPolicyByName(identifier, searchParams)
          .then(policy => {
            if (!policy) {
              return findAndDeployPolicy(identifier, context)
              .then(report => {
                if (!report) {
                  throw new Error('The policy ' + identifier + ' could not be found.');
                }
                return { Arn: report.arn };
              });
            }
            return policy;
          });
        }
        return policy;
      });
    }
    return policy;
  })
  .then(policy => {
    return policy.Arn;
  });
}
978707
def list_role_policies(role_name, region=None, key=None, keyid=None,
                       profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        response = conn.list_role_policies(role_name)
        _list = response.list_role_policies_response.list_role_policies_result
        return _list.policy_names
    except boto.exception.BotoServerError as e:
        log.debug(e)
        return []
21723
def list_policies(self, scaling_group):
        
        uri = "/%s/%s/policies" % (self.uri_base, utils.get_id(scaling_group))
        resp, resp_body = self.api.method_get(uri)
        return [AutoScalePolicy(self, data, scaling_group)
                for data in resp_body.get("policies", [])]
1012507
@Override
    public PolicyFinderResult findPolicy(EvaluationCtx context) {
        PolicyFinderResult policyFinderResult = null;
        PolicySet policySet = m_repositoryPolicySet;
        try {
            String pid = getPid(context);
            if (pid != null && !pid.isEmpty()) {
                AbstractPolicy objectPolicyFromObject = 
                        m_policyLoader.loadObjectPolicy(m_policyParser.copy(),
                                                         pid,
                                                         m_validateObjectPoliciesFromDatastream);
                if (objectPolicyFromObject != null) {
                    List<AbstractPolicy> policies = new ArrayList<AbstractPolicy>(m_repositoryPolicies);
                    policies.add(objectPolicyFromObject);
                    policySet = toPolicySet(policies, m_combiningAlgorithm);
                }
            }
            policyFinderResult = new PolicyFinderResult(policySet);
        } catch (Exception e) {
            logger.warn("PolicyFinderModule seriously failed to evaluate a policy ", e);
            policyFinderResult =
                    new PolicyFinderResult(new Status(ERROR_CODE_LIST, e
                            .getMessage()));
        }
        return policyFinderResult;
    }
1260096
public static policymap[] get_filtered(nitro_service service, String filter) throws Exception{
		policymap obj = new policymap();
		options option = new options();
		option.set_filter(filter);
		policymap[] response = (policymap[]) obj.getfiltered(service, option);
		return response;
	}
77989
function getChoices() {
    return {
      policyIdentifiers: () => {
        return plugin.loadPolicies()
        .then(policies => {
          // Build the list of available policies for input verification and interactive selection
          return _.map(policies, policy => {
            return {
              value: policy.name,
              name: policy.name + (policy.description ? ' - ' + policy.description : '')
            };
          });
        });
      }
    };
  }
583948
@Override
    public Map<String, AbstractPolicy> getPolicies(EvaluationCtx eval, PolicyFinder policyFinder)
    throws PolicyIndexException {
        // no indexing, return everything
        // return a copy, otherwise the map could change during evaluation if policies are added, deleted etc
        readLock.lock();
        try {
            Map<String, AbstractPolicy> result = new ConcurrentHashMap<String, AbstractPolicy>();
            for(String id:policies.keySet()){
                AbstractPolicy policy = handleDocument(m_policyReader.readPolicy(policies.get(id)),policyFinder);
                result.put(id, policy);
            }
            return result;
        }
        catch (ParsingException pe) {
            throw new PolicyIndexException(pe.getMessage(),pe);
        }finally {
            readLock.unlock();
        }
    }
648488
public static policypatset[] get(nitro_service service) throws Exception{
		policypatset obj = new policypatset();
		policypatset[] response = (policypatset[])obj.get_resources(service);
		return response;
	}
613226
def policy(self):
        """"""
        policies = VNXIOPolicy.get(cli=self._cli)
        ret = None
        for policy in policies:
            contained = policy.ioclasses.name
            if self._get_name() in contained:
                ret = VNXIOPolicy.get(name=policy.name, cli=self._cli)
                break
        return ret
1216418
def policy_definition_get(name, **kwargs):
    '''
    

    '''
    polconn = __utils__['azurearm.get_client']('policy', **kwargs)
    try:
        policy_def = polconn.policy_definitions.get(
            policy_definition_name=name
        )
        result = policy_def.as_dict()
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('resource', str(exc), **kwargs)
        result = {'error': str(exc)}

    return result
109391
def list_policies():
    '''
    
    '''
    ret = {}

    cmd = __execute_kadmin('list_policies')

    if cmd['retcode'] != 0 or cmd['stderr']:
        ret['comment'] = cmd['stderr'].splitlines()[-1]
        ret['result'] = False

        return ret

    ret = {'policies': []}

    for i in cmd['stdout'].splitlines()[1:]:
        ret['policies'].append(i)

    return ret
505129
def ha_get_delay_policy(self, config_name):
        
        config = self.ha_get_config(config_name)
        delay_policy_conf = config.delay_config
        delay_policy_conf = copy.deepcopy(delay_policy_conf)
        delay_policy_conf.update(delay=config.delay)
        return self._retry_delays_class.get(
            config.delay_policy,
            **delay_policy_conf
        )
1036014
public java.util.List<String> getPolicyNames() {
        if (policyNames == null) {
            policyNames = new com.ibm.cloud.objectstorage.internal.SdkInternalList<String>();
        }
        return policyNames;
    }
23284
function parsePlugins(config) {
  let plugins = [];

  function parse(plugins) {
    return plugins.map(plugin => {
      if ('string' == typeof plugin) plugin = path.resolve(plugin);
      return plugin;
    });
  }

  // Handle plugin paths defined in config file
  if (config.plugins) {
    plugins.push(...parse(config.plugins));
    delete config.plugins;
  }
  // Handle plugin paths/functions defined in runtime options
  if (config.runtimeOptions.plugins) {
    plugins.push(...parse(config.runtimeOptions.plugins));
    delete config.runtimeOptions.plugins;
  }

  return plugins;
}
167840
def _get_policy_object(platform,
                       filters=None,
                       pillar_key='acl',
                       pillarenv=None,
                       saltenv=None,
                       merge_pillar=True):
    '''
    
    '''
    policy = _Policy()
    policy_filters = []
    if not filters:
        filters = []
    for filter_ in filters:
        if not filter_ or not isinstance(filter_, dict):
            continue  # go to the next filter
        filter_name = filter_.keys()[0]
        filter_config = filter_.values()[0]
        header = capirca.lib.policy.Header()  # same header everywhere
        target_opts = [
            platform,
            filter_name
        ]
        filter_options = filter_config.pop('options', None)
        if filter_options:
            filter_options = _make_it_list({}, filter_name, filter_options)
            # make sure the filter options are sent as list
            target_opts.extend(filter_options)
        target = capirca.lib.policy.Target(target_opts)
        header.AddObject(target)
        filter_terms = []
        for term_ in filter_config.get('terms', []):
            if term_ and isinstance(term_, dict):
                term_name = term_.keys()[0]
                term_fields = term_.values()[0]
                term = _get_term_object(filter_name,
                                        term_name,
                                        pillar_key=pillar_key,
                                        pillarenv=pillarenv,
                                        saltenv=saltenv,
                                        merge_pillar=merge_pillar,
                                        **term_fields)
            filter_terms.append(term)
        policy_filters.append(
            (header, filter_terms)
        )
    policy.filters = policy_filters
    log.debug('Policy config:')
    log.debug(six.text_type(policy))
    platform_generator = _import_platform_generator(platform)
    policy_config = platform_generator(policy, 2)
    log.debug('Generating policy config for %s:', platform)
    log.debug(six.text_type(policy_config))
    return policy_config
1032219
private static List<ImageConfiguration> resolveConfiguration(Resolver imageResolver,
                                                                 List<ImageConfiguration> unresolvedImages) {
        List<ImageConfiguration> ret = new ArrayList<>();
        if (unresolvedImages != null) {
            for (ImageConfiguration image : unresolvedImages) {
                ret.addAll(imageResolver.resolve(image));
            }
            verifyImageNames(ret);
        }
        return ret;
    }