| 1 | package Google::Cloud::Identitytoolkit::V2; | ||
| 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::Identitytoolkit::V2::MfaInfo; | ||
| 14 | use Google::Cloud::Identitytoolkit::V2::AccountManagementService; | ||
| 15 | use Google::Cloud::Identitytoolkit::V2::AuthenticationService; | ||
| 16 | |||
| 17 | our $VERSION = '0.06'; | ||
| 18 | |||
| 19 | has credentials => ( is => 'ro', required => 0 ); | ||
| 20 | has transport => ( is => 'rw' ); | ||
| 21 | |||
| 22 | sub BUILD { | ||
| 23 | my ($self) = @_; | ||
| 24 | |||
| 25 | my $auth = $self->credentials; | ||
| 26 | if (!defined $auth) { | ||
| 27 | $auth = Google::Auth->default(); | ||
| 28 | } elsif (!eval { $auth->can('get_token') }) { | ||
| 29 | croak 'Invalid credentials object: must implement get_token()'; | ||
| 30 | } | ||
| 31 | my $token = $auth->get_token(); | ||
| 32 | |||
| 33 | my $target = 'identitytoolkit.googleapis.com:443'; | ||
| 34 | my $t = $self->transport || 'grpc'; | ||
| 35 | |||
| 36 | if (ref($t) && eval { $t->can('call') }) { | ||
| 37 | # Already a transport object | ||
| 38 | } elsif (lc($t) eq 'rest') { | ||
| 39 | my $client = Google::Cloud::REST::Client->new( | ||
| 40 | target => $target, | ||
| 41 | auth_token => $token, | ||
| 42 | ); | ||
| 43 | $self->transport($client); | ||
| 44 | } else { | ||
| 45 | my $client = Google::gRPC::Client->new( | ||
| 46 | target => $target, | ||
| 47 | auth_token => $token, | ||
| 48 | ); | ||
| 49 | $self->transport($client); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | sub finalize_mfa_enrollment { | ||
| 54 | my ($self, %params) = @_; | ||
| 55 | |||
| 56 | my $request_class = 'Google::Cloud::Identitytoolkit::V2::AccountManagementService::FinalizeMfaEnrollmentRequest'; | ||
| 57 | my $request = eval { $request_class->new(\%params) }; | ||
| 58 | my $new_err = $@; | ||
| 59 | if (!$request) { | ||
| 60 | $request = eval { $request_class->new(%params) }; | ||
| 61 | $new_err ||= $@; | ||
| 62 | } | ||
| 63 | if (!$request) { | ||
| 64 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 65 | } | ||
| 66 | |||
| 67 | my $response_class = 'Google::Cloud::Identitytoolkit::V2::AccountManagementService::FinalizeMfaEnrollmentResponse'; | ||
| 68 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 69 | return $self->transport->call({ | ||
| 70 | http_method => 'POST', | ||
| 71 | path => '/google.cloud.identitytoolkit.v2.AccountManagementService/FinalizeMfaEnrollment', | ||
| 72 | request => $request, | ||
| 73 | response_class => $response_class, | ||
| 74 | }); | ||
| 75 | } | ||
| 76 | |||
| 77 | my $response = $self->transport->call({ | ||
| 78 | service => 'google.cloud.identitytoolkit.v2.AccountManagementService', | ||
| 79 | method => 'FinalizeMfaEnrollment', | ||
| 80 | request => $request, | ||
| 81 | response_class => $response_class, | ||
| 82 | }); | ||
| 83 | |||
| 84 | return $response; | ||
| 85 | } | ||
| 86 | |||
| 87 | sub start_mfa_enrollment { | ||
| 88 | my ($self, %params) = @_; | ||
| 89 | |||
| 90 | my $request_class = 'Google::Cloud::Identitytoolkit::V2::AccountManagementService::StartMfaEnrollmentRequest'; | ||
| 91 | my $request = eval { $request_class->new(\%params) }; | ||
| 92 | my $new_err = $@; | ||
| 93 | if (!$request) { | ||
| 94 | $request = eval { $request_class->new(%params) }; | ||
| 95 | $new_err ||= $@; | ||
| 96 | } | ||
| 97 | if (!$request) { | ||
| 98 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 99 | } | ||
| 100 | |||
| 101 | my $response_class = 'Google::Cloud::Identitytoolkit::V2::AccountManagementService::StartMfaEnrollmentResponse'; | ||
| 102 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 103 | return $self->transport->call({ | ||
| 104 | http_method => 'POST', | ||
| 105 | path => '/google.cloud.identitytoolkit.v2.AccountManagementService/StartMfaEnrollment', | ||
| 106 | request => $request, | ||
| 107 | response_class => $response_class, | ||
| 108 | }); | ||
| 109 | } | ||
| 110 | |||
| 111 | my $response = $self->transport->call({ | ||
| 112 | service => 'google.cloud.identitytoolkit.v2.AccountManagementService', | ||
| 113 | method => 'StartMfaEnrollment', | ||
| 114 | request => $request, | ||
| 115 | response_class => $response_class, | ||
| 116 | }); | ||
| 117 | |||
| 118 | return $response; | ||
| 119 | } | ||
| 120 | |||
| 121 | sub withdraw_mfa { | ||
| 122 | my ($self, %params) = @_; | ||
| 123 | |||
| 124 | my $request_class = 'Google::Cloud::Identitytoolkit::V2::AccountManagementService::WithdrawMfaRequest'; | ||
| 125 | my $request = eval { $request_class->new(\%params) }; | ||
| 126 | my $new_err = $@; | ||
| 127 | if (!$request) { | ||
| 128 | $request = eval { $request_class->new(%params) }; | ||
| 129 | $new_err ||= $@; | ||
| 130 | } | ||
| 131 | if (!$request) { | ||
| 132 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 133 | } | ||
| 134 | |||
| 135 | my $response_class = 'Google::Cloud::Identitytoolkit::V2::AccountManagementService::WithdrawMfaResponse'; | ||
| 136 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 137 | return $self->transport->call({ | ||
| 138 | http_method => 'POST', | ||
| 139 | path => '/google.cloud.identitytoolkit.v2.AccountManagementService/WithdrawMfa', | ||
| 140 | request => $request, | ||
| 141 | response_class => $response_class, | ||
| 142 | }); | ||
| 143 | } | ||
| 144 | |||
| 145 | my $response = $self->transport->call({ | ||
| 146 | service => 'google.cloud.identitytoolkit.v2.AccountManagementService', | ||
| 147 | method => 'WithdrawMfa', | ||
| 148 | request => $request, | ||
| 149 | response_class => $response_class, | ||
| 150 | }); | ||
| 151 | |||
| 152 | return $response; | ||
| 153 | } | ||
| 154 | |||
| 155 | sub finalize_mfa_sign_in { | ||
| 156 | my ($self, %params) = @_; | ||
| 157 | |||
| 158 | my $request_class = 'Google::Cloud::Identitytoolkit::V2::AuthenticationService::FinalizeMfaSignInRequest'; | ||
| 159 | my $request = eval { $request_class->new(\%params) }; | ||
| 160 | my $new_err = $@; | ||
| 161 | if (!$request) { | ||
| 162 | $request = eval { $request_class->new(%params) }; | ||
| 163 | $new_err ||= $@; | ||
| 164 | } | ||
| 165 | if (!$request) { | ||
| 166 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 167 | } | ||
| 168 | |||
| 169 | my $response_class = 'Google::Cloud::Identitytoolkit::V2::AuthenticationService::FinalizeMfaSignInResponse'; | ||
| 170 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 171 | return $self->transport->call({ | ||
| 172 | http_method => 'POST', | ||
| 173 | path => '/google.cloud.identitytoolkit.v2.AuthenticationService/FinalizeMfaSignIn', | ||
| 174 | request => $request, | ||
| 175 | response_class => $response_class, | ||
| 176 | }); | ||
| 177 | } | ||
| 178 | |||
| 179 | my $response = $self->transport->call({ | ||
| 180 | service => 'google.cloud.identitytoolkit.v2.AuthenticationService', | ||
| 181 | method => 'FinalizeMfaSignIn', | ||
| 182 | request => $request, | ||
| 183 | response_class => $response_class, | ||
| 184 | }); | ||
| 185 | |||
| 186 | return $response; | ||
| 187 | } | ||
| 188 | |||
| 189 | sub start_mfa_sign_in { | ||
| 190 | my ($self, %params) = @_; | ||
| 191 | |||
| 192 | my $request_class = 'Google::Cloud::Identitytoolkit::V2::AuthenticationService::StartMfaSignInRequest'; | ||
| 193 | my $request = eval { $request_class->new(\%params) }; | ||
| 194 | my $new_err = $@; | ||
| 195 | if (!$request) { | ||
| 196 | $request = eval { $request_class->new(%params) }; | ||
| 197 | $new_err ||= $@; | ||
| 198 | } | ||
| 199 | if (!$request) { | ||
| 200 | croak 'Failed to construct ' . $request_class . ': ' . ($new_err || 'unknown error'); | ||
| 201 | } | ||
| 202 | |||
| 203 | my $response_class = 'Google::Cloud::Identitytoolkit::V2::AuthenticationService::StartMfaSignInResponse'; | ||
| 204 | if (eval { $self->transport->isa('Google::Cloud::REST::Client') }) { | ||
| 205 | return $self->transport->call({ | ||
| 206 | http_method => 'POST', | ||
| 207 | path => '/google.cloud.identitytoolkit.v2.AuthenticationService/StartMfaSignIn', | ||
| 208 | request => $request, | ||
| 209 | response_class => $response_class, | ||
| 210 | }); | ||
| 211 | } | ||
| 212 | |||
| 213 | my $response = $self->transport->call({ | ||
| 214 | service => 'google.cloud.identitytoolkit.v2.AuthenticationService', | ||
| 215 | method => 'StartMfaSignIn', | ||
| 216 | request => $request, | ||
| 217 | response_class => $response_class, | ||
| 218 | }); | ||
| 219 | |||
| 220 | return $response; | ||
| 221 | } | ||
| 222 | 1; # End of Google::Cloud::Identitytoolkit::V2 | ||
| 223 | |||
| 224 | __END__ | ||