| 1 | package Google::Cloud::Retail::V2alpha::ProjectServiceClient; | ||
| 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::Retail::V2alpha::Promotion; | ||
| 14 | use Google::Cloud::Retail::V2alpha::GenerativeQuestion; | ||
| 15 | use Google::Cloud::Retail::V2alpha::Safety; | ||
| 16 | use Google::Cloud::Retail::V2alpha::Common; | ||
| 17 | use Google::Cloud::Retail::V2alpha::PurgeConfig; | ||
| 18 | use Google::Cloud::Retail::V2alpha::MerchantCenterAccountLink; | ||
| 19 | use Google::Cloud::Retail::V2alpha::ExportConfig; | ||
| 20 | use Google::Cloud::Retail::V2alpha::GenerativeQuestionService; | ||
| 21 | use Google::Cloud::Retail::V2alpha::Project; | ||
| 22 | use Google::Cloud::Retail::V2alpha::Model; | ||
| 23 | use Google::Cloud::Retail::V2alpha::Product; | ||
| 24 | use Google::Cloud::Retail::V2alpha::MerchantCenterAccountLinkService; | ||
| 25 | use Google::Cloud::Retail::V2alpha::AnalyticsService; | ||
| 26 | use Google::Cloud::Retail::V2alpha::ProjectService; | ||
| 27 | use Google::Cloud::Retail::V2alpha::ModelService; | ||
| 28 | use Google::Cloud::Retail::V2alpha::SearchService; | ||
| 29 | use Google::Cloud::Retail::V2alpha::Branch; | ||
| 30 | use Google::Cloud::Retail::V2alpha::UserEvent; | ||
| 31 | use Google::Cloud::Retail::V2alpha::ConversationalSearchService; | ||
| 32 | use Google::Cloud::Retail::V2alpha::ServingConfig; | ||
| 33 | use Google::Cloud::Retail::V2alpha::Control; | ||
| 34 | use Google::Cloud::Retail::V2alpha::BranchService; | ||
| 35 | use Google::Cloud::Retail::V2alpha::PredictionService; | ||
| 36 | use Google::Cloud::Retail::V2alpha::ImportConfig; | ||
| 37 | use Google::Cloud::Retail::V2alpha::ServingConfigService; | ||
| 38 | use Google::Cloud::Retail::V2alpha::ControlService; | ||
| 39 | use Google::Cloud::Retail::V2alpha::CompletionService; | ||
| 40 | use Google::Cloud::Retail::V2alpha::ProductService; | ||
| 41 | use Google::Cloud::Retail::V2alpha::Catalog; | ||
| 42 | use Google::Cloud::Retail::V2alpha::UserEventService; | ||
| 43 | use Google::Cloud::Retail::V2alpha::CatalogService; | ||
| 44 | |||
| 45 | our $VERSION = '0.06'; | ||
| 46 | |||
| 47 | has credentials => ( is => 'ro', required => 0 ); | ||
| 48 | has transport => ( is => 'rw' ); | ||
| 49 | |||
| 50 | sub BUILD { | ||
| 51 | my ($self) = @_; | ||
| 52 | |||
| 53 | my $auth = $self->credentials; | ||
| 54 | if (!defined $auth) { | ||
| 55 | $auth = Google::Auth->default(); | ||
| 56 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 57 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 58 | } | ||
| 59 | my $token = $auth->get_token(); | ||
| 60 | |||
| 61 | my $target = 'retail.googleapis.com:443'; | ||
| 62 | my $t = $self->transport || 'grpc'; | ||
| 63 | |||
| 64 | if (ref($t) && eval { $t->can('call') }) { | ||
| 65 | # Already a transport object | ||
| 66 | } elsif (lc($t) eq 'rest') { | ||
| 67 | my $client = Google::Cloud::REST::Client->new( | ||
| 68 | target => $target, | ||
| 69 | auth_token => $token, | ||
| 70 | ); | ||
| 71 | $self->transport($client); | ||
| 72 | } else { | ||
| 73 | my $client = Google::gRPC::Client->new( | ||
| 74 | target => $target, | ||
| 75 | auth_token => $token, | ||
| 76 | ); | ||
| 77 | $self->transport($client); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | sub get_project { | ||
| 82 | my ($self, %params) = @_; | ||
| 83 | |||
| 84 | my $request_class = 'Google::Cloud::Retail::V2alpha::ProjectService::GetProjectRequest'; | ||
| 85 | my $request = eval { $request_class->new(\%params) }; | ||
| 86 | my $new_err = $@; | ||
| 87 | if (!$request) { | ||
| 88 | $request = eval { $request_class->new(%params) }; | ||
| 89 | $new_err ||= $@; | ||
| 90 | } | ||
| 91 | if (!$request) { | ||
| 92 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 93 | } | ||
| 94 | |||
| 95 | my $response_class = 'Google::Cloud::Retail::V2alpha::Project::Project'; | ||
| 96 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 97 | return $self->transport->call({ | ||
| 98 | http_method => 'POST', | ||
| 99 | path => '/google.cloud.retail.v2alpha.ProjectService/GetProject', | ||
| 100 | request => $request, | ||
| 101 | response_class => $response_class, | ||
| 102 | }); | ||
| 103 | } | ||
| 104 | |||
| 105 | my $response = $self->transport->call({ | ||
| 106 | service => 'google.cloud.retail.v2alpha.ProjectService', | ||
| 107 | method => 'GetProject', | ||
| 108 | request => $request, | ||
| 109 | response_class => $response_class, | ||
| 110 | }); | ||
| 111 | |||
| 112 | return $response; | ||
| 113 | } | ||
| 114 | |||
| 115 | sub enroll_solution { | ||
| 116 | my ($self, %params) = @_; | ||
| 117 | |||
| 118 | my $request_class = 'Google::Cloud::Retail::V2alpha::ProjectService::EnrollSolutionRequest'; | ||
| 119 | my $request = eval { $request_class->new(\%params) }; | ||
| 120 | my $new_err = $@; | ||
| 121 | if (!$request) { | ||
| 122 | $request = eval { $request_class->new(%params) }; | ||
| 123 | $new_err ||= $@; | ||
| 124 | } | ||
| 125 | if (!$request) { | ||
| 126 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 127 | } | ||
| 128 | |||
| 129 | my $response_class = 'Google::Longrunning::Operations::Operation'; | ||
| 130 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 131 | return $self->transport->call({ | ||
| 132 | http_method => 'POST', | ||
| 133 | path => '/google.cloud.retail.v2alpha.ProjectService/EnrollSolution', | ||
| 134 | request => $request, | ||
| 135 | response_class => $response_class, | ||
| 136 | }); | ||
| 137 | } | ||
| 138 | |||
| 139 | my $response = $self->transport->call({ | ||
| 140 | service => 'google.cloud.retail.v2alpha.ProjectService', | ||
| 141 | method => 'EnrollSolution', | ||
| 142 | request => $request, | ||
| 143 | response_class => $response_class, | ||
| 144 | }); | ||
| 145 | |||
| 146 | return $response; | ||
| 147 | } | ||
| 148 | |||
| 149 | sub update_logging_config { | ||
| 150 | my ($self, %params) = @_; | ||
| 151 | |||
| 152 | my $request_class = 'Google::Cloud::Retail::V2alpha::ProjectService::UpdateLoggingConfigRequest'; | ||
| 153 | my $request = eval { $request_class->new(\%params) }; | ||
| 154 | my $new_err = $@; | ||
| 155 | if (!$request) { | ||
| 156 | $request = eval { $request_class->new(%params) }; | ||
| 157 | $new_err ||= $@; | ||
| 158 | } | ||
| 159 | if (!$request) { | ||
| 160 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 161 | } | ||
| 162 | |||
| 163 | my $response_class = 'Google::Cloud::Retail::V2alpha::Project::LoggingConfig'; | ||
| 164 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 165 | return $self->transport->call({ | ||
| 166 | http_method => 'POST', | ||
| 167 | path => '/google.cloud.retail.v2alpha.ProjectService/UpdateLoggingConfig', | ||
| 168 | request => $request, | ||
| 169 | response_class => $response_class, | ||
| 170 | }); | ||
| 171 | } | ||
| 172 | |||
| 173 | my $response = $self->transport->call({ | ||
| 174 | service => 'google.cloud.retail.v2alpha.ProjectService', | ||
| 175 | method => 'UpdateLoggingConfig', | ||
| 176 | request => $request, | ||
| 177 | response_class => $response_class, | ||
| 178 | }); | ||
| 179 | |||
| 180 | return $response; | ||
| 181 | } | ||
| 182 | |||
| 183 | sub update_alert_config { | ||
| 184 | my ($self, %params) = @_; | ||
| 185 | |||
| 186 | my $request_class = 'Google::Cloud::Retail::V2alpha::ProjectService::UpdateAlertConfigRequest'; | ||
| 187 | my $request = eval { $request_class->new(\%params) }; | ||
| 188 | my $new_err = $@; | ||
| 189 | if (!$request) { | ||
| 190 | $request = eval { $request_class->new(%params) }; | ||
| 191 | $new_err ||= $@; | ||
| 192 | } | ||
| 193 | if (!$request) { | ||
| 194 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 195 | } | ||
| 196 | |||
| 197 | my $response_class = 'Google::Cloud::Retail::V2alpha::Project::AlertConfig'; | ||
| 198 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 199 | return $self->transport->call({ | ||
| 200 | http_method => 'POST', | ||
| 201 | path => '/google.cloud.retail.v2alpha.ProjectService/UpdateAlertConfig', | ||
| 202 | request => $request, | ||
| 203 | response_class => $response_class, | ||
| 204 | }); | ||
| 205 | } | ||
| 206 | |||
| 207 | my $response = $self->transport->call({ | ||
| 208 | service => 'google.cloud.retail.v2alpha.ProjectService', | ||
| 209 | method => 'UpdateAlertConfig', | ||
| 210 | request => $request, | ||
| 211 | response_class => $response_class, | ||
| 212 | }); | ||
| 213 | |||
| 214 | return $response; | ||
| 215 | } | ||
| 216 | 1; # End of Google::Cloud::Retail::V2alpha::ProjectServiceClient | ||
| 217 | |||
| 218 | __END__ | ||