Cloud/Dataflow/V1beta3/FlexTemplatesServiceClient.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
« Cloud/Dataflow/V1beta3.pm ↑ Summary Cloud/Dataflow/V1beta3/JobsV1Beta3Client.pm »
1 package Google::Cloud::Dataflow::V1beta3::FlexTemplatesServiceClient;
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::Dataflow::V1beta3::Streaming;
14 use Google::Dataflow::V1beta3::Snapshots;
15 use Google::Dataflow::V1beta3::Environment;
16 use Google::Dataflow::V1beta3::Metrics;
17 use Google::Dataflow::V1beta3::Messages;
18 use Google::Dataflow::V1beta3::Jobs;
19 use Google::Dataflow::V1beta3::Templates;
20  
21 our $VERSION = '0.06';
22  
23 has credentials => ( is => 'ro', required => 0 );
24 has transport => ( is => 'rw' );
25  
26 sub BUILD {
27 my ($self) = @_;
28  
29 my $auth = $self->credentials;
30 if (!defined $auth) {
31 $auth = Google::Auth->default();
32 } elsif (!eval { $auth->can('get_token') }) {
33 croak 'Invalid credentials object: must implement get_token()';
34 }
35 my $token = $auth->get_token();
36  
37 my $target = 'dataflow.googleapis.com:443';
38 my $t = $self->transport || 'grpc';
39  
40 if (ref($t) && eval { $t->can('call') }) {
41 # Already a transport object
42 } elsif (lc($t) eq 'rest') {
43 my $client = Google::Cloud::REST::Client->new(
44 target => $target,
45 auth_token => $token,
46 );
47 $self->transport($client);
48 } else {
49 my $client = Google::gRPC::Client->new(
50 target => $target,
51 auth_token => $token,
52 );
53 $self->transport($client);
54 }
55 }
56  
57 sub launch_flex_template {
58 my ($self, %params) = @_;
59  
60 my $request_class = 'Google::Dataflow::V1beta3::Templates::LaunchFlexTemplateRequest';
61 my $request = eval { $request_class->new(\%params) };
62 my $new_err = $@;
63 if (!$request) {
64 $request = eval { $request_class->new(%params) };
65 $new_err ||= $@;
66 }
67 if (!$request) {
68 croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error');
69 }
70  
71 my $response_class = 'Google::Dataflow::V1beta3::Templates::LaunchFlexTemplateResponse';
72 if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) {
73 return $self->transport->call({
74 http_method => 'POST',
75 path => '/google.dataflow.v1beta3.FlexTemplatesService/LaunchFlexTemplate',
76 request => $request,
77 response_class => $response_class,
78 });
79 }
80  
81 my $response = $self->transport->call({
82 service => 'google.dataflow.v1beta3.FlexTemplatesService',
83 method => 'LaunchFlexTemplate',
84 request => $request,
85 response_class => $response_class,
86 });
87  
88 return $response;
89 }
90 1; # End of Google::Cloud::Dataflow::V1beta3::FlexTemplatesServiceClient
91  
92 __END__
« Cloud/Dataflow/V1beta3.pm ↑ Summary Cloud/Dataflow/V1beta3/JobsV1Beta3Client.pm »