| 1 | package Google::Cloud::Devtools::Artifactregistry::V1::ArtifactRegistryClient; | ||
| 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::V1::Artifact; | ||
| 14 | use Google::Devtools::Artifactregistry::V1::Generic; | ||
| 15 | use Google::Devtools::Artifactregistry::V1::Go; | ||
| 16 | use Google::Devtools::Artifactregistry::V1::Attachment; | ||
| 17 | use Google::Devtools::Artifactregistry::V1::KfpArtifact; | ||
| 18 | use Google::Devtools::Artifactregistry::V1::YumArtifact; | ||
| 19 | use Google::Devtools::Artifactregistry::V1::AptArtifact; | ||
| 20 | use Google::Devtools::Artifactregistry::V1::Rule; | ||
| 21 | use Google::Devtools::Artifactregistry::V1::Repository; | ||
| 22 | use Google::Devtools::Artifactregistry::V1::VpcscConfig; | ||
| 23 | use Google::Devtools::Artifactregistry::V1::Tag; | ||
| 24 | use Google::Devtools::Artifactregistry::V1::Settings; | ||
| 25 | use Google::Devtools::Artifactregistry::V1::File; | ||
| 26 | use Google::Devtools::Artifactregistry::V1::Package; | ||
| 27 | use Google::Devtools::Artifactregistry::V1::Version; | ||
| 28 | use Google::Devtools::Artifactregistry::V1::Export; | ||
| 29 | use Google::Devtools::Artifactregistry::V1::Service; | ||
| 30 | |||
| 31 | our $VERSION = '0.06'; | ||
| 32 | |||
| 33 | has credentials => ( is => 'ro', required => 0 ); | ||
| 34 | has transport => ( is => 'rw' ); | ||
| 35 | |||
| 36 | sub BUILD { | ||
| 37 | my ($self) = @_; | ||
| 38 | |||
| 39 | my $auth = $self->credentials; | ||
| 40 | if (!defined $auth) { | ||
| 41 | $auth = Google::Auth->default(); | ||
| 42 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 43 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 44 | } | ||
| 45 | my $token = $auth->get_token(); | ||
| 46 | |||
| 47 | my $target = 'artifactregistry.googleapis.com:443'; | ||
| 48 | my $t = $self->transport || 'grpc'; | ||
| 49 | |||
| 50 | if (ref($t) && eval { $t->can('call') }) { | ||
| 51 | # Already a transport object | ||
| 52 | } elsif (lc($t) eq 'rest') { | ||
| 53 | my $client = Google::Cloud::REST::Client->new( | ||
| 54 | target => $target, | ||
| 55 | auth_token => $token, | ||
| 56 | ); | ||
| 57 | $self->transport($client); | ||
| 58 | } else { | ||
| 59 | my $client = Google::gRPC::Client->new( | ||
| 60 | target => $target, | ||
| 61 | auth_token => $token, | ||
| 62 | ); | ||
| 63 | $self->transport($client); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | sub list_docker_images { | ||
| 68 | my ($self, %params) = @_; | ||
| 69 | |||
| 70 | my $request_class = 'Google::Devtools::Artifactregistry::V1::Artifact::ListDockerImagesRequest'; | ||
| 71 | my $request = eval { $request_class->new(\%params) }; | ||
| 72 | my $new_err = $@; | ||
| 73 | if (!$request) { | ||
| 74 | $request = eval { $request_class->new(%params) }; | ||
| 75 | $new_err ||= $@; | ||
| 76 | } | ||
| 77 | if (!$request) { | ||
| 78 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 79 | } | ||
| 80 | |||
| 81 | my $response_class = 'Google::Devtools::Artifactregistry::V1::Artifact::ListDockerImagesResponse'; | ||
| 82 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 83 | return $self->transport->call({ | ||
| 84 | http_method => 'POST', | ||
| 85 | path => '/google.devtools.artifactregistry.v1.ArtifactRegistry/ListDockerImages', | ||
| 86 | request => $request, | ||
| 87 | response_class => $response_class, | ||
| 88 | }); | ||
| 89 | } | ||
| 90 | |||
| 91 | my $response = $self->transport->call({ | ||
| 92 | service => 'google.devtools.artifactregistry.v1.ArtifactRegistry', | ||
| 93 | method => 'ListDockerImages', | ||
| 94 | request => $request, | ||
| 95 | response_class => $response_class, | ||
| 96 | }); | ||
| 97 | |||
| 98 | return $response; | ||
| 99 | } | ||
| 100 | |||
| 101 | sub update_project_settings { | ||
| 102 | my ($self, %params) = @_; | ||
| 103 | |||
| 104 | my $request_class = 'Google::Devtools::Artifactregistry::V1::Settings::UpdateProjectSettingsRequest'; | ||
| 105 | my $request = eval { $request_class->new(\%params) }; | ||
| 106 | my $new_err = $@; | ||
| 107 | if (!$request) { | ||
| 108 | $request = eval { $request_class->new(%params) }; | ||
| 109 | $new_err ||= $@; | ||
| 110 | } | ||
| 111 | if (!$request) { | ||
| 112 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 113 | } | ||
| 114 | |||
| 115 | my $response_class = 'Google::Devtools::Artifactregistry::V1::Settings::ProjectSettings'; | ||
| 116 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 117 | return $self->transport->call({ | ||
| 118 | http_method => 'POST', | ||
| 119 | path => '/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateProjectSettings', | ||
| 120 | request => $request, | ||
| 121 | response_class => $response_class, | ||
| 122 | }); | ||
| 123 | } | ||
| 124 | |||
| 125 | my $response = $self->transport->call({ | ||
| 126 | service => 'google.devtools.artifactregistry.v1.ArtifactRegistry', | ||
| 127 | method => 'UpdateProjectSettings', | ||
| 128 | request => $request, | ||
| 129 | response_class => $response_class, | ||
| 130 | }); | ||
| 131 | |||
| 132 | return $response; | ||
| 133 | } | ||
| 134 | 1; # End of Google::Cloud::Devtools::Artifactregistry::V1::ArtifactRegistryClient | ||
| 135 | |||
| 136 | __END__ | ||