| 1 | package Google::Cloud::Discoveryengine::V1::RankServiceClient; | ||
| 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::Discoveryengine::V1::Completion; | ||
| 14 | use Google::Cloud::Discoveryengine::V1::Safety; | ||
| 15 | use Google::Cloud::Discoveryengine::V1::SiteSearchEngine; | ||
| 16 | use Google::Cloud::Discoveryengine::V1::AgentGatewaySetting; | ||
| 17 | use Google::Cloud::Discoveryengine::V1::UserStore; | ||
| 18 | use Google::Cloud::Discoveryengine::V1::DocumentProcessingConfig; | ||
| 19 | use Google::Cloud::Discoveryengine::V1::Chunk; | ||
| 20 | use Google::Cloud::Discoveryengine::V1::CustomTuningModel; | ||
| 21 | use Google::Cloud::Discoveryengine::V1::Grounding; | ||
| 22 | use Google::Cloud::Discoveryengine::V1::Logging; | ||
| 23 | use Google::Cloud::Discoveryengine::V1::UserLicense; | ||
| 24 | use Google::Cloud::Discoveryengine::V1::Schema; | ||
| 25 | use Google::Cloud::Discoveryengine::V1::Collection; | ||
| 26 | use Google::Cloud::Discoveryengine::V1::Common; | ||
| 27 | use Google::Cloud::Discoveryengine::V1::RankService; | ||
| 28 | use Google::Cloud::Discoveryengine::V1::CollectionService; | ||
| 29 | use Google::Cloud::Discoveryengine::V1::CmekConfigService; | ||
| 30 | use Google::Cloud::Discoveryengine::V1::Answer; | ||
| 31 | use Google::Cloud::Discoveryengine::V1::SiteSearchEngineService; | ||
| 32 | use Google::Cloud::Discoveryengine::V1::UserStoreService; | ||
| 33 | use Google::Cloud::Discoveryengine::V1::GroundedGenerationService; | ||
| 34 | use Google::Cloud::Discoveryengine::V1::Project; | ||
| 35 | use Google::Cloud::Discoveryengine::V1::UserLicenseService; | ||
| 36 | use Google::Cloud::Discoveryengine::V1::SchemaService; | ||
| 37 | use Google::Cloud::Discoveryengine::V1::Document; | ||
| 38 | use Google::Cloud::Discoveryengine::V1::Control; | ||
| 39 | use Google::Cloud::Discoveryengine::V1::LicenseConfig; | ||
| 40 | use Google::Cloud::Discoveryengine::V1::Assistant; | ||
| 41 | use Google::Cloud::Discoveryengine::V1::AclConfig; | ||
| 42 | use Google::Cloud::Discoveryengine::V1::DataConnector; | ||
| 43 | use Google::Cloud::Discoveryengine::V1::Engine; | ||
| 44 | use Google::Cloud::Discoveryengine::V1::IdentityMappingStore; | ||
| 45 | use Google::Cloud::Discoveryengine::V1::DataStore; | ||
| 46 | use Google::Cloud::Discoveryengine::V1::AssistAnswer; | ||
| 47 | use Google::Cloud::Discoveryengine::V1::ProjectService; | ||
| 48 | use Google::Cloud::Discoveryengine::V1::SearchService; | ||
| 49 | use Google::Cloud::Discoveryengine::V1::ControlService; | ||
| 50 | use Google::Cloud::Discoveryengine::V1::LicenseConfigService; | ||
| 51 | use Google::Cloud::Discoveryengine::V1::AclConfigService; | ||
| 52 | use Google::Cloud::Discoveryengine::V1::DataConnectorService; | ||
| 53 | use Google::Cloud::Discoveryengine::V1::WidgetConfig; | ||
| 54 | use Google::Cloud::Discoveryengine::V1::EngineService; | ||
| 55 | use Google::Cloud::Discoveryengine::V1::IdentityMappingStoreService; | ||
| 56 | use Google::Cloud::Discoveryengine::V1::DataStoreService; | ||
| 57 | use Google::Cloud::Discoveryengine::V1::Session; | ||
| 58 | use Google::Cloud::Discoveryengine::V1::Conversation; | ||
| 59 | use Google::Cloud::Discoveryengine::V1::ServingConfig; | ||
| 60 | use Google::Cloud::Discoveryengine::V1::WidgetConfigService; | ||
| 61 | use Google::Cloud::Discoveryengine::V1::AssistantService; | ||
| 62 | use Google::Cloud::Discoveryengine::V1::Feedback; | ||
| 63 | use Google::Cloud::Discoveryengine::V1::ConversationalSearchService; | ||
| 64 | use Google::Cloud::Discoveryengine::V1::ServingConfigService; | ||
| 65 | use Google::Cloud::Discoveryengine::V1::UserEvent; | ||
| 66 | use Google::Cloud::Discoveryengine::V1::SessionService; | ||
| 67 | use Google::Cloud::Discoveryengine::V1::ImportConfig; | ||
| 68 | use Google::Cloud::Discoveryengine::V1::RecommendationService; | ||
| 69 | use Google::Cloud::Discoveryengine::V1::PurgeConfig; | ||
| 70 | use Google::Cloud::Discoveryengine::V1::SearchTuningService; | ||
| 71 | use Google::Cloud::Discoveryengine::V1::UserEventService; | ||
| 72 | use Google::Cloud::Discoveryengine::V1::DocumentService; | ||
| 73 | use Google::Cloud::Discoveryengine::V1::CompletionService; | ||
| 74 | |||
| 75 | our $VERSION = '0.06'; | ||
| 76 | |||
| 77 | has credentials => ( is => 'ro', required => 0 ); | ||
| 78 | has transport => ( is => 'rw' ); | ||
| 79 | |||
| 80 | sub BUILD { | ||
| 81 | my ($self) = @_; | ||
| 82 | |||
| 83 | my $auth = $self->credentials; | ||
| 84 | if (!defined $auth) { | ||
| 85 | $auth = Google::Auth->default(); | ||
| 86 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 87 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 88 | } | ||
| 89 | my $token = $auth->get_token(); | ||
| 90 | |||
| 91 | my $target = 'discoveryengine.googleapis.com:443'; | ||
| 92 | my $t = $self->transport || 'grpc'; | ||
| 93 | |||
| 94 | if (ref($t) && eval { $t->can('call') }) { | ||
| 95 | # Already a transport object | ||
| 96 | } elsif (lc($t) eq 'rest') { | ||
| 97 | my $client = Google::Cloud::REST::Client->new( | ||
| 98 | target => $target, | ||
| 99 | auth_token => $token, | ||
| 100 | ); | ||
| 101 | $self->transport($client); | ||
| 102 | } else { | ||
| 103 | my $client = Google::gRPC::Client->new( | ||
| 104 | target => $target, | ||
| 105 | auth_token => $token, | ||
| 106 | ); | ||
| 107 | $self->transport($client); | ||
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | sub rank { | ||
| 112 | my ($self, %params) = @_; | ||
| 113 | |||
| 114 | my $request_class = 'Google::Cloud::Discoveryengine::V1::RankService::RankRequest'; | ||
| 115 | my $request = eval { $request_class->new(\%params) }; | ||
| 116 | my $new_err = $@; | ||
| 117 | if (!$request) { | ||
| 118 | $request = eval { $request_class->new(%params) }; | ||
| 119 | $new_err ||= $@; | ||
| 120 | } | ||
| 121 | if (!$request) { | ||
| 122 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 123 | } | ||
| 124 | |||
| 125 | my $response_class = 'Google::Cloud::Discoveryengine::V1::RankService::RankResponse'; | ||
| 126 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 127 | return $self->transport->call({ | ||
| 128 | http_method => 'POST', | ||
| 129 | path => '/google.cloud.discoveryengine.v1.RankService/Rank', | ||
| 130 | request => $request, | ||
| 131 | response_class => $response_class, | ||
| 132 | }); | ||
| 133 | } | ||
| 134 | |||
| 135 | my $response = $self->transport->call({ | ||
| 136 | service => 'google.cloud.discoveryengine.v1.RankService', | ||
| 137 | method => 'Rank', | ||
| 138 | request => $request, | ||
| 139 | response_class => $response_class, | ||
| 140 | }); | ||
| 141 | |||
| 142 | return $response; | ||
| 143 | } | ||
| 144 | 1; # End of Google::Cloud::Discoveryengine::V1::RankServiceClient | ||
| 145 | |||
| 146 | __END__ | ||