| 1 | package Google::Cloud::Support::V2beta::CaseServiceClient; | ||
| 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::V2beta::Content; | ||
| 14 | use Google::Cloud::Support::V2beta::Actor; | ||
| 15 | use Google::Cloud::Support::V2beta::Escalation; | ||
| 16 | use Google::Cloud::Support::V2beta::SupportEventSubscription; | ||
| 17 | use Google::Cloud::Support::V2beta::Comment; | ||
| 18 | use Google::Cloud::Support::V2beta::Attachment; | ||
| 19 | use Google::Cloud::Support::V2beta::EmailMessage; | ||
| 20 | use Google::Cloud::Support::V2beta::Case; | ||
| 21 | use Google::Cloud::Support::V2beta::SupportEventSubscriptionService; | ||
| 22 | use Google::Cloud::Support::V2beta::CommentService; | ||
| 23 | use Google::Cloud::Support::V2beta::AttachmentService; | ||
| 24 | use Google::Cloud::Support::V2beta::FeedItem; | ||
| 25 | use Google::Cloud::Support::V2beta::CaseService; | ||
| 26 | use Google::Cloud::Support::V2beta::FeedService; | ||
| 27 | |||
| 28 | our $VERSION = '0.06'; | ||
| 29 | |||
| 30 | has credentials => ( is => 'ro', required => 0 ); | ||
| 31 | has transport => ( is => 'rw' ); | ||
| 32 | |||
| 33 | sub BUILD { | ||
| 34 | my ($self) = @_; | ||
| 35 | |||
| 36 | my $auth = $self->credentials; | ||
| 37 | if (!defined $auth) { | ||
| 38 | $auth = Google::Auth->default(); | ||
| 39 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 40 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 41 | } | ||
| 42 | my $token = $auth->get_token(); | ||
| 43 | |||
| 44 | my $target = 'cloudsupport.googleapis.com:443'; | ||
| 45 | my $t = $self->transport || 'grpc'; | ||
| 46 | |||
| 47 | if (ref($t) && eval { $t->can('call') }) { | ||
| 48 | # Already a transport object | ||
| 49 | } elsif (lc($t) eq 'rest') { | ||
| 50 | my $client = Google::Cloud::REST::Client->new( | ||
| 51 | target => $target, | ||
| 52 | auth_token => $token, | ||
| 53 | ); | ||
| 54 | $self->transport($client); | ||
| 55 | } else { | ||
| 56 | my $client = Google::gRPC::Client->new( | ||
| 57 | target => $target, | ||
| 58 | auth_token => $token, | ||
| 59 | ); | ||
| 60 | $self->transport($client); | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | sub get_case { | ||
| 65 | my ($self, %params) = @_; | ||
| 66 | |||
| 67 | my $request_class = 'Google::Cloud::Support::V2beta::CaseService::GetCaseRequest'; | ||
| 68 | my $request = eval { $request_class->new(\%params) }; | ||
| 69 | my $new_err = $@; | ||
| 70 | if (!$request) { | ||
| 71 | $request = eval { $request_class->new(%params) }; | ||
| 72 | $new_err ||= $@; | ||
| 73 | } | ||
| 74 | if (!$request) { | ||
| 75 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 76 | } | ||
| 77 | |||
| 78 | my $response_class = 'Google::Cloud::Support::V2beta::Case::Case'; | ||
| 79 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 80 | return $self->transport->call({ | ||
| 81 | http_method => 'POST', | ||
| 82 | path => '/google.cloud.support.v2beta.CaseService/GetCase', | ||
| 83 | request => $request, | ||
| 84 | response_class => $response_class, | ||
| 85 | }); | ||
| 86 | } | ||
| 87 | |||
| 88 | my $response = $self->transport->call({ | ||
| 89 | service => 'google.cloud.support.v2beta.CaseService', | ||
| 90 | method => 'GetCase', | ||
| 91 | request => $request, | ||
| 92 | response_class => $response_class, | ||
| 93 | }); | ||
| 94 | |||
| 95 | return $response; | ||
| 96 | } | ||
| 97 | |||
| 98 | sub search_case_classifications { | ||
| 99 | my ($self, %params) = @_; | ||
| 100 | |||
| 101 | my $request_class = 'Google::Cloud::Support::V2beta::CaseService::SearchCaseClassificationsRequest'; | ||
| 102 | my $request = eval { $request_class->new(\%params) }; | ||
| 103 | my $new_err = $@; | ||
| 104 | if (!$request) { | ||
| 105 | $request = eval { $request_class->new(%params) }; | ||
| 106 | $new_err ||= $@; | ||
| 107 | } | ||
| 108 | if (!$request) { | ||
| 109 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 110 | } | ||
| 111 | |||
| 112 | my $response_class = 'Google::Cloud::Support::V2beta::CaseService::SearchCaseClassificationsResponse'; | ||
| 113 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 114 | return $self->transport->call({ | ||
| 115 | http_method => 'POST', | ||
| 116 | path => '/google.cloud.support.v2beta.CaseService/SearchCaseClassifications', | ||
| 117 | request => $request, | ||
| 118 | response_class => $response_class, | ||
| 119 | }); | ||
| 120 | } | ||
| 121 | |||
| 122 | my $response = $self->transport->call({ | ||
| 123 | service => 'google.cloud.support.v2beta.CaseService', | ||
| 124 | method => 'SearchCaseClassifications', | ||
| 125 | request => $request, | ||
| 126 | response_class => $response_class, | ||
| 127 | }); | ||
| 128 | |||
| 129 | return $response; | ||
| 130 | } | ||
| 131 | 1; # End of Google::Cloud::Support::V2beta::CaseServiceClient | ||
| 132 | |||
| 133 | __END__ | ||