| 1 | package Google::Cloud::Monitoring::Dashboard::V1::DashboardsServiceClient; | ||
| 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::Monitoring::Dashboard::V1::LogsPanel; | ||
| 14 | use Google::Monitoring::Dashboard::V1::SingleViewGroup; | ||
| 15 | use Google::Monitoring::Dashboard::V1::Drilldowns; | ||
| 16 | use Google::Monitoring::Dashboard::V1::Service; | ||
| 17 | use Google::Monitoring::Dashboard::V1::CollapsibleGroup; | ||
| 18 | use Google::Monitoring::Dashboard::V1::Text; | ||
| 19 | use Google::Monitoring::Dashboard::V1::SectionHeader; | ||
| 20 | use Google::Monitoring::Dashboard::V1::ErrorReportingPanel; | ||
| 21 | use Google::Monitoring::Dashboard::V1::Common; | ||
| 22 | use Google::Monitoring::Dashboard::V1::Alertchart; | ||
| 23 | use Google::Monitoring::Dashboard::V1::TableDisplayOptions; | ||
| 24 | use Google::Monitoring::Dashboard::V1::DashboardFilter; | ||
| 25 | use Google::Monitoring::Dashboard::V1::IncidentList; | ||
| 26 | use Google::Monitoring::Dashboard::V1::Metrics; | ||
| 27 | use Google::Monitoring::Dashboard::V1::Xychart; | ||
| 28 | use Google::Monitoring::Dashboard::V1::Scorecard; | ||
| 29 | use Google::Monitoring::Dashboard::V1::Table; | ||
| 30 | use Google::Monitoring::Dashboard::V1::Piechart; | ||
| 31 | use Google::Monitoring::Dashboard::V1::Widget; | ||
| 32 | use Google::Monitoring::Dashboard::V1::Layouts; | ||
| 33 | use Google::Monitoring::Dashboard::V1::Dashboard; | ||
| 34 | use Google::Monitoring::Dashboard::V1::DashboardsService; | ||
| 35 | |||
| 36 | our $VERSION = '0.06'; | ||
| 37 | |||
| 38 | has credentials => ( is => 'ro', required => 0 ); | ||
| 39 | has transport => ( is => 'rw' ); | ||
| 40 | |||
| 41 | sub BUILD { | ||
| 42 | my ($self) = @_; | ||
| 43 | |||
| 44 | my $auth = $self->credentials; | ||
| 45 | if (!defined $auth) { | ||
| 46 | $auth = Google::Auth->default(); | ||
| 47 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 48 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 49 | } | ||
| 50 | my $token = $auth->get_token(); | ||
| 51 | |||
| 52 | my $target = 'monitoring.googleapis.com:443'; | ||
| 53 | my $t = $self->transport || 'grpc'; | ||
| 54 | |||
| 55 | if (ref($t) && eval { $t->can('call') }) { | ||
| 56 | # Already a transport object | ||
| 57 | } elsif (lc($t) eq 'rest') { | ||
| 58 | my $client = Google::Cloud::REST::Client->new( | ||
| 59 | target => $target, | ||
| 60 | auth_token => $token, | ||
| 61 | ); | ||
| 62 | $self->transport($client); | ||
| 63 | } else { | ||
| 64 | my $client = Google::gRPC::Client->new( | ||
| 65 | target => $target, | ||
| 66 | auth_token => $token, | ||
| 67 | ); | ||
| 68 | $self->transport($client); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | sub create_dashboard { | ||
| 73 | my ($self, %params) = @_; | ||
| 74 | |||
| 75 | my $request_class = 'Google::Monitoring::Dashboard::V1::DashboardsService::CreateDashboardRequest'; | ||
| 76 | my $request = eval { $request_class->new(\%params) }; | ||
| 77 | my $new_err = $@; | ||
| 78 | if (!$request) { | ||
| 79 | $request = eval { $request_class->new(%params) }; | ||
| 80 | $new_err ||= $@; | ||
| 81 | } | ||
| 82 | if (!$request) { | ||
| 83 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 84 | } | ||
| 85 | |||
| 86 | my $response_class = 'Google::Monitoring::Dashboard::V1::Dashboard::Dashboard'; | ||
| 87 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 88 | return $self->transport->call({ | ||
| 89 | http_method => 'POST', | ||
| 90 | path => '/google.monitoring.dashboard.v1.DashboardsService/CreateDashboard', | ||
| 91 | request => $request, | ||
| 92 | response_class => $response_class, | ||
| 93 | }); | ||
| 94 | } | ||
| 95 | |||
| 96 | my $response = $self->transport->call({ | ||
| 97 | service => 'google.monitoring.dashboard.v1.DashboardsService', | ||
| 98 | method => 'CreateDashboard', | ||
| 99 | request => $request, | ||
| 100 | response_class => $response_class, | ||
| 101 | }); | ||
| 102 | |||
| 103 | return $response; | ||
| 104 | } | ||
| 105 | 1; # End of Google::Cloud::Monitoring::Dashboard::V1::DashboardsServiceClient | ||
| 106 | |||
| 107 | __END__ | ||