Доброго времени суток!
Есть база данных следующей структуры:
MariaDB [pdns]> SELECT * FROM domains;
+-----+--------------------+--------+------------+--------+-----------------+---------+
| id | name | master | last_check | type | notified_serial | account |
+-----+--------------------+--------+------------+--------+-----------------+---------+
| 106 | mnc001.mcc400.gprs | | NULL | MASTER | 2006022801 | NULL |
| 107 | localhost | | NULL | MASTER | 2005020801 | NULL |
+-----+--------------------+--------+------------+--------+-----------------+---------+
2 rows in set (0.00 sec)
MariaDB [pdns]> SELECT * FROM records;
+------+-----------+----------------------+-------+------------------------------------------------------------------------------------------+------+------+-------------+----------+-----------+------+
| id | domain_id | name | type | content | ttl | prio | change_date | disabled | ordername | auth |
+------+-----------+----------------------+-------+------------------------------------------------------------------------------------------+------+------+-------------+----------+-----------+------+
| 1906 | 106 | mnc001.mcc400.gprs | SOA | idns1.mnc001.mcc400.gprs. admin.mnc001.mcc400.gprs. 2006022801 43200 1800 3456000 432000 | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1907 | 106 | mnc001.mcc400.gprs | NS | idns1.mnc001.mcc400.gprs | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1908 | 106 | *.mnc001.mcc400.gprs | A | 192.168.123.123 | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1909 | 106 | mnc001.mcc400.gprs | NS | idns2.mnc001.mcc400.gprs | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1910 | 107 | localhost | SOA | idns1.mnc001.mcc400.gprs. admin.mnc001.mcc400.gprs. 2005020801 86400 7200 3600000 172800 | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1911 | 107 | localhost | NS | idns1.mnc001.mcc400.gprs | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1912 | 107 | localhost | A | 127.0.0.1 | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1913 | 107 | localhost.localhost | CNAME | localhost | 3600 | 0 | NULL | 0 | NULL | 1 |
| 1914 | 107 | localhost | NS | idns2.mnc001.mcc400.gprs | 3600 | 0 | NULL | 0 | NULL | 1 |
+------+-----------+----------------------+-------+------------------------------------------------------------------------------------------+------+------+-------------+----------+-----------+------+
9 rows in set (0.00 sec)
пытаюсь получить запись из таблицы records с типом CNAME через скрипт perl :
use JSON;
use LWP::UserAgent;
use Data::Dumper;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(
GET => "http://127.0.0.1:8081/servers/localhost/zones/localhost",
['X-API-Key' => 'aaa123']
);
$req->content('["type":"CNAME"]');
print Dumper($req). "\n";
my $res = $ua->request($req);
my $content = $res->content;
print "$content\n\n";
print "\n------------------------------\n";
print Dumper($res). "\n\n";
print "\n=----------------------------=\n";
print $req->as_string(),"\n";
print "\n=----------------------------=\n";
print $res->as_string(),"\n"; но в результате получаю данные о всей зоне DNS:
$VAR1 = bless( {
'_content' => '["type":"CNAME"]',
'_uri' => bless( do{\(my $o = '
http://127.0.0.1:8081/servers/localhost/zones/localhost')}, 'URI::http' ),
'_headers' => bless( {
'x-api-key' => 'aaa123',
'::std_case' => {
'x-api-key' => 'X-API-Key'
}
}, 'HTTP::Headers' ),
'_method' => 'GET'
}, 'HTTP::Request' );
{"id":"localhost.","url":"/servers/localhost/zones/localhost.","name":"localhost","kind":"Master","dnssec":false,"account":"","masters":[],"serial":2005020801,"notified_serial":2005020801,"last_check":0,"soa_edit_api":"","soa_edit":"","records":[{"name":"localhost","type":"A","ttl":3600,"disabled":false,"content":"127.0.0.1"},{"name":"localhost","type":"NS","ttl":3600,"disabled":false,"content":"idns1.mnc001.mcc400.gprs"},{"name":"localhost","type":"NS","ttl":3600,"disabled":false,"content":"idns2.mnc001.mcc400.gprs"},{"name":"localhost","type":"SOA","ttl":3600,"disabled":false,"content":"idns1.mnc001.mcc400.gprs. admin.mnc001.mcc400.gprs. 2005020801 86400 7200 3600000 172800"},{"name":"localhost.localhost","type":"CNAME","ttl":3600,"disabled":false,"content":"localhost"}],"comments":[]}
------------------------------
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '{"id":"localhost.","url":"/servers/localhost/zones/localhost.","name":"localhost","kind":"Master","dnssec":false,"account":"","masters":[],"serial":2005020801,"notified_serial":2005020801,"last_check":0,"soa_edit_api":"","soa_edit":"","records":[{"name":"localhost","type":"A","ttl":3600,"disabled":false,"content":"127.0.0.1"},{"name":"localhost","type":"NS","ttl":3600,"disabled":false,"content":"idns1.mnc001.mcc400.gprs"},{"name":"localhost","type":"NS","ttl":3600,"disabled":false,"content":"idns2.mnc001.mcc400.gprs"},{"name":"localhost","type":"SOA","ttl":3600,"disabled":false,"content":"idns1.mnc001.mcc400.gprs. admin.mnc001.mcc400.gprs. 2005020801 86400 7200 3600000 172800"},{"name":"localhost.localhost","type":"CNAME","ttl":3600,"disabled":false,"content":"localhost"}],"comments":[]}',
'_rc' => '200',
'_headers' => bless( {
'connection' => 'close',
'client-response-num' => 1,
'access-control-allow-origin' => '*',
'client-peer' => '127.0.0.1:8081',
'content-length' => '798',
'::std_case' => {
'client-date' => 'Client-Date',
'client-response-num' => 'Client-Response-Num',
'access-control-allow-origin' => 'Access-Control-Allow-Origin',
'client-transfer-encoding' => 'Client-Transfer-Encoding',
'client-peer' => 'Client-Peer'
},
'client-date' => 'Tue, 01 Sep 2015 13:49:10 GMT',
'content-type' => 'application/json',
'client-transfer-encoding' => [
'chunked'
],
'server' => 'PowerDNS/3.4.5'
}, 'HTTP::Headers' ),
'_msg' => 'OK',
'_request' => bless( {
'_content' => '["type":"CNAME"]',
'_uri' => bless( do{\(my $o = '
http://127.0.0.1:8081/servers/localhost/zones/localhost')}, 'URI::http' ),
'_headers' => bless( {
'user-agent' => 'libwww-perl/6.05',
'x-api-key' => 'aaa123',
'::std_case' => {
'x-api-key' => 'X-API-Key'
}
}, 'HTTP::Headers' ),
'_method' => 'GET',
'_uri_canonical' => $VAR1->{'_request'}{'_uri'}
}, 'HTTP::Request' )
}, 'HTTP::Response' );
=----------------------------=
GET
http://127.0.0.1:8081/servers/localhost/zones/localhostUser-Agent: libwww-perl/6.05
X-API-Key: aaa123
["type":"CNAME"]
=----------------------------=
HTTP/1.1 200 OK
Connection: close
Server: PowerDNS/3.4.5
Content-Length: 798
Content-Type: application/json
Access-Control-Allow-Origin: *
Client-Date: Tue, 01 Sep 2015 13:49:10 GMT
Client-Peer: 127.0.0.1:8081
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
{"id":"localhost.","url":"/servers/localhost/zones/localhost.","name":"localhost","kind":"Master","dnssec":false,"account":"","masters":[],"serial":2005020801,"notified_serial":2005020801,"last_check":0,"soa_edit_api":"","soa_edit":"","records":[{"name":"localhost","type":"A","ttl":3600,"disabled":false,"content":"127.0.0.1"},{"name":"localhost","type":"NS","ttl":3600,"disabled":false,"content":"idns1.mnc001.mcc400.gprs"},{"name":"localhost","type":"NS","ttl":3600,"disabled":false,"content":"idns2.mnc001.mcc400.gprs"},{"name":"localhost","type":"SOA","ttl":3600,"disabled":false,"content":"idns1.mnc001.mcc400.gprs. admin.mnc001.mcc400.gprs. 2005020801 86400 7200 3600000 172800"},{"name":"localhost.localhost","type":"CNAME","ttl":3600,"disabled":false,"content":"localhost"}],"comments":[]}
Уважаемые знатоки!
как правильно поменять контент в запросе, чтобы получить только строчки с CNAME?