@example Request syntax with placeholder values

   user.policies()
 @param [Hash] options ({})
 @return [UserPolicy::Collection]
550286
def policies(options = {})
      batches = Enumerator.new do |y|
        options = options.merge(user_name: @name)
        resp = @client.list_user_policies(options)
        resp.each_page do |page|
          batch = []
          page.data.policy_names.each do |p|
            batch << UserPolicy.new(
              user_name: @name,
              name: p,
              client: @client
            )
          end
          y.yield(batch)
        end
      end
      UserPolicy::Collection.new(batches)
    end
440655
def options
      map = Artifactory::Configurable.keys.map do |key|
        [key, instance_variable_get(:"@#{key}")]
      end
      Hash[map]
    end
573344
def users(options={query: {}})
      url = url_for_path(user_path)
      url = append_query_params(url, options)
      client.get(url, options) do |response|
        a_hash = parse(response)
        Resource::Page.from_coach a_hash, Resource::User
      end
    end
667728
def _make_policies(self):
        
        self.policies = [AutoScalePolicy(self.manager, dct, self)
                for dct in self.scalingPolicies]
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;
  });
}
292232
def policy(name, options = {}, &block)
      p = Sprinkle::Policy.new(name, options, &block)
      POLICIES << p
      p
    end
917954
protected function accept_and_revoke_policies() {
        global $USER;

        if ($this->isexistinguser) {
            // Existing user.
            if (!empty($this->action) && confirm_sesskey()) {
                // The form has been sent, update policies acceptances.
                $lang = current_language();
                // Accept / revoke policies.
                $acceptversionids = [];
                $declineversionids = [];

                foreach ($this->policies as $policy) {
                    if (in_array($policy->id, $this->listdocs)) {
                        if (in_array($policy->id, $this->agreedocs)) {
                            $acceptversionids[] = $policy->id;
                        } else if (in_array($policy->id, $this->declinedocs)) {
                            $declineversionids[] = $policy->id;
                        } else {
                            // If the policy was displayed but not answered, revoke the eventually given acceptance.
                            api::revoke_acceptance($policy->id, $this->behalfid);
                        }
                    }
                }

                api::accept_policies($acceptversionids, $this->behalfid, null, $lang);
                api::decline_policies($declineversionids, $this->behalfid, null, $lang);

                // Show a message to let know the user he/she must agree all the policies.
                if ((count($acceptversionids) + count($declineversionids)) != count($this->policies)) {
                    $message = (object) [
                        'type' => 'error',
                        'text' => get_string('mustagreetocontinue', 'tool_policy')
                    ];
                } else {
                    $message = (object) [
                        'type' => 'success',
                        'text' => get_string('acceptancessavedsucessfully', 'tool_policy')
                    ];
                }
                $this->messages[] = $message;
            } else if (!empty($this->policies) && empty($USER->policyagreed)) {
                // Inform users they must agree to all policies before continuing.
                $message = (object) [
                    'type' => 'error',
                    'text' => get_string('mustagreetocontinue', 'tool_policy')
                ];
                $this->messages[] = $message;
            }
        } else {
            // New user.
            if (!empty($this->action) && confirm_sesskey()) {
                $currentpolicyversionids = [];
                $presignupcache = \cache::make('core', 'presignup');
                $acceptances = $presignupcache->get('tool_policy_policyversionidsagreed');
                if (!$acceptances) {
                    $acceptances = [];
                }
                foreach ($this->policies as $policy) {
                    $currentpolicyversionids[] = $policy->id;
                    if (in_array($policy->id, $this->listdocs)) {
                        if (in_array($policy->id, $this->agreedocs)) {
                            $acceptances[] = $policy->id;
                        } else {
                            $acceptances = array_values(array_diff($acceptances, [$policy->id]));
                        }
                    }
                }
                // If the user has accepted all the policies, add it to the session to let continue with the signup process.
                $this->signupuserpolicyagreed = empty(array_diff($currentpolicyversionids, $acceptances));
                $presignupcache->set('tool_policy_userpolicyagreed', $this->signupuserpolicyagreed);
                $presignupcache->set('tool_policy_policyversionidsagreed', $acceptances);
            } else if (empty($this->policies)) {
                // There are no policies to agree to. Update the policyagreed value to avoid show empty consent page.
                \cache::make('core', 'presignup')->set('tool_policy_userpolicyagreed', 1);
            }
            if (!empty($this->policies) && !$this->signupuserpolicyagreed) {
                // During the signup process, inform users they must agree to all policies before continuing.
                $message = (object) [
                    'type' => 'error',
                    'text' => get_string('mustagreetocontinue', 'tool_policy')
                ];
                $this->messages[] = $message;
            }
        }
    }
