| 1 | package Google::Cloud::Sql::V1beta4::BlueGreenDeploymentsServiceClient; | ||
| 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::Sql::V1beta4::CloudSqlIamPolicies; | ||
| 14 | use Google::Cloud::Sql::V1beta4::CloudSqlTiers; | ||
| 15 | use Google::Cloud::Sql::V1beta4::CloudSqlData; | ||
| 16 | use Google::Cloud::Sql::V1beta4::CloudSqlResources; | ||
| 17 | use Google::Cloud::Sql::V1beta4::CloudSqlBlueGreenDeployments; | ||
| 18 | use Google::Cloud::Sql::V1beta4::CloudSql; | ||
| 19 | use Google::Cloud::Sql::V1beta4::CloudSqlUsers; | ||
| 20 | use Google::Cloud::Sql::V1beta4::CloudSqlWorkloadCaptures; | ||
| 21 | use Google::Cloud::Sql::V1beta4::CloudSqlConnect; | ||
| 22 | |||
| 23 | our $VERSION = '0.06'; | ||
| 24 | |||
| 25 | has credentials => ( is => 'ro', required => 0 ); | ||
| 26 | has transport => ( is => 'rw' ); | ||
| 27 | |||
| 28 | sub BUILD { | ||
| 29 | my ($self) = @_; | ||
| 30 | |||
| 31 | my $auth = $self->credentials; | ||
| 32 | if (!defined $auth) { | ||
| 33 | $auth = Google::Auth->default(); | ||
| 34 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 35 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 36 | } | ||
| 37 | my $token = $auth->get_token(); | ||
| 38 | |||
| 39 | my $target = 'sqladmin.googleapis.com:443'; | ||
| 40 | my $t = $self->transport || 'grpc'; | ||
| 41 | |||
| 42 | if (ref($t) && eval { $t->can('call') }) { | ||
| 43 | # Already a transport object | ||
| 44 | } elsif (lc($t) eq 'rest') { | ||
| 45 | my $client = Google::Cloud::REST::Client->new( | ||
| 46 | target => $target, | ||
| 47 | auth_token => $token, | ||
| 48 | ); | ||
| 49 | $self->transport($client); | ||
| 50 | } else { | ||
| 51 | my $client = Google::gRPC::Client->new( | ||
| 52 | target => $target, | ||
| 53 | auth_token => $token, | ||
| 54 | ); | ||
| 55 | $self->transport($client); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | sub create_blue_green_deployment { | ||
| 60 | my ($self, %params) = @_; | ||
| 61 | |||
| 62 | my $request_class = 'Google::Cloud::Sql::V1beta4::CloudSqlBlueGreenDeployments::CreateBlueGreenDeploymentRequest'; | ||
| 63 | my $request = eval { $request_class->new(\%params) }; | ||
| 64 | my $new_err = $@; | ||
| 65 | if (!$request) { | ||
| 66 | $request = eval { $request_class->new(%params) }; | ||
| 67 | $new_err ||= $@; | ||
| 68 | } | ||
| 69 | if (!$request) { | ||
| 70 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 71 | } | ||
| 72 | |||
| 73 | my $response_class = 'Google::Cloud::Sql::V1beta4::CloudSqlResources::Operation'; | ||
| 74 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 75 | return $self->transport->call({ | ||
| 76 | http_method => 'POST', | ||
| 77 | path => '/google.cloud.sql.v1beta4.BlueGreenDeploymentsService/CreateBlueGreenDeployment', | ||
| 78 | request => $request, | ||
| 79 | response_class => $response_class, | ||
| 80 | }); | ||
| 81 | } | ||
| 82 | |||
| 83 | my $response = $self->transport->call({ | ||
| 84 | service => 'google.cloud.sql.v1beta4.BlueGreenDeploymentsService', | ||
| 85 | method => 'CreateBlueGreenDeployment', | ||
| 86 | request => $request, | ||
| 87 | response_class => $response_class, | ||
| 88 | }); | ||
| 89 | |||
| 90 | return $response; | ||
| 91 | } | ||
| 92 | 1; # End of Google::Cloud::Sql::V1beta4::BlueGreenDeploymentsServiceClient | ||
| 93 | |||
| 94 | __END__ | ||