AutokeyClient.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« AutokeyAdminClient.pm ↑ Summary EkmServiceClient.pm »
1 package Google::Cloud::Kms::AutokeyClient;
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::Kms::V1::HsmManagement;
14 use Google::Cloud::Kms::V1::Autokey;
15 use Google::Cloud::Kms::V1::Resources;
16 use Google::Cloud::Kms::V1::EkmService;
17 use Google::Cloud::Kms::V1::AutokeyAdmin;
18 use Google::Cloud::Kms::V1::Service;
19  
20 our $VERSION = '0.04';
21  
22 has credentials => ( is => 'ro', required => 0 );
23 has transport => ( is => 'rw' );
24  
25 sub BUILD {
26 my ($self) = @_;
27  
28 # Resolve credentials: use passed credentials object if it implements get_token, or default to ADC
29 my $auth = $self->credentials;
30 if (!$auth || !eval { $auth->can('get_token') }) {
31 $auth = Google::Auth->default();
32 }
33 my $token = $auth->get_token();
34  
35 my $target = 'cloudkms.googleapis.com';
36 my $t = $self->transport || 'grpc';
37  
38 if (ref($t) && eval { $t->can('call') }) {
39 # Already a transport object
40 } elsif (lc($t) eq 'rest') {
41 my $client = Google::Cloud::REST::Client->new(
42 target => $target,
43 auth_token => $token,
44 );
45 $self->transport($client);
46 } else {
47 # Default high-performance HTTP/2 gRPC client
48 my $client = Google::gRPC::Client->new(
49 target => $target,
50 auth_token => $token,
51 );
52 $self->transport($client);
53 }
54 }
55  
56 sub create_key_handle {
57 my ($self, %params) = @_;
58  
59 my $request_class = 'Google::Cloud::Kms::V1::Autokey::CreateKeyHandleRequest';
60 my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);
61  
62 my $response_class = 'Google::Longrunning::Operations::Operation';
63 my $response = $self->transport->call({
64 service => 'google.cloud.kms.v1.Autokey',
65 method => 'CreateKeyHandle',
66 request => $request,
67 response_class => $response_class,
68 });
69  
70 return $response;
71 }
72 1; # End of Google::Cloud::Kms::AutokeyClient
73  
74 __END__
« AutokeyAdminClient.pm ↑ Summary EkmServiceClient.pm »