Cloud/Devtools/Artifactregistry/V1beta2.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
« Devtools/Artifactregistry/V1beta2/YumArtifact/Types.pm ↑ Summary Cloud/Devtools/Artifactregistry/V1beta2/ArtifactRegistryClient.pm »
1 package Google::Cloud::Devtools::Artifactregistry::V1beta2;
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::Devtools::Artifactregistry::V1beta2::File;
14 use Google::Devtools::Artifactregistry::V1beta2::Package;
15 use Google::Devtools::Artifactregistry::V1beta2::Tag;
16 use Google::Devtools::Artifactregistry::V1beta2::Settings;
17 use Google::Devtools::Artifactregistry::V1beta2::Repository;
18 use Google::Devtools::Artifactregistry::V1beta2::YumArtifact;
19 use Google::Devtools::Artifactregistry::V1beta2::AptArtifact;
20 use Google::Devtools::Artifactregistry::V1beta2::Version;
21 use Google::Devtools::Artifactregistry::V1beta2::Service;
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 = 'artifactregistry.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 import_apt_artifacts {
60 my ($self, %params) = @_;
61  
62 my $request_class = 'Google::Devtools::Artifactregistry::V1beta2::AptArtifact::ImportAptArtifactsRequest';
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.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportAptArtifacts',
78 request => $request,
79 response_class => $response_class,
80 });
81 }
82  
83 my $response = $self->transport->call({
84 service => 'google.devtools.artifactregistry.v1beta2.ArtifactRegistry',
85 method => 'ImportAptArtifacts',
86 request => $request,
87 response_class => $response_class,
88 });
89  
90 return $response;
91 }
92  
93 sub update_project_settings {
94 my ($self, %params) = @_;
95  
96 my $request_class = 'Google::Devtools::Artifactregistry::V1beta2::Settings::UpdateProjectSettingsRequest';
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::Devtools::Artifactregistry::V1beta2::Settings::ProjectSettings';
108 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
109 return $self->transport->call({
110 http_method => 'POST',
111 path => '/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateProjectSettings',
112 request => $request,
113 response_class => $response_class,
114 });
115 }
116  
117 my $response = $self->transport->call({
118 service => 'google.devtools.artifactregistry.v1beta2.ArtifactRegistry',
119 method => 'UpdateProjectSettings',
120 request => $request,
121 response_class => $response_class,
122 });
123  
124 return $response;
125 }
126 1; # End of Google::Cloud::Devtools::Artifactregistry::V1beta2
127  
128 __END__
« Devtools/Artifactregistry/V1beta2/YumArtifact/Types.pm ↑ Summary Cloud/Devtools/Artifactregistry/V1beta2/ArtifactRegistryClient.pm »