| 1 | package Google::Cloud::Ces::V1beta::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::V1beta::GoldenRun; | ||
| 14 | use Google::Cloud::Ces::V1beta::SearchSuggestions; | ||
| 15 | use Google::Cloud::Ces::V1beta::GoogleSearchTool; | ||
| 16 | use Google::Cloud::Ces::V1beta::FileSearchTool; | ||
| 17 | use Google::Cloud::Ces::V1beta::SystemTool; | ||
| 18 | use Google::Cloud::Ces::V1beta::EvaluationMetricsConfig; | ||
| 19 | use Google::Cloud::Ces::V1beta::FileContext; | ||
| 20 | use Google::Cloud::Ces::V1beta::Fakes; | ||
| 21 | use Google::Cloud::Ces::V1beta::BigqueryExport; | ||
| 22 | use Google::Cloud::Ces::V1beta::Schema; | ||
| 23 | use Google::Cloud::Ces::V1beta::AgentTool; | ||
| 24 | use Google::Cloud::Ces::V1beta::AgentTransfers; | ||
| 25 | use Google::Cloud::Ces::V1beta::Auth; | ||
| 26 | use Google::Cloud::Ces::V1beta::ToolsetTool; | ||
| 27 | use Google::Cloud::Ces::V1beta::SecuritySettings; | ||
| 28 | use Google::Cloud::Ces::V1beta::Omnichannel; | ||
| 29 | use Google::Cloud::Ces::V1beta::WidgetService; | ||
| 30 | use Google::Cloud::Ces::V1beta::OmnichannelService; | ||
| 31 | use Google::Cloud::Ces::V1beta::Common; | ||
| 32 | use Google::Cloud::Ces::V1beta::Changelog; | ||
| 33 | use Google::Cloud::Ces::V1beta::DataStore; | ||
| 34 | use Google::Cloud::Ces::V1beta::ClientFunction; | ||
| 35 | use Google::Cloud::Ces::V1beta::AgentCard; | ||
| 36 | use Google::Cloud::Ces::V1beta::ConnectorTool; | ||
| 37 | use Google::Cloud::Ces::V1beta::Example; | ||
| 38 | use Google::Cloud::Ces::V1beta::Mocks; | ||
| 39 | use Google::Cloud::Ces::V1beta::McpToolset; | ||
| 40 | use Google::Cloud::Ces::V1beta::OpenApiTool; | ||
| 41 | use Google::Cloud::Ces::V1beta::OpenApiToolset; | ||
| 42 | use Google::Cloud::Ces::V1beta::Guardrail; | ||
| 43 | use Google::Cloud::Ces::V1beta::App; | ||
| 44 | use Google::Cloud::Ces::V1beta::PythonFunction; | ||
| 45 | use Google::Cloud::Ces::V1beta::Deployment; | ||
| 46 | use Google::Cloud::Ces::V1beta::McpTool; | ||
| 47 | use Google::Cloud::Ces::V1beta::AssistantService; | ||
| 48 | use Google::Cloud::Ces::V1beta::DataStoreTool; | ||
| 49 | use Google::Cloud::Ces::V1beta::Agent; | ||
| 50 | use Google::Cloud::Ces::V1beta::ConnectorToolset; | ||
| 51 | use Google::Cloud::Ces::V1beta::Conversation; | ||
| 52 | use Google::Cloud::Ces::V1beta::SessionService; | ||
| 53 | use Google::Cloud::Ces::V1beta::WidgetTool; | ||
| 54 | use Google::Cloud::Ces::V1beta::Toolset; | ||
| 55 | use Google::Cloud::Ces::V1beta::Evaluation; | ||
| 56 | use Google::Cloud::Ces::V1beta::Tool; | ||
| 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 run_session { | ||
| 99 | my ($self, %params) = @_; | ||
| 100 | |||
| 101 | my $request_class = 'Google::Cloud::Ces::V1beta::SessionService::RunSessionRequest'; | ||
| 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::SessionService::RunSessionResponse'; | ||
| 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.SessionService/RunSession', | ||
| 117 | request => $request, | ||
| 118 | response_class => $response_class, | ||
| 119 | }); | ||
| 120 | } | ||
| 121 | |||
| 122 | my $response = $self->transport->call({ | ||
| 123 | service => 'google.cloud.ces.v1beta.SessionService', | ||
| 124 | method => 'RunSession', | ||
| 125 | request => $request, | ||
| 126 | response_class => $response_class, | ||
| 127 | }); | ||
| 128 | |||
| 129 | return $response; | ||
| 130 | } | ||
| 131 | 1; # End of Google::Cloud::Ces::V1beta::SessionServiceClient | ||
| 132 | |||
| 133 | __END__ | ||