App Engine Python SDK version 1.8.9
[gae.git] / python / php / sdk / google / appengine / runtime / RealApiProxy.php
blob84be23d6e58b1814d1fe79d61abcd52d12f930f9
1 <?php
2 /**
3 * Copyright 2007 Google Inc.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 namespace google\appengine\runtime;
19 class RealApiProxy extends ApiProxyBase {
20 // Specifying a value of -1.0 for the default deadline ensures that the
21 // default for each package is used when making the call in the App Server.
22 const DEFAULT_DEADLINE_VALUE = -1.0;
23 /**
24 * Makes a synchronous RPC call.
25 * @param string $package Package to call
26 * @param string $call_name Specific RPC call to make
27 * @param string $request Request proto, serialised to string
28 * @param string $response Response proto string to populate
29 * @param double $deadline Optional deadline for the RPC call
31 public function makeSyncCall(
32 $package,
33 $call_name,
34 $request,
35 $response,
36 $deadline = null) {
37 if ($deadline === null) {
38 $deadline = self::DEFAULT_DEADLINE_VALUE;
41 $result_array = array();
43 \make_call($package,
44 $call_name,
45 $request->serializeToString(),
46 $result_array,
47 null,
48 $deadline);
50 $error_no = $result_array['error'];
52 if ($error_no === ApiProxyBase::APPLICATION_ERROR) {
53 throw new ApplicationError(
54 $result_array['application_error'],
55 $result_array['error_detail']);
58 if ($error_no === ApiProxyBase::CAPABILITY_DISABLED) {
59 if (isset($result_array['error_detail'])) {
60 $msg = $result_array['error_detail'];
61 } else {
62 $msg = sprintf('The API call %s.%s() is temporarily unavailable.',
63 $package, $call_name);
65 throw new CapabilityDisabledError($msg);
68 if ($error_no === ApiProxyBase::FEATURE_DISABLED) {
69 throw new FeatureNotEnabledError($result_array['error_detail']);
72 if (isset(ApiProxyBase::$exceptionLookupTable[$error_no])) {
73 $res = ApiProxyBase::$exceptionLookupTable[$error_no];
74 throw new $res[0](sprintf($res[1], $package, $call_name));
77 $response->parseFromString($result_array['result_string']);