| 1 | package Google::Cloud::Metastore::V1::DataprocMetastoreClient; | ||
| 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::Metastore::V1::Metastore; | ||
| 14 | use Google::Cloud::Metastore::V1::MetastoreFederation; | ||
| 15 | |||
| 16 | our $VERSION = '0.02'; | ||
| 17 | |||
| 18 | has credentials => ( is => 'ro', required => 0 ); | ||
| 19 | has transport => ( is => 'rw' ); | ||
| 20 | |||
| 21 | sub BUILD { | ||
| 22 | my ($self) = @_; | ||
| 23 | |||
| 24 | # Resolve credentials: use passed credentials object if it implements get_token, or default to ADC | ||
| 25 | my $auth = $self->credentials; | ||
| 26 | if (!$auth || !eval { $auth->can('get_token') }) { | ||
| 27 | $auth = Google::Auth->default(); | ||
| 28 | } | ||
| 29 | my $token = $auth->get_token(); | ||
| 30 | |||
| 31 | my $target = 'localhost:50051'; | ||
| 32 | my $t = $self->transport || 'grpc'; | ||
| 33 | |||
| 34 | if (ref($t) && eval { $t->can('call') }) { | ||
| 35 | # Already a transport object | ||
| 36 | } elsif (lc($t) eq 'rest') { | ||
| 37 | my $client = Google::Cloud::REST::Client->new( | ||
| 38 | target => $target, | ||
| 39 | auth_token => $token, | ||
| 40 | ); | ||
| 41 | $self->transport($client); | ||
| 42 | } else { | ||
| 43 | # Default high-performance HTTP/2 gRPC client | ||
| 44 | my $client = Google::gRPC::Client->new( | ||
| 45 | target => $target, | ||
| 46 | auth_token => $token, | ||
| 47 | ); | ||
| 48 | $self->transport($client); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | sub list_services { | ||
| 53 | my ($self, %params) = @_; | ||
| 54 | |||
| 55 | my $request_class = 'Google::Cloud::Metastore::V1::Metastore::ListServicesRequest'; | ||
| 56 | my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params); | ||
| 57 | |||
| 58 | my $response_class = 'Google::Cloud::Metastore::V1::Metastore::ListServicesResponse'; | ||
| 59 | my $response = $self->transport->call({ | ||
| 60 | service => 'google.cloud.metastore.v1.DataprocMetastore', | ||
| 61 | method => 'ListServices', | ||
| 62 | request => $request, | ||
| 63 | response_class => $response_class, | ||
| 64 | }); | ||
| 65 | |||
| 66 | return $response; | ||
| 67 | } | ||
| 68 | 1; # End of Google::Cloud::Metastore::V1::DataprocMetastoreClient | ||
| 69 | |||
| 70 | __END__ | ||