Skip to content

Commit 221da76

Browse files
author
GomoR
committed
- new: client: add support for calculated field Search API parameter
1 parent 7e7fb76 commit 221da76

7 files changed

Lines changed: 28 additions & 11 deletions

File tree

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Revision history for Perl extension Metabrik::Client::Onyphe.
22

3+
3.02 Tue 13 Sep 11:28:31 CEST 2022
4+
- new: support for calculated fields in Search API
5+
36
3.01 Wed 20 Apr 15:18:29 CEST 2022
47
- bugfix: avoid auto-paging on non-existent pages by using _maxpage internal value
58
- new function: flat

META.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"provides" : {
3131
"Metabrik::Api::Onyphe" : {
3232
"file" : "lib/Metabrik/Api/Onyphe.pm",
33-
"version" : "3.01"
33+
"version" : "3.02"
3434
},
3535
"Metabrik::Client::Onyphe" : {
3636
"file" : "lib/Metabrik/Client/Onyphe.pm",
37-
"version" : "3.01"
37+
"version" : "3.02"
3838
},
3939
"Metabrik::Client::Onyphe::Function" : {
4040
"file" : "lib/Metabrik/Client/Onyphe/Function.pm",
41-
"version" : "3.01"
41+
"version" : "3.02"
4242
},
4343
"Metabrik::Client::Onyphe::Function::Addcount" : {
4444
"file" : "lib/Metabrik/Client/Onyphe/Function/Addcount.pm"
@@ -119,6 +119,6 @@
119119
"http://opensource.org/licenses/BSD-3-Clause"
120120
]
121121
},
122-
"version" : "3.01",
122+
"version" : "3.02",
123123
"x_serialization_backend" : "JSON::PP version 4.02"
124124
}

META.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ name: Metabrik-Client-Onyphe
1515
provides:
1616
Metabrik::Api::Onyphe:
1717
file: lib/Metabrik/Api/Onyphe.pm
18-
version: '3.01'
18+
version: '3.02'
1919
Metabrik::Client::Onyphe:
2020
file: lib/Metabrik/Client/Onyphe.pm
21-
version: '3.01'
21+
version: '3.02'
2222
Metabrik::Client::Onyphe::Function:
2323
file: lib/Metabrik/Client/Onyphe/Function.pm
24-
version: '3.01'
24+
version: '3.02'
2525
Metabrik::Client::Onyphe::Function::Addcount:
2626
file: lib/Metabrik/Client/Onyphe/Function/Addcount.pm
2727
Metabrik::Client::Onyphe::Function::Allowlist:
@@ -76,5 +76,5 @@ requires:
7676
perl: v5.6.1
7777
resources:
7878
license: http://opensource.org/licenses/BSD-3-Clause
79-
version: '3.01'
79+
version: '3.02'
8080
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

