| 1 | package Google::Cloud::Backupdr::V1; | ||
| 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::Backupdr::V1::BackupvaultBa; | ||
| 14 | use Google::Cloud::Backupdr::V1::RestoreTemplateCommon; | ||
| 15 | use Google::Cloud::Backupdr::V1::BackupvaultCloudsql; | ||
| 16 | use Google::Cloud::Backupdr::V1::Autoprotectionpolicy; | ||
| 17 | use Google::Cloud::Backupdr::V1::ProtectionSummary; | ||
| 18 | use Google::Cloud::Backupdr::V1::RestoreVerificationPlan; | ||
| 19 | use Google::Cloud::Backupdr::V1::BackupvaultAlloydb; | ||
| 20 | use Google::Cloud::Backupdr::V1::Autoprotectionpolicybinding; | ||
| 21 | use Google::Cloud::Backupdr::V1::BackupvaultGce; | ||
| 22 | use Google::Cloud::Backupdr::V1::Bindingmatchingresource; | ||
| 23 | use Google::Cloud::Backupdr::V1::RestoreVerificationPlanAssociation; | ||
| 24 | use Google::Cloud::Backupdr::V1::Backupplan; | ||
| 25 | use Google::Cloud::Backupdr::V1::RestoreTemplateExecution; | ||
| 26 | use Google::Cloud::Backupdr::V1::Backupplanassociation; | ||
| 27 | use Google::Cloud::Backupdr::V1::Appliedautoprotectionpolicy; | ||
| 28 | use Google::Cloud::Backupdr::V1::BackupvaultDisk; | ||
| 29 | use Google::Cloud::Backupdr::V1::RestoreTemplate; | ||
| 30 | use Google::Cloud::Backupdr::V1::Backupvault; | ||
| 31 | use Google::Cloud::Backupdr::V1::Datasourcereference; | ||
| 32 | use Google::Cloud::Backupdr::V1::Backupdr; | ||
| 33 | |||
| 34 | our $VERSION = '0.06'; | ||
| 35 | |||
| 36 | has credentials => ( is => 'ro', required => 0 ); | ||
| 37 | has transport => ( is => 'rw' ); | ||
| 38 | |||
| 39 | sub BUILD { | ||
| 40 | my ($self) = @_; | ||
| 41 | |||
| 42 | my $auth = $self->credentials; | ||
| 43 | if (!defined $auth) { | ||
| 44 | $auth = Google::Auth->default(); | ||
| 45 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 46 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 47 | } | ||
| 48 | my $token = $auth->get_token(); | ||
| 49 | |||
| 50 | my $target = 'backupdr.googleapis.com:443'; | ||
| 51 | my $t = $self->transport || 'grpc'; | ||
| 52 | |||
| 53 | if (ref($t) && eval { $t->can('call') }) { | ||
| 54 | # Already a transport object | ||
| 55 | } elsif (lc($t) eq 'rest') { | ||
| 56 | my $client = Google::Cloud::REST::Client->new( | ||
| 57 | target => $target, | ||
| 58 | auth_token => $token, | ||
| 59 | ); | ||
| 60 | $self->transport($client); | ||
| 61 | } else { | ||
| 62 | my $client = Google::gRPC::Client->new( | ||
| 63 | target => $target, | ||
| 64 | auth_token => $token, | ||
| 65 | ); | ||
| 66 | $self->transport($client); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | sub list_management_servers { | ||
| 71 | my ($self, %params) = @_; | ||
| 72 | |||
| 73 | my $request_class = 'Google::Cloud::Backupdr::V1::Backupdr::ListManagementServersRequest'; | ||
| 74 | my $request = eval { $request_class->new(\%params) }; | ||
| 75 | my $new_err = $@; | ||
| 76 | if (!$request) { | ||
| 77 | $request = eval { $request_class->new(%params) }; | ||
| 78 | $new_err ||= $@; | ||
| 79 | } | ||
| 80 | if (!$request) { | ||
| 81 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 82 | } | ||
| 83 | |||
| 84 | my $response_class = 'Google::Cloud::Backupdr::V1::Backupdr::ListManagementServersResponse'; | ||
| 85 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 86 | return $self->transport->call({ | ||
| 87 | http_method => 'POST', | ||
| 88 | path => '/google.cloud.backupdr.v1.BackupDR/ListManagementServers', | ||
| 89 | request => $request, | ||
| 90 | response_class => $response_class, | ||
| 91 | }); | ||
| 92 | } | ||
| 93 | |||
| 94 | my $response = $self->transport->call({ | ||
| 95 | service => 'google.cloud.backupdr.v1.BackupDR', | ||
| 96 | method => 'ListManagementServers', | ||
| 97 | request => $request, | ||
| 98 | response_class => $response_class, | ||
| 99 | }); | ||
| 100 | |||
| 101 | return $response; | ||
| 102 | } | ||
| 103 | |||
| 104 | sub list_resource_backup_configs { | ||
| 105 | my ($self, %params) = @_; | ||
| 106 | |||
| 107 | my $request_class = 'Google::Cloud::Backupdr::V1::ProtectionSummary::ListResourceBackupConfigsRequest'; | ||
| 108 | my $request = eval { $request_class->new(\%params) }; | ||
| 109 | my $new_err = $@; | ||
| 110 | if (!$request) { | ||
| 111 | $request = eval { $request_class->new(%params) }; | ||
| 112 | $new_err ||= $@; | ||
| 113 | } | ||
| 114 | if (!$request) { | ||
| 115 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 116 | } | ||
| 117 | |||
| 118 | my $response_class = 'Google::Cloud::Backupdr::V1::ProtectionSummary::ListResourceBackupConfigsResponse'; | ||
| 119 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 120 | return $self->transport->call({ | ||
| 121 | http_method => 'POST', | ||
| 122 | path => '/google.cloud.backupdr.v1.BackupDrProtectionSummary/ListResourceBackupConfigs', | ||
| 123 | request => $request, | ||
| 124 | response_class => $response_class, | ||
| 125 | }); | ||
| 126 | } | ||
| 127 | |||
| 128 | my $response = $self->transport->call({ | ||
| 129 | service => 'google.cloud.backupdr.v1.BackupDrProtectionSummary', | ||
| 130 | method => 'ListResourceBackupConfigs', | ||
| 131 | request => $request, | ||
| 132 | response_class => $response_class, | ||
| 133 | }); | ||
| 134 | |||
| 135 | return $response; | ||
| 136 | } | ||
| 137 | 1; # End of Google::Cloud::Backupdr::V1 | ||
| 138 | |||
| 139 | __END__ | ||