V1alpha/DataChatServiceClient.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
« V1alpha/DataAgentServiceClient.pm ↑ Summary
1 package Google::Cloud::Geminidataanalytics::V1alpha::DataChatServiceClient;
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::Geminidataanalytics::V1alpha::Usage;
14 use Google::Cloud::Geminidataanalytics::V1alpha::AgentContext;
15 use Google::Cloud::Geminidataanalytics::V1alpha::Credentials;
16 use Google::Cloud::Geminidataanalytics::V1alpha::Conversation;
17 use Google::Cloud::Geminidataanalytics::V1alpha::Datasource;
18 use Google::Cloud::Geminidataanalytics::V1alpha::Context;
19 use Google::Cloud::Geminidataanalytics::V1alpha::DataChatService;
20 use Google::Cloud::Geminidataanalytics::V1alpha::DataAnalyticsAgent;
21 use Google::Cloud::Geminidataanalytics::V1alpha::DataAgent;
22 use Google::Cloud::Geminidataanalytics::V1alpha::DataAgentService;
23  
24 our $VERSION = '0.06';
25  
26 has credentials => ( is => 'ro', required => 0 );
27 has transport => ( is => 'rw' );
28  
29 sub BUILD {
30 my ($self) = @_;
31  
32 my $auth = $self->credentials;
33 if (!defined $auth) {
34 $auth = Google::Auth->default();
35 } elsif (!eval { $auth->can('get_token') }) {
36 croak 'Invalid credentials object: must implement get_token()';
37 }
38 my $token = $auth->get_token();
39  
40 my $target = 'geminidataanalytics.googleapis.com:443';
41 my $t = $self->transport || 'grpc';
42  
43 if (ref($t) && eval { $t->can('call') }) {
44 # Already a transport object
45 } elsif (lc($t) eq 'rest') {
46 my $client = Google::Cloud::REST::Client->new(
47 target => $target,
48 auth_token => $token,
49 );
50 $self->transport($client);
51 } else {
52 my $client = Google::gRPC::Client->new(
53 target => $target,
54 auth_token => $token,
55 );
56 $self->transport($client);
57 }
58 }
59  
60 sub chat {
61 my ($self, %params) = @_;
62  
63 my $request_class = 'Google::Cloud::Geminidataanalytics::V1alpha::DataChatService::ChatRequest';
64 my $request = eval { $request_class->new(\%params) };
65 my $new_err = $@;
66 if (!$request) {
67 $request = eval { $request_class->new(%params) };
68 $new_err ||= $@;
69 }
70 if (!$request) {
71 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
72 }
73  
74 my $response_class = 'Google::Cloud::Geminidataanalytics::V1alpha::DataChatService::Message';
75 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
76 return $self->transport->call({
77 http_method => 'POST',
78 path => '/google.cloud.geminidataanalytics.v1alpha.DataChatService/Chat',
79 request => $request,
80 response_class => $response_class,
81 });
82 }
83  
84 my $response = $self->transport->call({
85 service => 'google.cloud.geminidataanalytics.v1alpha.DataChatService',
86 method => 'Chat',
87 request => $request,
88 response_class => $response_class,
89 });
90  
91 return $response;
92 }
93 1; # End of Google::Cloud::Geminidataanalytics::V1alpha::DataChatServiceClient
94  
95 __END__
« V1alpha/DataAgentServiceClient.pm ↑ Summary