« Cloud/Dataflow/V1beta3/MessagesV1Beta3Client.pm
↑ Summary
Cloud/Dataflow/V1beta3/SnapshotsV1Beta3Client.pm »
| 1 | package Google::Cloud::Dataflow::V1beta3::MetricsV1Beta3Client; | ||
| 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::Environment; | ||
| 15 | use Google::Dataflow::V1beta3::Messages; | ||
| 16 | use Google::Dataflow::V1beta3::Snapshots; | ||
| 17 | use Google::Dataflow::V1beta3::Metrics; | ||
| 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 get_job_metrics { | ||
| 58 | my ($self, %params) = @_; | ||
| 59 | |||
| 60 | my $request_class = 'Google::Dataflow::V1beta3::Metrics::GetJobMetricsRequest'; | ||
| 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::Metrics::JobMetrics'; | ||
| 72 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 73 | return $self->transport->call({ | ||
| 74 | http_method => 'POST', | ||
| 75 | path => '/google.dataflow.v1beta3.MetricsV1Beta3/GetJobMetrics', | ||
| 76 | request => $request, | ||
| 77 | response_class => $response_class, | ||
| 78 | }); | ||
| 79 | } | ||
| 80 | |||
| 81 | my $response = $self->transport->call({ | ||
| 82 | service => 'google.dataflow.v1beta3.MetricsV1Beta3', | ||
| 83 | method => 'GetJobMetrics', | ||
| 84 | request => $request, | ||
| 85 | response_class => $response_class, | ||
| 86 | }); | ||
| 87 | |||
| 88 | return $response; | ||
| 89 | } | ||
| 90 | |||
| 91 | sub get_job_execution_details { | ||
| 92 | my ($self, %params) = @_; | ||
| 93 | |||
| 94 | my $request_class = 'Google::Dataflow::V1beta3::Metrics::GetJobExecutionDetailsRequest'; | ||
| 95 | my $request = eval { $request_class->new(\%params) }; | ||
| 96 | my $new_err = $@; | ||
| 97 | if (!$request) { | ||
| 98 | $request = eval { $request_class->new(%params) }; | ||
| 99 | $new_err ||= $@; | ||
| 100 | } | ||
| 101 | if (!$request) { | ||
| 102 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 103 | } | ||
| 104 | |||
| 105 | my $response_class = 'Google::Dataflow::V1beta3::Metrics::JobExecutionDetails'; | ||
| 106 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 107 | return $self->transport->call({ | ||
| 108 | http_method => 'POST', | ||
| 109 | path => '/google.dataflow.v1beta3.MetricsV1Beta3/GetJobExecutionDetails', | ||
| 110 | request => $request, | ||
| 111 | response_class => $response_class, | ||
| 112 | }); | ||
| 113 | } | ||
| 114 | |||
| 115 | my $response = $self->transport->call({ | ||
| 116 | service => 'google.dataflow.v1beta3.MetricsV1Beta3', | ||
| 117 | method => 'GetJobExecutionDetails', | ||
| 118 | request => $request, | ||
| 119 | response_class => $response_class, | ||
| 120 | }); | ||
| 121 | |||
| 122 | return $response; | ||
| 123 | } | ||
| 124 | |||
| 125 | sub get_stage_execution_details { | ||
| 126 | my ($self, %params) = @_; | ||
| 127 | |||
| 128 | my $request_class = 'Google::Dataflow::V1beta3::Metrics::GetStageExecutionDetailsRequest'; | ||
| 129 | my $request = eval { $request_class->new(\%params) }; | ||
| 130 | my $new_err = $@; | ||
| 131 | if (!$request) { | ||
| 132 | $request = eval { $request_class->new(%params) }; | ||
| 133 | $new_err ||= $@; | ||
| 134 | } | ||
| 135 | if (!$request) { | ||
| 136 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 137 | } | ||
| 138 | |||
| 139 | my $response_class = 'Google::Dataflow::V1beta3::Metrics::StageExecutionDetails'; | ||
| 140 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 141 | return $self->transport->call({ | ||
| 142 | http_method => 'POST', | ||
| 143 | path => '/google.dataflow.v1beta3.MetricsV1Beta3/GetStageExecutionDetails', | ||
| 144 | request => $request, | ||
| 145 | response_class => $response_class, | ||
| 146 | }); | ||
| 147 | } | ||
| 148 | |||
| 149 | my $response = $self->transport->call({ | ||
| 150 | service => 'google.dataflow.v1beta3.MetricsV1Beta3', | ||
| 151 | method => 'GetStageExecutionDetails', | ||
| 152 | request => $request, | ||
| 153 | response_class => $response_class, | ||
| 154 | }); | ||
| 155 | |||
| 156 | return $response; | ||
| 157 | } | ||
| 158 | 1; # End of Google::Cloud::Dataflow::V1beta3::MetricsV1Beta3Client | ||
| 159 | |||
| 160 | __END__ | ||