| 1 | package Google::Cloud::Retail::V2beta::CatalogServiceClient; | ||
| 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::V2beta::Promotion; | ||
| 14 | use Google::Cloud::Retail::V2beta::ExportConfig; | ||
| 15 | use Google::Cloud::Retail::V2beta::Project; | ||
| 16 | use Google::Cloud::Retail::V2beta::Safety; | ||
| 17 | use Google::Cloud::Retail::V2beta::Common; | ||
| 18 | use Google::Cloud::Retail::V2beta::PurgeConfig; | ||
| 19 | use Google::Cloud::Retail::V2beta::GenerativeQuestion; | ||
| 20 | use Google::Cloud::Retail::V2beta::AnalyticsService; | ||
| 21 | use Google::Cloud::Retail::V2beta::ProjectService; | ||
| 22 | use Google::Cloud::Retail::V2beta::Model; | ||
| 23 | use Google::Cloud::Retail::V2beta::Product; | ||
| 24 | use Google::Cloud::Retail::V2beta::GenerativeQuestionService; | ||
| 25 | use Google::Cloud::Retail::V2beta::ModelService; | ||
| 26 | use Google::Cloud::Retail::V2beta::UserEvent; | ||
| 27 | use Google::Cloud::Retail::V2beta::SearchService; | ||
| 28 | use Google::Cloud::Retail::V2beta::PredictionService; | ||
| 29 | use Google::Cloud::Retail::V2beta::ImportConfig; | ||
| 30 | use Google::Cloud::Retail::V2beta::ServingConfig; | ||
| 31 | use Google::Cloud::Retail::V2beta::ConversationalSearchService; | ||
| 32 | use Google::Cloud::Retail::V2beta::Control; | ||
| 33 | use Google::Cloud::Retail::V2beta::UserEventService; | ||
| 34 | use Google::Cloud::Retail::V2beta::Catalog; | ||
| 35 | use Google::Cloud::Retail::V2beta::CompletionService; | ||
| 36 | use Google::Cloud::Retail::V2beta::ProductService; | ||
| 37 | use Google::Cloud::Retail::V2beta::ServingConfigService; | ||
| 38 | use Google::Cloud::Retail::V2beta::ControlService; | ||
| 39 | use Google::Cloud::Retail::V2beta::CatalogService; | ||
| 40 | |||
| 41 | our $VERSION = '0.06'; | ||
| 42 | |||
| 43 | has credentials => ( is => 'ro', required => 0 ); | ||
| 44 | has transport => ( is => 'rw' ); | ||
| 45 | |||
| 46 | sub BUILD { | ||
| 47 | my ($self) = @_; | ||
| 48 | |||
| 49 | my $auth = $self->credentials; | ||
| 50 | if (!defined $auth) { | ||
| 51 | $auth = Google::Auth->default(); | ||
| 52 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 53 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 54 | } | ||
| 55 | my $token = $auth->get_token(); | ||
| 56 | |||
| 57 | my $target = 'retail.googleapis.com:443'; | ||
| 58 | my $t = $self->transport || 'grpc'; | ||
| 59 | |||
| 60 | if (ref($t) && eval { $t->can('call') }) { | ||
| 61 | # Already a transport object | ||
| 62 | } elsif (lc($t) eq 'rest') { | ||
| 63 | my $client = Google::Cloud::REST::Client->new( | ||
| 64 | target => $target, | ||
| 65 | auth_token => $token, | ||
| 66 | ); | ||
| 67 | $self->transport($client); | ||
| 68 | } else { | ||
| 69 | my $client = Google::gRPC::Client->new( | ||
| 70 | target => $target, | ||
| 71 | auth_token => $token, | ||
| 72 | ); | ||
| 73 | $self->transport($client); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | sub list_catalogs { | ||
| 78 | my ($self, %params) = @_; | ||
| 79 | |||
| 80 | my $request_class = 'Google::Cloud::Retail::V2beta::CatalogService::ListCatalogsRequest'; | ||
| 81 | my $request = eval { $request_class->new(\%params) }; | ||
| 82 | my $new_err = $@; | ||
| 83 | if (!$request) { | ||
| 84 | $request = eval { $request_class->new(%params) }; | ||
| 85 | $new_err ||= $@; | ||
| 86 | } | ||
| 87 | if (!$request) { | ||
| 88 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 89 | } | ||
| 90 | |||
| 91 | my $response_class = 'Google::Cloud::Retail::V2beta::CatalogService::ListCatalogsResponse'; | ||
| 92 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 93 | return $self->transport->call({ | ||
| 94 | http_method => 'POST', | ||
| 95 | path => '/google.cloud.retail.v2beta.CatalogService/ListCatalogs', | ||
| 96 | request => $request, | ||
| 97 | response_class => $response_class, | ||
| 98 | }); | ||
| 99 | } | ||
| 100 | |||
| 101 | my $response = $self->transport->call({ | ||
| 102 | service => 'google.cloud.retail.v2beta.CatalogService', | ||
| 103 | method => 'ListCatalogs', | ||
| 104 | request => $request, | ||
| 105 | response_class => $response_class, | ||
| 106 | }); | ||
| 107 | |||
| 108 | return $response; | ||
| 109 | } | ||
| 110 | |||
| 111 | sub update_completion_config { | ||
| 112 | my ($self, %params) = @_; | ||
| 113 | |||
| 114 | my $request_class = 'Google::Cloud::Retail::V2beta::CatalogService::UpdateCompletionConfigRequest'; | ||
| 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::Retail::V2beta::Catalog::CompletionConfig'; | ||
| 126 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 127 | return $self->transport->call({ | ||
| 128 | http_method => 'POST', | ||
| 129 | path => '/google.cloud.retail.v2beta.CatalogService/UpdateCompletionConfig', | ||
| 130 | request => $request, | ||
| 131 | response_class => $response_class, | ||
| 132 | }); | ||
| 133 | } | ||
| 134 | |||
| 135 | my $response = $self->transport->call({ | ||
| 136 | service => 'google.cloud.retail.v2beta.CatalogService', | ||
| 137 | method => 'UpdateCompletionConfig', | ||
| 138 | request => $request, | ||
| 139 | response_class => $response_class, | ||
| 140 | }); | ||
| 141 | |||
| 142 | return $response; | ||
| 143 | } | ||
| 144 | |||
| 145 | sub update_attributes_config { | ||
| 146 | my ($self, %params) = @_; | ||
| 147 | |||
| 148 | my $request_class = 'Google::Cloud::Retail::V2beta::CatalogService::UpdateAttributesConfigRequest'; | ||
| 149 | my $request = eval { $request_class->new(\%params) }; | ||
| 150 | my $new_err = $@; | ||
| 151 | if (!$request) { | ||
| 152 | $request = eval { $request_class->new(%params) }; | ||
| 153 | $new_err ||= $@; | ||
| 154 | } | ||
| 155 | if (!$request) { | ||
| 156 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 157 | } | ||
| 158 | |||
| 159 | my $response_class = 'Google::Cloud::Retail::V2beta::Catalog::AttributesConfig'; | ||
| 160 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 161 | return $self->transport->call({ | ||
| 162 | http_method => 'POST', | ||
| 163 | path => '/google.cloud.retail.v2beta.CatalogService/UpdateAttributesConfig', | ||
| 164 | request => $request, | ||
| 165 | response_class => $response_class, | ||
| 166 | }); | ||
| 167 | } | ||
| 168 | |||
| 169 | my $response = $self->transport->call({ | ||
| 170 | service => 'google.cloud.retail.v2beta.CatalogService', | ||
| 171 | method => 'UpdateAttributesConfig', | ||
| 172 | request => $request, | ||
| 173 | response_class => $response_class, | ||
| 174 | }); | ||
| 175 | |||
| 176 | return $response; | ||
| 177 | } | ||
| 178 | |||
| 179 | sub remove_catalog_attribute { | ||
| 180 | my ($self, %params) = @_; | ||
| 181 | |||
| 182 | my $request_class = 'Google::Cloud::Retail::V2beta::CatalogService::RemoveCatalogAttributeRequest'; | ||
| 183 | my $request = eval { $request_class->new(\%params) }; | ||
| 184 | my $new_err = $@; | ||
| 185 | if (!$request) { | ||
| 186 | $request = eval { $request_class->new(%params) }; | ||
| 187 | $new_err ||= $@; | ||
| 188 | } | ||
| 189 | if (!$request) { | ||
| 190 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 191 | } | ||
| 192 | |||
| 193 | my $response_class = 'Google::Cloud::Retail::V2beta::Catalog::AttributesConfig'; | ||
| 194 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 195 | return $self->transport->call({ | ||
| 196 | http_method => 'POST', | ||
| 197 | path => '/google.cloud.retail.v2beta.CatalogService/RemoveCatalogAttribute', | ||
| 198 | request => $request, | ||
| 199 | response_class => $response_class, | ||
| 200 | }); | ||
| 201 | } | ||
| 202 | |||
| 203 | my $response = $self->transport->call({ | ||
| 204 | service => 'google.cloud.retail.v2beta.CatalogService', | ||
| 205 | method => 'RemoveCatalogAttribute', | ||
| 206 | request => $request, | ||
| 207 | response_class => $response_class, | ||
| 208 | }); | ||
| 209 | |||
| 210 | return $response; | ||
| 211 | } | ||
| 212 | |||
| 213 | sub replace_catalog_attribute { | ||
| 214 | my ($self, %params) = @_; | ||
| 215 | |||
| 216 | my $request_class = 'Google::Cloud::Retail::V2beta::CatalogService::ReplaceCatalogAttributeRequest'; | ||
| 217 | my $request = eval { $request_class->new(\%params) }; | ||
| 218 | my $new_err = $@; | ||
| 219 | if (!$request) { | ||
| 220 | $request = eval { $request_class->new(%params) }; | ||
| 221 | $new_err ||= $@; | ||
| 222 | } | ||
| 223 | if (!$request) { | ||
| 224 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 225 | } | ||
| 226 | |||
| 227 | my $response_class = 'Google::Cloud::Retail::V2beta::Catalog::AttributesConfig'; | ||
| 228 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 229 | return $self->transport->call({ | ||
| 230 | http_method => 'POST', | ||
| 231 | path => '/google.cloud.retail.v2beta.CatalogService/ReplaceCatalogAttribute', | ||
| 232 | request => $request, | ||
| 233 | response_class => $response_class, | ||
| 234 | }); | ||
| 235 | } | ||
| 236 | |||
| 237 | my $response = $self->transport->call({ | ||
| 238 | service => 'google.cloud.retail.v2beta.CatalogService', | ||
| 239 | method => 'ReplaceCatalogAttribute', | ||
| 240 | request => $request, | ||
| 241 | response_class => $response_class, | ||
| 242 | }); | ||
| 243 | |||
| 244 | return $response; | ||
| 245 | } | ||
| 246 | 1; # End of Google::Cloud::Retail::V2beta::CatalogServiceClient | ||
| 247 | |||
| 248 | __END__ | ||