static function RegionList(Rage4Api $api, $cache = true) { if ($cache && self::$cache) { return self::$cache; } $ret = array(); foreach ($api->getGeoRegions() as $g) { $ret[$g['name']] = (int) $g['value']; } self::$cache = $ret; return $ret; }
/** * @param CreatedDomain $domain * @param Rage4Api $api * @return CreatedRecord * @throws Rage4Exception */ function create(CreatedDomain $domain, Rage4Api $api) { $ret = $api->createRecord($domain->id, $this->name, $this->content, $this->type, $this->priority, $this->failover, $this->failovercontent, $this->ttl, $this->geo, $this->geolat, $this->geolong); $id = null; if (is_string($ret)) { throw new Rage4Exception("Failed to create record: " . $this->name . ' error: ' . $ret); } if (!is_array($ret)) { throw new Rage4Exception("Failed to create record: " . $this->name); } $id = $ret['id']; return $this->_created($id); }
/** * @param Rage4Api $api * @param bool $cache * @return CreatedRecord[] */ function get_records(Rage4Api $api, $cache = false) { if ($cache && $this->record_cache !== null) { return $this->record_cache; } $records = array(); $ret = $api->getRecords($this->id); foreach ($ret as $r) { $records[] = CreatedRecord::fromRage4($r); } if ($cache) { $this->record_cache = $records; } return $records; }
/** * Delete record at Rage4.com * * @param Rage4Api $api */ function delete(Rage4Api $api) { $api->deleteRecord($this->id); }
/** * Get a domain by id from Rage4 * * @param Rage4Api $api * @param integer $id * @return null|CreatedDomain * @throws Rage4Exception */ static function fromId(Rage4Api $api, $id) { $ret = $api->getDomain($id); if (is_string($ret)) { throw new Rage4Exception($ret); } if (!$ret) { return null; } return new CreatedDomain($ret['name'], $ret['type'], $ret['owner_email'], $ret['id']); }