code: def create_policy_for_vhost(
              self, vhost, name,
              definition,
              pattern=None,
              priority=0,
              apply_to='all'):
          
          data = {
              "pattern": pattern,
              "definition": definition,
              "priority": priority,
              "apply-to": apply_to
          }
          self._api_put(
              '/api/policies/{0}/{1}'.format(
                  urllib.parse.quote_plus(vhost),
                  urllib.parse.quote_plus(name),
              ),
              data=data,
          )
docs: Create a policy for a vhost.
  
          :param vhost: The virtual host the policy is for
          :type vhost: str
          :param name: The name of the policy
          :type name: str
  
          :param definition: The definition of the policy. Required
          :type definition: dict
          :param priority: The priority of the policy. Defaults to 0
          :param pattern: The pattern of resource names to apply the policy to
          :type pattern: str
          :type priority: int
          :param apply_to: What resource type to apply the policy to.
              Usually "exchanges", "queues", or "all". Defaults to "all"
          :type apply_to: str
  
          Example ::
  
              # Makes all queues and exchanges on vhost "/" highly available
              >>> api.create_policy_for_vhost(
              ... vhost="/",
              ... name="ha-all",
              ... definition={"ha-mode": "all"},
              ... pattern="",
              ... apply_to="all")