V4beta1/JobServiceClient.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
« V4beta1/EventServiceClient.pm ↑ Summary V4beta1/TenantServiceClient.pm »
1 package Google::Cloud::Talent::V4beta1::JobServiceClient;
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::Talent::V4beta1::Histogram;
14 use Google::Cloud::Talent::V4beta1::Batch;
15 use Google::Cloud::Talent::V4beta1::Common;
16 use Google::Cloud::Talent::V4beta1::Tenant;
17 use Google::Cloud::Talent::V4beta1::Event;
18 use Google::Cloud::Talent::V4beta1::Filters;
19 use Google::Cloud::Talent::V4beta1::Company;
20 use Google::Cloud::Talent::V4beta1::Job;
21 use Google::Cloud::Talent::V4beta1::CompletionService;
22 use Google::Cloud::Talent::V4beta1::TenantService;
23 use Google::Cloud::Talent::V4beta1::EventService;
24 use Google::Cloud::Talent::V4beta1::CompanyService;
25 use Google::Cloud::Talent::V4beta1::JobService;
26  
27 our $VERSION = '0.06';
28  
29 has credentials => ( is => 'ro', required => 0 );
30 has transport => ( is => 'rw' );
31  
32 sub BUILD {
33 my ($self) = @_;
34  
35 my $auth = $self->credentials;
36 if (!defined $auth) {
37 $auth = Google::Auth->default();
38 } elsif (!eval { $auth->can('get_token') }) {
39 croak 'Invalid credentials object: must implement get_token()';
40 }
41 my $token = $auth->get_token();
42  
43 my $target = 'jobs.googleapis.com:443';
44 my $t = $self->transport || 'grpc';
45  
46 if (ref($t) && eval { $t->can('call') }) {
47 # Already a transport object
48 } elsif (lc($t) eq 'rest') {
49 my $client = Google::Cloud::REST::Client->new(
50 target => $target,
51 auth_token => $token,
52 );
53 $self->transport($client);
54 } else {
55 my $client = Google::gRPC::Client->new(
56 target => $target,
57 auth_token => $token,
58 );
59 $self->transport($client);
60 }
61 }
62  
63 sub create_job {
64 my ($self, %params) = @_;
65  
66 my $request_class = 'Google::Cloud::Talent::V4beta1::JobService::CreateJobRequest';
67 my $request = eval { $request_class->new(\%params) };
68 my $new_err = $@;
69 if (!$request) {
70 $request = eval { $request_class->new(%params) };
71 $new_err ||= $@;
72 }
73 if (!$request) {
74 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
75 }
76  
77 my $response_class = 'Google::Cloud::Talent::V4beta1::Job::Job';
78 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
79 return $self->transport->call({
80 http_method => 'POST',
81 path => '/google.cloud.talent.v4beta1.JobService/CreateJob',
82 request => $request,
83 response_class => $response_class,
84 });
85 }
86  
87 my $response = $self->transport->call({
88 service => 'google.cloud.talent.v4beta1.JobService',
89 method => 'CreateJob',
90 request => $request,
91 response_class => $response_class,
92 });
93  
94 return $response;
95 }
96 1; # End of Google::Cloud::Talent::V4beta1::JobServiceClient
97  
98 __END__
« V4beta1/EventServiceClient.pm ↑ Summary V4beta1/TenantServiceClient.pm »