V1/SecurityPostureClient.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
« V1.pm ↑ Summary
1 package Google::Cloud::Securityposture::V1::SecurityPostureClient;
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::Securityposture::V1::OrgPolicyConfig;
14 use Google::Cloud::Securityposture::V1::ShaCustomConfig;
15 use Google::Cloud::Securityposture::V1::OrgPolicyConstraints;
16 use Google::Cloud::Securityposture::V1::ShaConstraints;
17 use Google::Cloud::Securityposture::V1::Securityposture;
18  
19 our $VERSION = '0.06';
20  
21 has credentials => ( is => 'ro', required => 0 );
22 has transport => ( is => 'rw' );
23  
24 sub BUILD {
25 my ($self) = @_;
26  
27 my $auth = $self->credentials;
28 if (!defined $auth) {
29 $auth = Google::Auth->default();
30 } elsif (!eval { $auth->can('get_token') }) {
31 croak 'Invalid credentials object: must implement get_token()';
32 }
33 my $token = $auth->get_token();
34  
35 my $target = 'securityposture.googleapis.com:443';
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 my $client = Google::gRPC::Client->new(
48 target => $target,
49 auth_token => $token,
50 );
51 $self->transport($client);
52 }
53 }
54  
55 sub list_postures {
56 my ($self, %params) = @_;
57  
58 my $request_class = 'Google::Cloud::Securityposture::V1::Securityposture::ListPosturesRequest';
59 my $request = eval { $request_class->new(\%params) };
60 my $new_err = $@;
61 if (!$request) {
62 $request = eval { $request_class->new(%params) };
63 $new_err ||= $@;
64 }
65 if (!$request) {
66 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
67 }
68  
69 my $response_class = 'Google::Cloud::Securityposture::V1::Securityposture::ListPosturesResponse';
70 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
71 return $self->transport->call({
72 http_method => 'POST',
73 path => '/google.cloud.securityposture.v1.SecurityPosture/ListPostures',
74 request => $request,
75 response_class => $response_class,
76 });
77 }
78  
79 my $response = $self->transport->call({
80 service => 'google.cloud.securityposture.v1.SecurityPosture',
81 method => 'ListPostures',
82 request => $request,
83 response_class => $response_class,
84 });
85  
86 return $response;
87 }
88 1; # End of Google::Cloud::Securityposture::V1::SecurityPostureClient
89  
90 __END__
« V1.pm ↑ Summary