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