1154219
def options
      map = Config.class_variables.map do |key|
        [key.to_s.tr('@', '').to_sym, class_variable_get(:"#{key}")]
      end
      Hash[map]
    end
170848
def select(self, names):
        """"""
        return PolicyCollection(
            [p for p in self.policies if p.name in names], self.options)
1302564
def delete(options = {})
      options = options.merge(
        group_name: @group_name,
        policy_name: @name
      )
      resp = @client.delete_group_policy(options)
      resp.data
    end
700640
def policy_exists(vhost, name, runas=None):
    '''
    
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    policies = list_policies(runas=runas)
    return bool(vhost in policies and name in policies[vhost])
557653
function replaceUserPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId, policies } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, organizationId, policies }, validationRules.replaceUserPolicies, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = id
          job.organizationId = organizationId
          job.policies = utils.preparePolicies(policies)

          next()
        },
        checkUserOrg,
        clearUserPolicies
      ]

      if (policies.length > 0) {
        tasks.push((job, next) => {
          utils.checkPoliciesOrg(job.client, job.policies, job.organizationId, next)
        })
        tasks.push(insertUserPolicies)
      }

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)

        userOps.readUser({ id, organizationId }, cb)
      })

      return promise
    }
452679
function(options) {
    var user = options.user.email || options.user.username
    return [
      'User', user, 'is not permitted to', options.method, options.model.name
    ].join(' ');
  }
694821
def options
      accepted_options.each_with_object({}) do |option_name, options|
        option_value         = send(option_name)
        options[option_name] = option_value unless option_value.nil?
      end
    end
83478
protected function callPolicyMethod($policy, $method, $user, array $arguments)
    {
        // If this first argument is a string, that means they are passing a class name
        // to the policy. We will remove the first argument from this argument array
        // because this policy already knows what type of models it can authorize.
        if (isset($arguments[0]) && is_string($arguments[0])) {
            array_shift($arguments);
        }

        if (! is_callable([$policy, $method])) {
            return;
        }

        if ($this->canBeCalledWithUser($user, $policy, $method)) {
            return $policy->{$method}($user, ...$arguments);
        }
    }
763567
def options_policy(skip_invalid, warn_on_skip):
    
    settings = (Options.skip_invalid, Options.warn_on_skip)
    (Options.skip_invalid, Options.warn_on_skip) = (skip_invalid, warn_on_skip)
    yield
    (Options.skip_invalid, Options.warn_on_skip) = settings
381036
def roles_for (user)
      user ||= Authorization.current_user
      raise AuthorizationUsageError, "User object doesn't respond to roles (#{user.inspect})" \
        if !user.respond_to?(:role_symbols) and !user.respond_to?(:roles)

      Rails.logger.info("The use of user.roles is deprecated.  Please add a method " +
          "role_symbols to your User model.") if defined?(Rails) and Rails.respond_to?(:logger) and !user.respond_to?(:role_symbols)

      roles = user.respond_to?(:role_symbols) ? user.role_symbols : user.roles

      raise AuthorizationUsageError, "User.#{user.respond_to?(:role_symbols) ? 'role_symbols' : 'roles'} " +
        "doesn't return an Array of Symbols (#{roles.inspect})" \
            if !roles.is_a?(Array) or (!roles.empty? and !roles[0].is_a?(Symbol))

      (roles.empty? ? [Authorization.default_role] : roles)
    end