bin/onyphe

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ my %lopts = (
2020
maxpage => 1,
2121
apiurl => 'https://www.onyphe.io/api/v2',
2222
apitrackquery => 0,
23+
apicalculated => 0,
2324
apikeepalive => 0,
2425
wait => 1,
2526
# API options:
@@ -39,6 +40,7 @@ GetOptions(
3940
"apikey=s" => \$lopts{apikey}, # -apikey YOUR_APIKEY
4041
"apisize=i" => \$lopts{apisize}, # -apisize 100
4142
"apitrackquery=i" => \$lopts{apitrackquery}, # -apitrackquery 1
43+
"apicalculated=i" => \$lopts{apicalculated}, # -apicalculated 1
4244
"apikeepalive=i" => \$lopts{apikeepalive}, # -apikeelalive 1
4345
"wait=i" => \$lopts{wait}, # -wait 3
4446
# API options:
@@ -83,6 +85,7 @@ $cli->apiurl($lopts{apiurl});
8385
$cli->apikey($lopts{apikey});
8486
$cli->apisize($lopts{apisize});
8587
$cli->apitrackquery($lopts{apitrackquery});
88+
$cli->apicalculated($lopts{apicalculated});
8689
$cli->apikeepalive($lopts{apikeepalive});
8790
$cli->wait($lopts{wait});
8891

@@ -145,6 +148,7 @@ General options:
145148
-apiurl <URL> use another URL endpoint for API calls
146149
-apikey <APIKEY> your personal ONYPHE API key
147150
-apitrackquery <0|1> add trackquery field into results (default: 0)
151+
-apicalculated <0|1> add calculated fields into results (default: 0)
148152
-apikeepalive <0|1> use a keepalive message (default: 0)
149153
150154
API options:

lib/Metabrik/Api/Onyphe.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package Metabrik::Api::Onyphe;
77
use strict;
88
use warnings;
99

10-
our $VERSION = '3.01';
10+
our $VERSION = '3.02';
1111

1212
use base qw(Metabrik::Client::Rest);
1313

lib/Metabrik/Client/Onyphe.pm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package Metabrik::Client::Onyphe;
55
use strict;
66
use warnings;
77

8-
our $VERSION = '3.01';
8+
our $VERSION = '3.02';
99

1010
use base qw(Metabrik);
1111

@@ -24,6 +24,7 @@ sub brik_properties {
2424
apikey => [ qw(key) ],
2525
apisize => [ qw(size) ],
2626
apitrackquery => [ qw(0|1) ],
27+
apicalculated => [ qw(0|1) ],
2728
apikeepalive => [ qw(0|1) ],
2829
wait => [ qw(seconds) ],
2930
# API options:
@@ -146,6 +147,7 @@ sub search {
146147

147148
my $apiargs = [];
148149
push @$apiargs, { trackquery => 'true' } if $self->apitrackquery;
150+
push @$apiargs, { calculated => 'true' } if $self->apicalculated;
149151
push @$apiargs, { size => $self->apisize } if $self->apisize;
150152

151153
for my $page (1..$maxpage) {
@@ -178,6 +180,7 @@ sub export {
178180
my $apiargs = [];
179181
#push @$apiargs, { keepalive => 'true' } if $self->apikeepalive; # Not supported
180182
#push @$apiargs, { trackquery => 'true' } if $self->apitrackquery; # Not supported
183+
#push @$apiargs, { calculated => 'true' } if $self->apicalculated; # Not supported
181184
push @$apiargs, { size => $self->apisize } if $self->apisize;
182185

183186
return $self->ao->export($oql, $apiargs, $self->callback, $opl);
@@ -205,6 +208,7 @@ sub simple {
205208
my $apiargs = [];
206209
push @$apiargs, { keepalive => 'true' } if $self->apikeepalive;
207210
push @$apiargs, { trackquery => 'true' } if $self->apitrackquery;
211+
#push @$apiargs, { calculated => 'true' } if $self->apicalculated; # Not supported
208212
push @$apiargs, { size => $self->apisize } if $self->apisize;
209213
return $self->best
210214
? $self->ao->bulk_simple_best($oql, $category, $apiargs, $self->callback, $opl)
@@ -238,6 +242,7 @@ sub summary {
238242
my $apiargs = [];
239243
push @$apiargs, { keepalive => 'true' } if $self->apikeepalive;
240244
push @$apiargs, { trackquery => 'true' } if $self->apitrackquery;
245+
#push @$apiargs, { calculated => 'true' } if $self->apicalculated; # Not supported
241246
push @$apiargs, { size => $self->apisize } if $self->apisize;
242247
return $self->ao->bulk_summary($oql, $type, $apiargs, $self->callback, $opl);
243248
}
@@ -263,6 +268,7 @@ sub discovery {
263268
my $apiargs = [];
264269
push @$apiargs, { keepalive => 'true' } if $self->apikeepalive;
265270
push @$apiargs, { trackquery => 'true' } if $self->apitrackquery;
271+
#push @$apiargs, { calculated => 'true' } if $self->apicalculated; # Not supported
266272
push @$apiargs, { size => $self->apisize } if $self->apisize;
267273

268274
return $self->ao->bulk_discovery($oql, $category, $apiargs, $self->callback, $opl);
@@ -536,6 +542,10 @@ Number of results to return per page. Default: 10.
536542
537543
Activate track query mode: it will add a trackquery field to results. Default: 0.
538544
545+
=item B<apicalculated> (0|1)
546+
547+
Activate calculated fields mode: it will add a calculated field to results. Default: 0.
548+
539549
=item B<apikeepalive> (0|1)
540550
541551
Activate keep alive mode: it will print some dummy results on API calls when nothing has been rendered to support long running API calls. Default: 0.

lib/Metabrik/Client/Onyphe/Function.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package Metabrik::Client::Onyphe::Function;
55
use strict;
66
use warnings;
77

8-
our $VERSION = '3.01';
8+
our $VERSION = '3.02';
99

1010
use base qw(Metabrik::Client::Onyphe);
1111

0 commit comments

Comments
 (0)