support for object tagging - hard to test as the IANA registry is currently empty!

parent efda8f16
......@@ -197,6 +197,34 @@ sub autnum {
}
}
=pod
=head2 Entity Lookup
$entity = $rdap->entity($handle);
This method returns a L<Net::RDAP::Object::Entity> object containing
information about the entity referenced by C<$handle> which is a string
containing a "tagged" handle, such as C<ABC123-EXAMPLE>, as per RFC
8521.
=cut
sub entity {
my ($self, $object, %args) = @_;
if ($object !~ /-/) {
return $self->error(
'errorCode' => 400,
'title' => 'argument must be a tagged handle',
);
} else {
return $self->query('object' => $object, %args);
}
}
#
# main method
#
......@@ -236,7 +264,7 @@ L<URI> or L<Net::RDAP::Link> object), and return a L<Net::RDAP::Object>
object (assuming that the server returns a valid RDAP response). This
method is used internally by C<query()> but is also available for when
you need to directly fetch a resource without using the IANA
registry, such as for nameserver or entity queries.
registry, such as for nameserver or untagged entity queries.
The third form allows the method to be called on an existing
L<Net::RDAP::Object>. Objects which are embedded inside other
......@@ -603,6 +631,9 @@ Protocol (EPP) and Registration Data Access Protocol (RDAP) Status Mapping
=item * L<https://tools.ietf.org/html/rfc8288> - Web Linking
=item * L<https://tools.ietf.org/html/rfc8521> - Registration Data Access
Protocol (RDAP) Object Tagging
=back
=head1 COPYRIGHT
......
......@@ -63,6 +63,8 @@ address range;
=item * a L<Net::DNS::Domain> object representing a domain name.
=item * a string containing a tagged entity handle
=back
This method requires objects to be passed to ensure that the resource
......@@ -84,6 +86,9 @@ sub get_url {
} elsif ('Net::DNS::Domain' eq ref($object)) {
return $package->domain($object);
} elsif ($object =~ /-/) {
return $package->entity($object);
} else {
croak("Unable to deal with '$object'");
......@@ -270,6 +275,25 @@ sub reverse_domain {
return URI->new_abs(sprintf('../../domain/%s', $domain->name), $url);
}
sub entity {
my ($package, $handle) = @_;
my @parts = split(/-/, $handle);
my $tag = pop(@parts);
my $registry = $package->load_registry('https://data.iana.org/rdap/object-tags.json');
return undef if (!$registry);
foreach my $service (@{$registry->{'services'}}) {
foreach my $value (@{$service->[0]}) {
# unlike the other registries we are only looking for an exact match as there is no hierarchy to tag
return $package->assemble_url($package->get_best_url(@{$service->[1]}), 'entity', $handle) if (lc($value) eq lc($tag));
}
}
return undef;
}
#
# load a registry. uses (in order of preference) an in-memory cache, a JSON file on disk,
# or a resource on the IANA website.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment