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