| 1 | package Google::Cloud::Support::V2::CaseAttachmentServiceClient; | ||
| 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::Support::V2::SupportEventSubscription; | ||
| 14 | use Google::Cloud::Support::V2::Actor; | ||
| 15 | use Google::Cloud::Support::V2::Escalation; | ||
| 16 | use Google::Cloud::Support::V2::SupportEventSubscriptionService; | ||
| 17 | use Google::Cloud::Support::V2::Comment; | ||
| 18 | use Google::Cloud::Support::V2::Case; | ||
| 19 | use Google::Cloud::Support::V2::Attachment; | ||
| 20 | use Google::Cloud::Support::V2::CommentService; | ||
| 21 | use Google::Cloud::Support::V2::CaseService; | ||
| 22 | use Google::Cloud::Support::V2::AttachmentService; | ||
| 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 = 'cloudsupport.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 list_attachments { | ||
| 61 | my ($self, %params) = @_; | ||
| 62 | |||
| 63 | my $request_class = 'Google::Cloud::Support::V2::AttachmentService::ListAttachmentsRequest'; | ||
| 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::Support::V2::AttachmentService::ListAttachmentsResponse'; | ||
| 75 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 76 | return $self->transport->call({ | ||
| 77 | http_method => 'POST', | ||
| 78 | path => '/google.cloud.support.v2.CaseAttachmentService/ListAttachments', | ||
| 79 | request => $request, | ||
| 80 | response_class => $response_class, | ||
| 81 | }); | ||
| 82 | } | ||
| 83 | |||
| 84 | my $response = $self->transport->call({ | ||
| 85 | service => 'google.cloud.support.v2.CaseAttachmentService', | ||
| 86 | method => 'ListAttachments', | ||
| 87 | request => $request, | ||
| 88 | response_class => $response_class, | ||
| 89 | }); | ||
| 90 | |||
| 91 | return $response; | ||
| 92 | } | ||
| 93 | 1; # End of Google::Cloud::Support::V2::CaseAttachmentServiceClient | ||
| 94 | |||
| 95 | __END__ | ||