V1beta1.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« V1beta1/Domains/Types.pm ↑ Summary V1beta1/DomainsClient.pm »
1 package Google::Cloud::Domains::V1beta1;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 0 ▶use Google::gRPC::Client;
Subroutine BEGIN: called CC=1 SCAR=2.6
7 use Google::Cloud::REST::Client;
8 use Google::Auth;
9 use Carp qw(croak);
10  
11 use Protobuf;
12 use Google::Api::Common;
13 use Google::Cloud::Domains::V1beta1::Domains;
14  
15 our $VERSION = '0.06';
16  
17 has credentials => ( is => 'ro', required => 0 );
18 has transport => ( is => 'rw' );
19  
20 sub BUILD {
21 my ($self) = @_;
22  
23 my $auth = $self->credentials;
24 if (!defined $auth) {
25 $auth = Google::Auth->default();
26 } elsif (!eval { $auth->can('get_token') }) {
27 croak 'Invalid credentials object: must implement get_token()';
28 }
29 my $token = $auth->get_token();
30  
31 my $target = 'domains.googleapis.com:443';
32 my $t = $self->transport || 'grpc';
33  
34 if (ref($t) && eval { $t->can('call') }) {
35 # Already a transport object
36 } elsif (lc($t) eq 'rest') {
37 my $client = Google::Cloud::REST::Client->new(
38 target => $target,
39 auth_token => $token,
40 );
41 $self->transport($client);
42 } else {
43 my $client = Google::gRPC::Client->new(
44 target => $target,
45 auth_token => $token,
46 );
47 $self->transport($client);
48 }
49 }
50  
51 sub search_domains {
52 my ($self, %params) = @_;
53  
54 my $request_class = 'Google::Cloud::Domains::V1beta1::Domains::SearchDomainsRequest';
55 my $request = eval { $request_class->new(\%params) };
56 my $new_err = $@;
57 if (!$request) {
58 $request = eval { $request_class->new(%params) };
59 $new_err ||= $@;
60 }
61 if (!$request) {
62 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
63 }
64  
65 my $response_class = 'Google::Cloud::Domains::V1beta1::Domains::SearchDomainsResponse';
66 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
67 return $self->transport->call({
68 http_method => 'POST',
69 path => '/google.cloud.domains.v1beta1.Domains/SearchDomains',
70 request => $request,
71 response_class => $response_class,
72 });
73 }
74  
75 my $response = $self->transport->call({
76 service => 'google.cloud.domains.v1beta1.Domains',
77 method => 'SearchDomains',
78 request => $request,
79 response_class => $response_class,
80 });
81  
82 return $response;
83 }
84 1; # End of Google::Cloud::Domains::V1beta1
85  
86 __END__
« V1beta1/Domains/Types.pm ↑ Summary V1beta1/DomainsClient.pm »