V1/OrgPolicyViolationsPreviewServiceClient.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 V1/SimulatorClient.pm »
1 package Google::Cloud::Policysimulator::V1::OrgPolicyViolationsPreviewServiceClient;
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::Policysimulator::V1::Explanations;
14 use Google::Cloud::Policysimulator::V1::Orgpolicy;
15 use Google::Cloud::Policysimulator::V1::Simulator;
16  
17 our $VERSION = '0.06';
18  
19 has credentials => ( is => 'ro', required => 0 );
20 has transport => ( is => 'rw' );
21  
22 sub BUILD {
23 my ($self) = @_;
24  
25 my $auth = $self->credentials;
26 if (!defined $auth) {
27 $auth = Google::Auth->default();
28 } elsif (!eval { $auth->can('get_token') }) {
29 croak 'Invalid credentials object: must implement get_token()';
30 }
31 my $token = $auth->get_token();
32  
33 my $target = 'policysimulator.googleapis.com:443';
34 my $t = $self->transport || 'grpc';
35  
36 if (ref($t) && eval { $t->can('call') }) {
37 # Already a transport object
38 } elsif (lc($t) eq 'rest') {
39 my $client = Google::Cloud::REST::Client->new(
40 target => $target,
41 auth_token => $token,
42 );
43 $self->transport($client);
44 } else {
45 my $client = Google::gRPC::Client->new(
46 target => $target,
47 auth_token => $token,
48 );
49 $self->transport($client);
50 }
51 }
52  
53 sub list_org_policy_violations_previews {
54 my ($self, %params) = @_;
55  
56 my $request_class = 'Google::Cloud::Policysimulator::V1::Orgpolicy::ListOrgPolicyViolationsPreviewsRequest';
57 my $request = eval { $request_class->new(\%params) };
58 my $new_err = $@;
59 if (!$request) {
60 $request = eval { $request_class->new(%params) };
61 $new_err ||= $@;
62 }
63 if (!$request) {
64 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
65 }
66  
67 my $response_class = 'Google::Cloud::Policysimulator::V1::Orgpolicy::ListOrgPolicyViolationsPreviewsResponse';
68 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
69 return $self->transport->call({
70 http_method => 'POST',
71 path => '/google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService/ListOrgPolicyViolationsPreviews',
72 request => $request,
73 response_class => $response_class,
74 });
75 }
76  
77 my $response = $self->transport->call({
78 service => 'google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService',
79 method => 'ListOrgPolicyViolationsPreviews',
80 request => $request,
81 response_class => $response_class,
82 });
83  
84 return $response;
85 }
86 1; # End of Google::Cloud::Policysimulator::V1::OrgPolicyViolationsPreviewServiceClient
87  
88 __END__
« V1.pm ↑ Summary V1/SimulatorClient.pm »