Add policy.

@param name   the name
@param policy the policy
519337
public void addPolicy(final String name, final ExpirationPolicy policy) {
        LOGGER.trace("Adding expiration policy [{}] with name [{}]", policy, name);
        this.policies.put(name, policy);
    }
413483
public function addFilter(string $name, string $filter): void{
        $this->filters[$name] = $filter;
    }
59933
public AcceptableUsagePolicyStatus addProperty(final String name, final Object value) {
        this.properties.put(name, value);
        return this;
    }
1349935
@Override
    public boolean updatePolicy(String name, String newDocument)
    throws PolicyIndexException {

        writeLock.lock();
        try {
            logger.debug("Updating policy named: " + name);
            if (doDelete(name)) {
                doAdd(name, newDocument);
                return true;
            } else {
                // delete failed
                return false;
            }
        } finally {
            writeLock.unlock();
        }
    }
783305
def set_policy(self, policy, headers=None):
        
        response = self.connection.make_request('PUT', self.name,
                                                data=policy,
                                                query_args='policy',
                                                headers=headers)
        body = response.read()
        if response.status >= 200 and response.status <= 204:
            return True
        else:
            raise self.connection.provider.storage_response_error(
                response.status, response.reason, body)
292232
def policy(name, options = {}, &block)
      p = Sprinkle::Policy.new(name, options, &block)
      POLICIES << p
      p
    end
515374
public void addActivationName(String name)
    {
        if (sealed) onSealedMutation();
        if (activationNames == null)
            activationNames = new HashSet<String>();
        activationNames.add(name);
    }
36657
@Override
    public AbstractPolicy getPolicy(String name, PolicyFinder policyFinder) throws PolicyIndexException {
        readLock.lock();
        try {
            logger.debug("Getting policy named: " + name);
            if (policies.containsKey(name)) {
                return handleDocument(m_policyReader.readPolicy(policies.get(name)), policyFinder);
            } else {
                throw new PolicyIndexException("Attempting to get non-existent policy " + name);
            }
        } catch (ParsingException pe) {
            throw new PolicyIndexException(pe.getMessage(),pe);
        } finally {
            readLock.unlock();
        }
    }
1006806
public void setPolicyAttributes(java.util.Collection<PolicyAttribute> policyAttributes) {
        if (policyAttributes == null) {
            this.policyAttributes = null;
            return;
        }

        this.policyAttributes = new com.amazonaws.internal.SdkInternalList<PolicyAttribute>(policyAttributes);
    }
904051
function Policy(document, name, pathPrefix) {
  this.document = document;
  this.name = name;
  this.pathPrefix = pathPrefix || '/';
}
1137447
public function addRule($name, callable $rule)
    {
        if (isset($this[self::rule($name)])) {
            throw new \RuntimeException("rule '$name' already exists'");
        }
        $this[self::rule($name)] = $this->protect($rule);
    }
595978
public static Set<Policy> policy(BasicSettings settings, String name) {
    Function<Config, Set<Policy>> factory = FACTORIES.get(name.toLowerCase(US));
    checkNotNull(factory, "%s not found", name);
    return factory.apply(settings.config());
  }
760071
public final void setUndoManagerPolicy(UndoManagerPolicy policy) throws NullPointerException {
		if (policy == null) {
			throw new NullPointerException("The policy must not be null.");
		}
		
		if (this.policy == policy) {
			return;
		}

		final UndoManagerPolicy oldPolicy = this.policy;
		this.policy = policy;
		
		if (oldPolicy == UndoManagerPolicy.DEFAULT) {
			this.textComponent.removePropertyChangeListener("editable", this);
			this.textComponent.removePropertyChangeListener("enabled", this);
		}

		if (this.policy == UndoManagerPolicy.DEFAULT) {
			this.textComponent.addPropertyChangeListener("editable", this);
			this.textComponent.addPropertyChangeListener("enabled", this);
		}

		handleUndoManagerPolicy();
	}
877839
def add_policy(self, scaling_group, name, policy_type, cooldown,
            change=None, is_percent=False, desired_capacity=None, args=None):
        
        uri = "/%s/%s/policies" % (self.uri_base, utils.get_id(scaling_group))
        body = self._create_policy_body(name, policy_type, cooldown,
                change=change, is_percent=is_percent,
                desired_capacity=desired_capacity, args=args)
        # "body" needs to be a list
        body = [body]
        resp, resp_body = self.api.method_post(uri, body=body)
        pol_info = resp_body.get("policies")[0]
        return AutoScalePolicy(self, pol_info, scaling_group)
446233
public function setPolicy(string $policy)
    {
        // allow (all is deny, allow part) | deny (all is allow, deny part) | none (all is allow, ignore part)
        if (!in_array($policy, [self::POLICY_NONE, self::POLICY_ALLOW, self::POLICY_DENY])) {
            throw new Exception('Unsupported policy type: ' . $policy);
        }
        $this->policy = $policy;

        $this->init();   // init data after set policy (in extension)!
    }
24472
public void addParameter( String name, String value )
    {
        if ( _additionalParameters == null )
        {
            _additionalParameters = new HashMap();
        }
        
        _additionalParameters.put( name, value );
    }
672320
def build_role(self, name, policies=False):
        
        # Build role template
        if policies:
            role = self.__template.add_resource(
                Role(
                    self.name_strip(name),
                    AssumeRolePolicyDocument=Policy(
                        Version=self.VERSION_IAM,
                        Statement=[
                            Statement(
                                Effect=Allow,
                                Principal=Principal(
                                    "Service", self.__role_principals
                                ),
                                Action=[AssumeRole],
                            )
                        ]
                    ),
                    Path=self.__role_path,
                    ManagedPolicyArns=policies,
                ))
            # Add role to list for default policy
            self.__roles_list.append(troposphere.Ref(role))
        else:
            role = self.__template.add_resource(
                Role(
                    self.name_strip(name),
                    AssumeRolePolicyDocument=Policy(
                        Version=self.VERSION_IAM,
                        Statement=[
                            Statement(
                                Effect=Allow,
                                Principal=Principal(
                                    "Service", self.__role_principals
                                ),
                                Action=[AssumeRole],
                            )
                        ]
                    ),
                    Path=self.__role_path,
                ))
            # Add role to list for default policy
            self.__roles_list.append(troposphere.Ref(role))

        return role