V1beta/AssistantServiceClient.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
« V1beta/AgentServiceClient.pm ↑ Summary V1beta/EvaluationServiceClient.pm »
1 package Google::Cloud::Ces::V1beta::AssistantServiceClient;
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::Ces::V1beta::SearchSuggestions;
14 use Google::Cloud::Ces::V1beta::GoldenRun;
15 use Google::Cloud::Ces::V1beta::AgentTool;
16 use Google::Cloud::Ces::V1beta::SecuritySettings;
17 use Google::Cloud::Ces::V1beta::GoogleSearchTool;
18 use Google::Cloud::Ces::V1beta::Omnichannel;
19 use Google::Cloud::Ces::V1beta::AgentTransfers;
20 use Google::Cloud::Ces::V1beta::FileSearchTool;
21 use Google::Cloud::Ces::V1beta::WidgetService;
22 use Google::Cloud::Ces::V1beta::OmnichannelService;
23 use Google::Cloud::Ces::V1beta::SystemTool;
24 use Google::Cloud::Ces::V1beta::Changelog;
25 use Google::Cloud::Ces::V1beta::Auth;
26 use Google::Cloud::Ces::V1beta::Schema;
27 use Google::Cloud::Ces::V1beta::Common;
28 use Google::Cloud::Ces::V1beta::FileContext;
29 use Google::Cloud::Ces::V1beta::Fakes;
30 use Google::Cloud::Ces::V1beta::EvaluationMetricsConfig;
31 use Google::Cloud::Ces::V1beta::ToolsetTool;
32 use Google::Cloud::Ces::V1beta::BigqueryExport;
33 use Google::Cloud::Ces::V1beta::DataStore;
34 use Google::Cloud::Ces::V1beta::ConnectorTool;
35 use Google::Cloud::Ces::V1beta::AgentCard;
36 use Google::Cloud::Ces::V1beta::ClientFunction;
37 use Google::Cloud::Ces::V1beta::McpToolset;
38 use Google::Cloud::Ces::V1beta::OpenApiToolset;
39 use Google::Cloud::Ces::V1beta::OpenApiTool;
40 use Google::Cloud::Ces::V1beta::Guardrail;
41 use Google::Cloud::Ces::V1beta::Deployment;
42 use Google::Cloud::Ces::V1beta::PythonFunction;
43 use Google::Cloud::Ces::V1beta::AssistantService;
44 use Google::Cloud::Ces::V1beta::McpTool;
45 use Google::Cloud::Ces::V1beta::Example;
46 use Google::Cloud::Ces::V1beta::Mocks;
47 use Google::Cloud::Ces::V1beta::App;
48 use Google::Cloud::Ces::V1beta::DataStoreTool;
49 use Google::Cloud::Ces::V1beta::ConnectorToolset;
50 use Google::Cloud::Ces::V1beta::Agent;
51 use Google::Cloud::Ces::V1beta::WidgetTool;
52 use Google::Cloud::Ces::V1beta::Conversation;
53 use Google::Cloud::Ces::V1beta::SessionService;
54 use Google::Cloud::Ces::V1beta::Toolset;
55 use Google::Cloud::Ces::V1beta::Tool;
56 use Google::Cloud::Ces::V1beta::Evaluation;
57 use Google::Cloud::Ces::V1beta::ToolService;
58 use Google::Cloud::Ces::V1beta::AppVersion;
59 use Google::Cloud::Ces::V1beta::AgentService;
60 use Google::Cloud::Ces::V1beta::EvaluationService;
61  
62 our $VERSION = '0.06';
63  
64 has credentials => ( is => 'ro', required => 0 );
65 has transport => ( is => 'rw' );
66  
67 sub BUILD {
68 my ($self) = @_;
69  
70 my $auth = $self->credentials;
71 if (!defined $auth) {
72 $auth = Google::Auth->default();
73 } elsif (!eval { $auth->can('get_token') }) {
74 croak 'Invalid credentials object: must implement get_token()';
75 }
76 my $token = $auth->get_token();
77  
78 my $target = 'ces.googleapis.com:443';
79 my $t = $self->transport || 'grpc';
80  
81 if (ref($t) && eval { $t->can('call') }) {
82 # Already a transport object
83 } elsif (lc($t) eq 'rest') {
84 my $client = Google::Cloud::REST::Client->new(
85 target => $target,
86 auth_token => $token,
87 );
88 $self->transport($client);
89 } else {
90 my $client = Google::gRPC::Client->new(
91 target => $target,
92 auth_token => $token,
93 );
94 $self->transport($client);
95 }
96 }
97  
98 sub list_assistant_sessions {
99 my ($self, %params) = @_;
100  
101 my $request_class = 'Google::Cloud::Ces::V1beta::AssistantService::ListAssistantSessionsRequest';
102 my $request = eval { $request_class->new(\%params) };
103 my $new_err = $@;
104 if (!$request) {
105 $request = eval { $request_class->new(%params) };
106 $new_err ||= $@;
107 }
108 if (!$request) {
109 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
110 }
111  
112 my $response_class = 'Google::Cloud::Ces::V1beta::AssistantService::ListAssistantSessionsResponse';
113 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
114 return $self->transport->call({
115 http_method => 'POST',
116 path => '/google.cloud.ces.v1beta.AssistantService/ListAssistantSessions',
117 request => $request,
118 response_class => $response_class,
119 });
120 }
121  
122 my $response = $self->transport->call({
123 service => 'google.cloud.ces.v1beta.AssistantService',
124 method => 'ListAssistantSessions',
125 request => $request,
126 response_class => $response_class,
127 });
128  
129 return $response;
130 }
131 1; # End of Google::Cloud::Ces::V1beta::AssistantServiceClient
132  
133 __END__
« V1beta/AgentServiceClient.pm ↑ Summary V1beta/EvaluationServiceClient.pm »