| 1 | package Google::Cloud::Osconfig::V1alpha; | ||
| 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::Osconfig::V1alpha::ConfigCommon; | ||
| 14 | use Google::Cloud::Osconfig::V1alpha::OsconfigCommon; | ||
| 15 | use Google::Cloud::Osconfig::V1alpha::OsPolicy; | ||
| 16 | use Google::Cloud::Osconfig::V1alpha::OsPolicyAssignmentReports; | ||
| 17 | use Google::Cloud::Osconfig::V1alpha::Vulnerability; | ||
| 18 | use Google::Cloud::Osconfig::V1alpha::Inventory; | ||
| 19 | use Google::Cloud::Osconfig::V1alpha::InstanceOsPoliciesCompliance; | ||
| 20 | use Google::Cloud::Osconfig::V1alpha::OsPolicyAssignments; | ||
| 21 | use Google::Cloud::Osconfig::V1alpha::OsconfigZonalService; | ||
| 22 | |||
| 23 | our $VERSION = '0.06'; | ||
| 24 | |||
| 25 | has credentials => ( is => 'ro', required => 0 ); | ||
| 26 | has transport => ( is => 'rw' ); | ||
| 27 | |||
| 28 | sub BUILD { | ||
| 29 | my ($self) = @_; | ||
| 30 | |||
| 31 | my $auth = $self->credentials; | ||
| 32 | if (!defined $auth) { | ||
| 33 | $auth = Google::Auth->default(); | ||
| 34 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 35 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 36 | } | ||
| 37 | my $token = $auth->get_token(); | ||
| 38 | |||
| 39 | my $target = 'osconfig.googleapis.com:443'; | ||
| 40 | my $t = $self->transport || 'grpc'; | ||
| 41 | |||
| 42 | if (ref($t) && eval { $t->can('call') }) { | ||
| 43 | # Already a transport object | ||
| 44 | } elsif (lc($t) eq 'rest') { | ||
| 45 | my $client = Google::Cloud::REST::Client->new( | ||
| 46 | target => $target, | ||
| 47 | auth_token => $token, | ||
| 48 | ); | ||
| 49 | $self->transport($client); | ||
| 50 | } else { | ||
| 51 | my $client = Google::gRPC::Client->new( | ||
| 52 | target => $target, | ||
| 53 | auth_token => $token, | ||
| 54 | ); | ||
| 55 | $self->transport($client); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | sub create_ospolicy_assignment { | ||
| 60 | my ($self, %params) = @_; | ||
| 61 | |||
| 62 | my $request_class = 'Google::Cloud::Osconfig::V1alpha::OsPolicyAssignments::CreateOSPolicyAssignmentRequest'; | ||
| 63 | my $request = eval { $request_class->new(\%params) }; | ||
| 64 | my $new_err = $@; | ||
| 65 | if (!$request) { | ||
| 66 | $request = eval { $request_class->new(%params) }; | ||
| 67 | $new_err ||= $@; | ||
| 68 | } | ||
| 69 | if (!$request) { | ||
| 70 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 71 | } | ||
| 72 | |||
| 73 | my $response_class = 'Google::Longrunning::Operations::Operation'; | ||
| 74 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 75 | return $self->transport->call({ | ||
| 76 | http_method => 'POST', | ||
| 77 | path => '/google.cloud.osconfig.v1alpha.OsConfigZonalService/CreateOSPolicyAssignment', | ||
| 78 | request => $request, | ||
| 79 | response_class => $response_class, | ||
| 80 | }); | ||
| 81 | } | ||
| 82 | |||
| 83 | my $response = $self->transport->call({ | ||
| 84 | service => 'google.cloud.osconfig.v1alpha.OsConfigZonalService', | ||
| 85 | method => 'CreateOSPolicyAssignment', | ||
| 86 | request => $request, | ||
| 87 | response_class => $response_class, | ||
| 88 | }); | ||
| 89 | |||
| 90 | return $response; | ||
| 91 | } | ||
| 92 | |||
| 93 | sub list_inventories { | ||
| 94 | my ($self, %params) = @_; | ||
| 95 | |||
| 96 | my $request_class = 'Google::Cloud::Osconfig::V1alpha::Inventory::ListInventoriesRequest'; | ||
| 97 | my $request = eval { $request_class->new(\%params) }; | ||
| 98 | my $new_err = $@; | ||
| 99 | if (!$request) { | ||
| 100 | $request = eval { $request_class->new(%params) }; | ||
| 101 | $new_err ||= $@; | ||
| 102 | } | ||
| 103 | if (!$request) { | ||
| 104 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 105 | } | ||
| 106 | |||
| 107 | my $response_class = 'Google::Cloud::Osconfig::V1alpha::Inventory::ListInventoriesResponse'; | ||
| 108 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 109 | return $self->transport->call({ | ||
| 110 | http_method => 'POST', | ||
| 111 | path => '/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInventories', | ||
| 112 | request => $request, | ||
| 113 | response_class => $response_class, | ||
| 114 | }); | ||
| 115 | } | ||
| 116 | |||
| 117 | my $response = $self->transport->call({ | ||
| 118 | service => 'google.cloud.osconfig.v1alpha.OsConfigZonalService', | ||
| 119 | method => 'ListInventories', | ||
| 120 | request => $request, | ||
| 121 | response_class => $response_class, | ||
| 122 | }); | ||
| 123 | |||
| 124 | return $response; | ||
| 125 | } | ||
| 126 | |||
| 127 | sub list_vulnerability_reports { | ||
| 128 | my ($self, %params) = @_; | ||
| 129 | |||
| 130 | my $request_class = 'Google::Cloud::Osconfig::V1alpha::Vulnerability::ListVulnerabilityReportsRequest'; | ||
| 131 | my $request = eval { $request_class->new(\%params) }; | ||
| 132 | my $new_err = $@; | ||
| 133 | if (!$request) { | ||
| 134 | $request = eval { $request_class->new(%params) }; | ||
| 135 | $new_err ||= $@; | ||
| 136 | } | ||
| 137 | if (!$request) { | ||
| 138 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 139 | } | ||
| 140 | |||
| 141 | my $response_class = 'Google::Cloud::Osconfig::V1alpha::Vulnerability::ListVulnerabilityReportsResponse'; | ||
| 142 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 143 | return $self->transport->call({ | ||
| 144 | http_method => 'POST', | ||
| 145 | path => '/google.cloud.osconfig.v1alpha.OsConfigZonalService/ListVulnerabilityReports', | ||
| 146 | request => $request, | ||
| 147 | response_class => $response_class, | ||
| 148 | }); | ||
| 149 | } | ||
| 150 | |||
| 151 | my $response = $self->transport->call({ | ||
| 152 | service => 'google.cloud.osconfig.v1alpha.OsConfigZonalService', | ||
| 153 | method => 'ListVulnerabilityReports', | ||
| 154 | request => $request, | ||
| 155 | response_class => $response_class, | ||
| 156 | }); | ||
| 157 | |||
| 158 | return $response; | ||
| 159 | } | ||
| 160 | 1; # End of Google::Cloud::Osconfig::V1alpha | ||
| 161 | |||
| 162 | __END__ | ||