V3beta1/AgentsClient.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
« V3beta1.pm ↑ Summary V3beta1/ChangelogsClient.pm »
1 package Google::Cloud::Dialogflow::Cx::V3beta1::AgentsClient;
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::Dialogflow::Cx::V3beta1::ValidationMessage;
14 use Google::Cloud::Dialogflow::Cx::V3beta1::BigqueryExport;
15 use Google::Cloud::Dialogflow::Cx::V3beta1::ImportStrategy;
16 use Google::Cloud::Dialogflow::Cx::V3beta1::Gcs;
17 use Google::Cloud::Dialogflow::Cx::V3beta1::ParameterDefinition;
18 use Google::Cloud::Dialogflow::Cx::V3beta1::SafetySettings;
19 use Google::Cloud::Dialogflow::Cx::V3beta1::CodeBlock;
20 use Google::Cloud::Dialogflow::Cx::V3beta1::Inline;
21 use Google::Cloud::Dialogflow::Cx::V3beta1::DataStoreConnection;
22 use Google::Cloud::Dialogflow::Cx::V3beta1::AudioConfig;
23 use Google::Cloud::Dialogflow::Cx::V3beta1::Deployment;
24 use Google::Cloud::Dialogflow::Cx::V3beta1::Changelog;
25 use Google::Cloud::Dialogflow::Cx::V3beta1::SecuritySettings;
26 use Google::Cloud::Dialogflow::Cx::V3beta1::ToolCall;
27 use Google::Cloud::Dialogflow::Cx::V3beta1::Experiment;
28 use Google::Cloud::Dialogflow::Cx::V3beta1::AdvancedSettings;
29 use Google::Cloud::Dialogflow::Cx::V3beta1::GenerativeSettings;
30 use Google::Cloud::Dialogflow::Cx::V3beta1::Intent;
31 use Google::Cloud::Dialogflow::Cx::V3beta1::EntityType;
32 use Google::Cloud::Dialogflow::Cx::V3beta1::Trace;
33 use Google::Cloud::Dialogflow::Cx::V3beta1::Tool;
34 use Google::Cloud::Dialogflow::Cx::V3beta1::ResponseMessage;
35 use Google::Cloud::Dialogflow::Cx::V3beta1::Generator;
36 use Google::Cloud::Dialogflow::Cx::V3beta1::SessionEntityType;
37 use Google::Cloud::Dialogflow::Cx::V3beta1::Example;
38 use Google::Cloud::Dialogflow::Cx::V3beta1::Fulfillment;
39 use Google::Cloud::Dialogflow::Cx::V3beta1::Webhook;
40 use Google::Cloud::Dialogflow::Cx::V3beta1::Page;
41 use Google::Cloud::Dialogflow::Cx::V3beta1::Playbook;
42 use Google::Cloud::Dialogflow::Cx::V3beta1::Flow;
43 use Google::Cloud::Dialogflow::Cx::V3beta1::TransitionRouteGroup;
44 use Google::Cloud::Dialogflow::Cx::V3beta1::Session;
45 use Google::Cloud::Dialogflow::Cx::V3beta1::Version;
46 use Google::Cloud::Dialogflow::Cx::V3beta1::Agent;
47 use Google::Cloud::Dialogflow::Cx::V3beta1::TestCase;
48 use Google::Cloud::Dialogflow::Cx::V3beta1::Environment;
49 use Google::Cloud::Dialogflow::Cx::V3beta1::ConversationHistory;
50  
51 our $VERSION = '0.06';
52  
53 has credentials => ( is => 'ro', required => 0 );
54 has transport => ( is => 'rw' );
55  
56 sub BUILD {
57 my ($self) = @_;
58  
59 my $auth = $self->credentials;
60 if (!defined $auth) {
61 $auth = Google::Auth->default();
62 } elsif (!eval { $auth->can('get_token') }) {
63 croak 'Invalid credentials object: must implement get_token()';
64 }
65 my $token = $auth->get_token();
66  
67 my $target = 'dialogflow.googleapis.com:443';
68 my $t = $self->transport || 'grpc';
69  
70 if (ref($t) && eval { $t->can('call') }) {
71 # Already a transport object
72 } elsif (lc($t) eq 'rest') {
73 my $client = Google::Cloud::REST::Client->new(
74 target => $target,
75 auth_token => $token,
76 );
77 $self->transport($client);
78 } else {
79 my $client = Google::gRPC::Client->new(
80 target => $target,
81 auth_token => $token,
82 );
83 $self->transport($client);
84 }
85 }
86  
87 sub list_agents {
88 my ($self, %params) = @_;
89  
90 my $request_class = 'Google::Cloud::Dialogflow::Cx::V3beta1::Agent::ListAgentsRequest';
91 my $request = eval { $request_class->new(\%params) };
92 my $new_err = $@;
93 if (!$request) {
94 $request = eval { $request_class->new(%params) };
95 $new_err ||= $@;
96 }
97 if (!$request) {
98 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
99 }
100  
101 my $response_class = 'Google::Cloud::Dialogflow::Cx::V3beta1::Agent::ListAgentsResponse';
102 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
103 return $self->transport->call({
104 http_method => 'POST',
105 path => '/google.cloud.dialogflow.cx.v3beta1.Agents/ListAgents',
106 request => $request,
107 response_class => $response_class,
108 });
109 }
110  
111 my $response = $self->transport->call({
112 service => 'google.cloud.dialogflow.cx.v3beta1.Agents',
113 method => 'ListAgents',
114 request => $request,
115 response_class => $response_class,
116 });
117  
118 return $response;
119 }
120  
121 sub get_generative_settings {
122 my ($self, %params) = @_;
123  
124 my $request_class = 'Google::Cloud::Dialogflow::Cx::V3beta1::Agent::GetGenerativeSettingsRequest';
125 my $request = eval { $request_class->new(\%params) };
126 my $new_err = $@;
127 if (!$request) {
128 $request = eval { $request_class->new(%params) };
129 $new_err ||= $@;
130 }
131 if (!$request) {
132 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
133 }
134  
135 my $response_class = 'Google::Cloud::Dialogflow::Cx::V3beta1::GenerativeSettings::GenerativeSettings';
136 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
137 return $self->transport->call({
138 http_method => 'POST',
139 path => '/google.cloud.dialogflow.cx.v3beta1.Agents/GetGenerativeSettings',
140 request => $request,
141 response_class => $response_class,
142 });
143 }
144  
145 my $response = $self->transport->call({
146 service => 'google.cloud.dialogflow.cx.v3beta1.Agents',
147 method => 'GetGenerativeSettings',
148 request => $request,
149 response_class => $response_class,
150 });
151  
152 return $response;
153 }
154 1; # End of Google::Cloud::Dialogflow::Cx::V3beta1::AgentsClient
155  
156 __END__
« V3beta1.pm ↑ Summary V3beta1/ChangelogsClient.pm »