/**
  * @param Service|ServiceGroup $s
  * @param bool $rewritexml
  * @param bool $forceAny
  * @return bool
  */
 public function API_remove($s, $rewritexml = true, $forceAny = false)
 {
     $xpath = null;
     if (!$s->isTmpSrv()) {
         $xpath = $s->getXPath();
     }
     $ret = $this->remove($s, $rewritexml, $forceAny);
     if ($ret && !$s->isTmpSrv()) {
         $con = findConnectorOrDie($this);
         $con->sendDeleteRequest($xpath);
     }
     return $ret;
 }
 public function API_addTag($Obj, $rewriteXML = true)
 {
     if ($this->addTag($Obj, $rewriteXML)) {
         $con = findConnectorOrDie($this);
         $con->sendSetRequest($this->getXPath(), '<member>' . $Obj->name() . '</member>');
         return true;
     }
     return false;
 }
 /**
  * Creates a new Address Group named '$name' . Will exit with error if a group with that
  * name already exists
  * @param $name string
  * @return AddressGroup
  **/
 public function API_newAddressGroup($name)
 {
     $found = $this->find($name, null, true);
     if ($found !== null) {
         derr("cannot create AddressGroup named '" . $name . "' as this name is already in use");
     }
     $newObject = $this->newAddressGroup($name);
     $con = findConnectorOrDie($this);
     $xpath = $newObject->getXPath();
     $con->sendSetRequest($xpath, $newObject, true);
     return $newObject;
 }
 /**
  * @param string $newName
  */
 public function API_setName($newName)
 {
     $c = findConnectorOrDie($this);
     $path = $this->getXPath();
     $url = "type=config&action=rename&xpath={$path}&newname={$newName}";
     $c->sendRequest($url);
     $this->setName($newName);
 }
 public function API_setName($newname)
 {
     $con = findConnectorOrDie($this);
     $xpath = $this->getXPath();
     $con->sendRenameRequest($xpath, $newname);
     $this->setName($newname);
 }
 function API_createTag($name, $ref = null)
 {
     $newTag = $this->createTag($name, $ref);
     if (!$newTag->isTmp()) {
         $xpath = $this->getXPath();
         $con = findConnectorOrDie($this);
         $element = $newTag->getXmlText_inline();
         $con->sendSetRequest($xpath, $element);
     }
     return $newTag;
 }
 public function API_sync()
 {
     $xpath = DH::elementToPanXPath($this->xmlroot);
     $con = findConnectorOrDie($this);
     $con->sendEditRequest($xpath, $this->getXmlText_inline());
 }
 public function &API_getServiceStats($timePeriod, $specificApps = null)
 {
     $con = findConnectorOrDie($this);
     $query_appfilter = '';
     if (!is_null($specificApps)) {
         if (!is_array($specificApps)) {
             if (is_string($specificApps)) {
                 $specificApps = explode(',', $specificApps);
             } else {
                 derr('$specificApps is not an array or a string');
             }
         }
         $query_appfilter = ' and (';
         $first = true;
         foreach ($specificApps as &$app) {
             if (!$first) {
                 $query_appfilter .= ' or ';
             } else {
                 $first = false;
             }
             $query_appfilter .= "(app eq {$app})";
         }
         $query_appfilter .= ') ';
     }
     $parentClass = get_class($this->owner->owner);
     if ($parentClass == 'VirtualSystem') {
         $type = 'traffic';
         $dvq = '(vsys eq ' . $this->owner->owner->name() . ')';
     } else {
         $type = 'panorama-traffic';
         $devices = $this->owner->owner->getDevicesInGroup();
         //print_r($devices);
         $first = true;
         if (count($devices) == 0) {
             derr('cannot request rule stats for a device group that has no member');
         }
         $dvq = '(' . array_to_devicequery($devices) . ')';
     }
     $query = 'type=report&reporttype=dynamic&reportname=custom-dynamic-report&cmd=<type>' . '<' . $type . '><aggregate-by><member>proto</member><member>dport</member></aggregate-by>' . '</' . $type . '></type><period>' . $timePeriod . '</period>' . '<topn>100</topn><topm>500</topm><caption>untitled</caption>' . '<query>' . "{$dvq} {$query_appfilter} and (rule eq '" . $this->name . "')</query>";
     $ret = $con->getReport($query);
     return $ret;
 }
 public function API_setName($newname)
 {
     if (!$this->isTmp()) {
         $c = findConnectorOrDie($this);
         $path = $this->getXPath();
         $c->sendRenameRequest($path, $newname);
     } else {
         mwarning('this is a temporary object, cannot be renamed from API');
     }
     $this->setName($newname);
 }
 /**
  * Removes a rule from this store (must be passed an object, not string/name). Returns TRUE if found.
  * @param Rule $rule
  * @return bool
  */
 public function API_remove($rule)
 {
     $xpath = $rule->getXPath();
     $ret = $this->remove($rule);
     if ($ret) {
         $con = findConnectorOrDie($this);
         $con->sendDeleteRequest($xpath);
     }
     return $ret;
 }
 public function API_delete()
 {
     $connector = findConnectorOrDie($this);
     $xpath = $this->getXPath();
     $connector->sendDeleteRequest($xpath);
 }
 /**
  * @param bool $yes
  * @return bool
  */
 public function API_setDestinationIsNegated($yes)
 {
     $ret = $this->setDestinationIsNegated($yes);
     if ($ret) {
         $con = findConnectorOrDie($this);
         $con->sendSetRequest($this->getXPath(), '<negate-destination>' . boolYesNo($yes) . '</negate-destination>');
     }
     return $ret;
 }
 public function API_setAny()
 {
     $this->setAny();
     $xpath =& $this->getXPath();
     $con = findConnectorOrDie($this);
     $url = "type=config&action=delete&xpath=" . $xpath;
     $con->sendRequest($url);
     $url = "type=config&action=set&xpath={$xpath}&element=<member>any</member>";
     $con->sendRequest($url);
 }