diff --git a/composer.json b/composer.json index 0d25bd23..1fd79c59 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ "forum": "https://groups.google.com/forum/#!forum/google-appengine" }, "require": { - "php": ">=5.4.0" + "php": ">=5.4.0", + "google/protobuf": "^3.15" }, "require-dev": { "mikey179/vfsstream": "~1", @@ -19,7 +20,8 @@ }, "autoload": { "psr-4": { - "Google\\AppEngine\\": "src" + "Google\\AppEngine\\": "src", + "GPBMetadata\\": "metadata" }, "files": [ "src/aliases.php" @@ -28,7 +30,6 @@ "src/Api/api_base_pb.php", "src/Api/Memcache/memcache_service_pb.php", "src/Api/Urlfetch/urlfetch_service_pb.php", - "src/Api/AppIdentity/app_identity_service_pb.php", "src/Datastore/action_pb.php", "src/Datastore/datastore_v3_pb.php", "src/Datastore/datastore_v4_pb.php", diff --git a/metadata/AppIdentityService.php b/metadata/AppIdentityService.php new file mode 100644 index 00000000..70fef399 Binary files /dev/null and b/metadata/AppIdentityService.php differ diff --git a/src/Api/AppIdentity/AppIdentityService.php b/src/Api/AppIdentity/AppIdentityService.php index 982b6f75..ac39f759 100644 --- a/src/Api/AppIdentity/AppIdentityService.php +++ b/src/Api/AppIdentity/AppIdentityService.php @@ -20,15 +20,15 @@ namespace Google\AppEngine\Api\AppIdentity; -use google\appengine\AppIdentityServiceError\ErrorCode; -use google\appengine\GetAccessTokenRequest; -use google\appengine\GetAccessTokenResponse; -use google\appengine\GetPublicCertificateForAppRequest; -use google\appengine\GetPublicCertificateForAppResponse; -use google\appengine\GetServiceAccountNameRequest; -use google\appengine\GetServiceAccountNameResponse; -use google\appengine\SignForAppRequest; -use google\appengine\SignForAppResponse; +use Google\AppEngine\Api\AppIdentity\AppIdentityServiceError\ErrorCode; +use Google\AppEngine\Api\AppIdentity\GetAccessTokenRequest; +use Google\AppEngine\Api\AppIdentity\GetAccessTokenResponse; +use Google\AppEngine\Api\AppIdentity\GetPublicCertificateForAppRequest; +use Google\AppEngine\Api\AppIdentity\GetPublicCertificateForAppResponse; +use Google\AppEngine\Api\AppIdentity\GetServiceAccountNameRequest; +use Google\AppEngine\Api\AppIdentity\GetServiceAccountNameResponse; +use Google\AppEngine\Api\AppIdentity\SignForAppRequest; +use Google\AppEngine\Api\AppIdentity\SignForAppResponse; use Google\AppEngine\Runtime\ApiProxy; use Google\AppEngine\Runtime\ApplicationError; use Google\AppEngine\Runtime\Memcache; @@ -137,9 +137,11 @@ public static function getPublicCertificates() { $result = []; - foreach ($resp->getPublicCertificateListList() as $cert) { - $result[] = new PublicCertificate($cert->getKeyName(), - $cert->getX509CertificatePem()); + foreach ($resp->getPublicCertificateList() as $cert) { + $pub_cert = new PublicCertificate(); + $pub_cert->setKeyName($cert->getKeyName()); + $pub_cert->setX509CertificatePem($cert->getX509CertificatePem()); + $result[] = $pub_cert; } return $result; @@ -212,16 +214,15 @@ private static function getAccessTokenUncached($scopes) { $resp = new GetAccessTokenResponse(); if (is_string($scopes)) { - $req->addScope($scopes); + $req->setScope([$scopes]); } else if (is_array($scopes)) { foreach($scopes as $scope) { - if (is_string($scope)) { - $req->addScope($scope); - } else { + if (!is_string($scope)) { throw new \InvalidArgumentException( 'Invalid scope ' . htmlspecialchars($scope)); } } + $req->setScope($scopes); } else { throw new \InvalidArgumentException( 'Invalid scope ' . htmlspecialchars($scopes)); diff --git a/src/Api/AppIdentity/AppIdentityServiceError.php b/src/Api/AppIdentity/AppIdentityServiceError.php new file mode 100644 index 00000000..86b34ebc --- /dev/null +++ b/src/Api/AppIdentity/AppIdentityServiceError.php @@ -0,0 +1,31 @@ +google.appEngine.api.appIdentity.AppIdentityServiceError + */ +class AppIdentityServiceError extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + +} + diff --git a/src/Api/AppIdentity/AppIdentityServiceError/ErrorCode.php b/src/Api/AppIdentity/AppIdentityServiceError/ErrorCode.php new file mode 100644 index 00000000..0b84a00e --- /dev/null +++ b/src/Api/AppIdentity/AppIdentityServiceError/ErrorCode.php @@ -0,0 +1,96 @@ +google.appEngine.api.appIdentity.AppIdentityServiceError.ErrorCode + */ +class ErrorCode +{ + /** + * Errors with low numbers are from gaiamintservice.proto. + * Only a few are copied here as this is visible externally. + * + * Generated from protobuf enum SUCCESS = 0; + */ + const SUCCESS = 0; + /** + * Generated from protobuf enum UNKNOWN_SCOPE = 9; + */ + const UNKNOWN_SCOPE = 9; + /** + * Errors 1000 and higher are unique to this service. + * + * Generated from protobuf enum BLOB_TOO_LARGE = 1000; + */ + const BLOB_TOO_LARGE = 1000; + /** + * Generated from protobuf enum DEADLINE_EXCEEDED = 1001; + */ + const DEADLINE_EXCEEDED = 1001; + /** + * Generated from protobuf enum NOT_A_VALID_APP = 1002; + */ + const NOT_A_VALID_APP = 1002; + /** + * Generated from protobuf enum UNKNOWN_ERROR = 1003; + */ + const UNKNOWN_ERROR = 1003; + /** + * Generated from protobuf enum GAIAMINT_NOT_INITIAILIZED = 1004; + */ + const GAIAMINT_NOT_INITIAILIZED = 1004; + /** + * Generated from protobuf enum NOT_ALLOWED = 1005; + */ + const NOT_ALLOWED = 1005; + /** + * Generated from protobuf enum NOT_IMPLEMENTED = 1006; + */ + const NOT_IMPLEMENTED = 1006; + + private static $valueToName = [ + self::SUCCESS => 'SUCCESS', + self::UNKNOWN_SCOPE => 'UNKNOWN_SCOPE', + self::BLOB_TOO_LARGE => 'BLOB_TOO_LARGE', + self::DEADLINE_EXCEEDED => 'DEADLINE_EXCEEDED', + self::NOT_A_VALID_APP => 'NOT_A_VALID_APP', + self::UNKNOWN_ERROR => 'UNKNOWN_ERROR', + self::GAIAMINT_NOT_INITIAILIZED => 'GAIAMINT_NOT_INITIAILIZED', + self::NOT_ALLOWED => 'NOT_ALLOWED', + self::NOT_IMPLEMENTED => 'NOT_IMPLEMENTED', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(ErrorCode::class, \Google\AppEngine\Api\AppIdentity\AppIdentityServiceError_ErrorCode::class); + diff --git a/src/Api/AppIdentity/AppIdentityServiceError_ErrorCode.php b/src/Api/AppIdentity/AppIdentityServiceError_ErrorCode.php new file mode 100644 index 00000000..7260d033 --- /dev/null +++ b/src/Api/AppIdentity/AppIdentityServiceError_ErrorCode.php @@ -0,0 +1,16 @@ +google.appEngine.api.appIdentity.GetAccessTokenRequest + */ +class GetAccessTokenRequest extends \Google\Protobuf\Internal\Message +{ + /** + * At the moment the 'id' and 'name' fields are used only for superapps. + * However if/when we support multiple robot for a single app, they will + * will be used to select the appropriate account. + * + * Generated from protobuf field repeated string scope = 1; + */ + private $scope; + /** + * TODO(wlhe): reserve these two fields once all the depending codes + * are removed. + * + * Generated from protobuf field int64 service_account_id = 2; + */ + protected $service_account_id = null; + /** + * Service account name is superapp only, and only a refresh token of the + * form r:refresh token is supported. + * + * Generated from protobuf field string service_account_name = 3 [deprecated = true]; + * @deprecated + */ + protected $service_account_name = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string[]|\Google\Protobuf\Internal\RepeatedField $scope + * At the moment the 'id' and 'name' fields are used only for superapps. + * However if/when we support multiple robot for a single app, they will + * will be used to select the appropriate account. + * @type int|string $service_account_id + * TODO(wlhe): reserve these two fields once all the depending codes + * are removed. + * @type string $service_account_name + * Service account name is superapp only, and only a refresh token of the + * form r:refresh token is supported. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * At the moment the 'id' and 'name' fields are used only for superapps. + * However if/when we support multiple robot for a single app, they will + * will be used to select the appropriate account. + * + * Generated from protobuf field repeated string scope = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getScope() + { + return $this->scope; + } + + /** + * At the moment the 'id' and 'name' fields are used only for superapps. + * However if/when we support multiple robot for a single app, they will + * will be used to select the appropriate account. + * + * Generated from protobuf field repeated string scope = 1; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setScope($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->scope = $arr; + + return $this; + } + + /** + * TODO(wlhe): reserve these two fields once all the depending codes + * are removed. + * + * Generated from protobuf field int64 service_account_id = 2; + * @return int|string + */ + public function getServiceAccountId() + { + return isset($this->service_account_id) ? $this->service_account_id : 0; + } + + public function hasServiceAccountId() + { + return isset($this->service_account_id); + } + + public function clearServiceAccountId() + { + unset($this->service_account_id); + } + + /** + * TODO(wlhe): reserve these two fields once all the depending codes + * are removed. + * + * Generated from protobuf field int64 service_account_id = 2; + * @param int|string $var + * @return $this + */ + public function setServiceAccountId($var) + { + GPBUtil::checkInt64($var); + $this->service_account_id = $var; + + return $this; + } + + /** + * Service account name is superapp only, and only a refresh token of the + * form r:refresh token is supported. + * + * Generated from protobuf field string service_account_name = 3 [deprecated = true]; + * @return string + * @deprecated + */ + public function getServiceAccountName() + { + @trigger_error('service_account_name is deprecated.', E_USER_DEPRECATED); + return isset($this->service_account_name) ? $this->service_account_name : ''; + } + + public function hasServiceAccountName() + { + @trigger_error('service_account_name is deprecated.', E_USER_DEPRECATED); + return isset($this->service_account_name); + } + + public function clearServiceAccountName() + { + @trigger_error('service_account_name is deprecated.', E_USER_DEPRECATED); + unset($this->service_account_name); + } + + /** + * Service account name is superapp only, and only a refresh token of the + * form r:refresh token is supported. + * + * Generated from protobuf field string service_account_name = 3 [deprecated = true]; + * @param string $var + * @return $this + * @deprecated + */ + public function setServiceAccountName($var) + { + @trigger_error('service_account_name is deprecated.', E_USER_DEPRECATED); + GPBUtil::checkString($var, True); + $this->service_account_name = $var; + + return $this; + } + +} + diff --git a/src/Api/AppIdentity/GetAccessTokenResponse.php b/src/Api/AppIdentity/GetAccessTokenResponse.php new file mode 100644 index 00000000..5d25db82 --- /dev/null +++ b/src/Api/AppIdentity/GetAccessTokenResponse.php @@ -0,0 +1,112 @@ +google.appEngine.api.appIdentity.GetAccessTokenResponse + */ +class GetAccessTokenResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string access_token = 1; + */ + protected $access_token = null; + /** + * Seconds since the epoch. + * + * Generated from protobuf field int64 expiration_time = 2; + */ + protected $expiration_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $access_token + * @type int|string $expiration_time + * Seconds since the epoch. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string access_token = 1; + * @return string + */ + public function getAccessToken() + { + return isset($this->access_token) ? $this->access_token : ''; + } + + public function hasAccessToken() + { + return isset($this->access_token); + } + + public function clearAccessToken() + { + unset($this->access_token); + } + + /** + * Generated from protobuf field string access_token = 1; + * @param string $var + * @return $this + */ + public function setAccessToken($var) + { + GPBUtil::checkString($var, True); + $this->access_token = $var; + + return $this; + } + + /** + * Seconds since the epoch. + * + * Generated from protobuf field int64 expiration_time = 2; + * @return int|string + */ + public function getExpirationTime() + { + return isset($this->expiration_time) ? $this->expiration_time : 0; + } + + public function hasExpirationTime() + { + return isset($this->expiration_time); + } + + public function clearExpirationTime() + { + unset($this->expiration_time); + } + + /** + * Seconds since the epoch. + * + * Generated from protobuf field int64 expiration_time = 2; + * @param int|string $var + * @return $this + */ + public function setExpirationTime($var) + { + GPBUtil::checkInt64($var); + $this->expiration_time = $var; + + return $this; + } + +} + diff --git a/src/Api/AppIdentity/GetDefaultGcsBucketNameRequest.php b/src/Api/AppIdentity/GetDefaultGcsBucketNameRequest.php new file mode 100644 index 00000000..d5bf59a8 --- /dev/null +++ b/src/Api/AppIdentity/GetDefaultGcsBucketNameRequest.php @@ -0,0 +1,33 @@ +google.appEngine.api.appIdentity.GetDefaultGcsBucketNameRequest + */ +class GetDefaultGcsBucketNameRequest extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + +} + diff --git a/src/Api/AppIdentity/GetDefaultGcsBucketNameResponse.php b/src/Api/AppIdentity/GetDefaultGcsBucketNameResponse.php new file mode 100644 index 00000000..8f8bcda2 --- /dev/null +++ b/src/Api/AppIdentity/GetDefaultGcsBucketNameResponse.php @@ -0,0 +1,75 @@ +google.appEngine.api.appIdentity.GetDefaultGcsBucketNameResponse + */ +class GetDefaultGcsBucketNameResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The default google storage bucket name for the application. + * + * Generated from protobuf field string default_gcs_bucket_name = 1; + */ + protected $default_gcs_bucket_name = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $default_gcs_bucket_name + * The default google storage bucket name for the application. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * The default google storage bucket name for the application. + * + * Generated from protobuf field string default_gcs_bucket_name = 1; + * @return string + */ + public function getDefaultGcsBucketName() + { + return isset($this->default_gcs_bucket_name) ? $this->default_gcs_bucket_name : ''; + } + + public function hasDefaultGcsBucketName() + { + return isset($this->default_gcs_bucket_name); + } + + public function clearDefaultGcsBucketName() + { + unset($this->default_gcs_bucket_name); + } + + /** + * The default google storage bucket name for the application. + * + * Generated from protobuf field string default_gcs_bucket_name = 1; + * @param string $var + * @return $this + */ + public function setDefaultGcsBucketName($var) + { + GPBUtil::checkString($var, True); + $this->default_gcs_bucket_name = $var; + + return $this; + } + +} + diff --git a/src/Api/AppIdentity/GetPublicCertificateForAppRequest.php b/src/Api/AppIdentity/GetPublicCertificateForAppRequest.php new file mode 100644 index 00000000..78dc5e69 --- /dev/null +++ b/src/Api/AppIdentity/GetPublicCertificateForAppRequest.php @@ -0,0 +1,33 @@ +google.appEngine.api.appIdentity.GetPublicCertificateForAppRequest + */ +class GetPublicCertificateForAppRequest extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + +} + diff --git a/src/Api/AppIdentity/GetPublicCertificateForAppResponse.php b/src/Api/AppIdentity/GetPublicCertificateForAppResponse.php new file mode 100644 index 00000000..8025c5da --- /dev/null +++ b/src/Api/AppIdentity/GetPublicCertificateForAppResponse.php @@ -0,0 +1,95 @@ +google.appEngine.api.appIdentity.GetPublicCertificateForAppResponse + */ +class GetPublicCertificateForAppResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .google.appEngine.api.appIdentity.PublicCertificate public_certificate_list = 1; + */ + private $public_certificate_list; + /** + * Generated from protobuf field int64 max_client_cache_time_in_second = 2; + */ + protected $max_client_cache_time_in_second = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\AppEngine\Api\AppIdentity\PublicCertificate[]|\Google\Protobuf\Internal\RepeatedField $public_certificate_list + * @type int|string $max_client_cache_time_in_second + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field repeated .google.appEngine.api.appIdentity.PublicCertificate public_certificate_list = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPublicCertificateList() + { + return $this->public_certificate_list; + } + + /** + * Generated from protobuf field repeated .google.appEngine.api.appIdentity.PublicCertificate public_certificate_list = 1; + * @param \Google\AppEngine\Api\AppIdentity\PublicCertificate[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPublicCertificateList($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\AppEngine\Api\AppIdentity\PublicCertificate::class); + $this->public_certificate_list = $arr; + + return $this; + } + + /** + * Generated from protobuf field int64 max_client_cache_time_in_second = 2; + * @return int|string + */ + public function getMaxClientCacheTimeInSecond() + { + return isset($this->max_client_cache_time_in_second) ? $this->max_client_cache_time_in_second : 0; + } + + public function hasMaxClientCacheTimeInSecond() + { + return isset($this->max_client_cache_time_in_second); + } + + public function clearMaxClientCacheTimeInSecond() + { + unset($this->max_client_cache_time_in_second); + } + + /** + * Generated from protobuf field int64 max_client_cache_time_in_second = 2; + * @param int|string $var + * @return $this + */ + public function setMaxClientCacheTimeInSecond($var) + { + GPBUtil::checkInt64($var); + $this->max_client_cache_time_in_second = $var; + + return $this; + } + +} + diff --git a/src/Api/AppIdentity/GetServiceAccountNameRequest.php b/src/Api/AppIdentity/GetServiceAccountNameRequest.php new file mode 100644 index 00000000..57764b56 --- /dev/null +++ b/src/Api/AppIdentity/GetServiceAccountNameRequest.php @@ -0,0 +1,33 @@ +google.appEngine.api.appIdentity.GetServiceAccountNameRequest + */ +class GetServiceAccountNameRequest extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + +} + diff --git a/src/Api/AppIdentity/GetServiceAccountNameResponse.php b/src/Api/AppIdentity/GetServiceAccountNameResponse.php new file mode 100644 index 00000000..73aa2ff7 --- /dev/null +++ b/src/Api/AppIdentity/GetServiceAccountNameResponse.php @@ -0,0 +1,68 @@ +google.appEngine.api.appIdentity.GetServiceAccountNameResponse + */ +class GetServiceAccountNameResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string service_account_name = 1; + */ + protected $service_account_name = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $service_account_name + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string service_account_name = 1; + * @return string + */ + public function getServiceAccountName() + { + return isset($this->service_account_name) ? $this->service_account_name : ''; + } + + public function hasServiceAccountName() + { + return isset($this->service_account_name); + } + + public function clearServiceAccountName() + { + unset($this->service_account_name); + } + + /** + * Generated from protobuf field string service_account_name = 1; + * @param string $var + * @return $this + */ + public function setServiceAccountName($var) + { + GPBUtil::checkString($var, True); + $this->service_account_name = $var; + + return $this; + } + +} + diff --git a/src/Api/AppIdentity/PublicCertificate.php b/src/Api/AppIdentity/PublicCertificate.php index 91585292..b541e33f 100644 --- a/src/Api/AppIdentity/PublicCertificate.php +++ b/src/Api/AppIdentity/PublicCertificate.php @@ -1,71 +1,105 @@ google.appEngine.api.appIdentity.PublicCertificate */ -final class PublicCertificate { - - /** - * The name of the certificate. - * @var string - */ - private $certificate_name; - - /** - * The public certificate in X509 PEM format. - * @var string - */ - private $certificate; - - /** - * Creates a new public certificate. - * - * @param string $certificate_name The name of the certificate. - * @param string $certificate_in_pem_format The public certificate in X509 - * PEM format. - */ - public function __construct($certificate_name, - $certificate_in_pem_format) { - $this->certificate_name = $certificate_name; - $this->certificate = $certificate_in_pem_format; - } - - /** - * Returns the name of this public certificate. - * - * @return string The name of the certificate. - */ - public function getCertificateName() { - return $this->certificate_name; - } - - /** - * Returns the X509 Certificate in PEM format. - * - * @return string The public certificate in X509 PEM format. - */ - public function getX509CertificateInPemFormat() { - return $this->certificate; - } +class PublicCertificate extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string key_name = 1; + */ + protected $key_name = null; + /** + * Generated from protobuf field string x509_certificate_pem = 2; + */ + protected $x509_certificate_pem = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $key_name + * @type string $x509_certificate_pem + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string key_name = 1; + * @return string + */ + public function getKeyName() + { + return isset($this->key_name) ? $this->key_name : ''; + } + + public function hasKeyName() + { + return isset($this->key_name); + } + + public function clearKeyName() + { + unset($this->key_name); + } + + /** + * Generated from protobuf field string key_name = 1; + * @param string $var + * @return $this + */ + public function setKeyName($var) + { + GPBUtil::checkString($var, True); + $this->key_name = $var; + + return $this; + } + + /** + * Generated from protobuf field string x509_certificate_pem = 2; + * @return string + */ + public function getX509CertificatePem() + { + return isset($this->x509_certificate_pem) ? $this->x509_certificate_pem : ''; + } + + public function hasX509CertificatePem() + { + return isset($this->x509_certificate_pem); + } + + public function clearX509CertificatePem() + { + unset($this->x509_certificate_pem); + } + + /** + * Generated from protobuf field string x509_certificate_pem = 2; + * @param string $var + * @return $this + */ + public function setX509CertificatePem($var) + { + GPBUtil::checkString($var, True); + $this->x509_certificate_pem = $var; + + return $this; + } } diff --git a/src/Api/AppIdentity/SignForAppRequest.php b/src/Api/AppIdentity/SignForAppRequest.php new file mode 100644 index 00000000..cff68569 --- /dev/null +++ b/src/Api/AppIdentity/SignForAppRequest.php @@ -0,0 +1,75 @@ +google.appEngine.api.appIdentity.SignForAppRequest + */ +class SignForAppRequest extends \Google\Protobuf\Internal\Message +{ + /** + * optional string app_id = 2; + * + * Generated from protobuf field bytes bytes_to_sign = 1; + */ + protected $bytes_to_sign = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $bytes_to_sign + * optional string app_id = 2; + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * optional string app_id = 2; + * + * Generated from protobuf field bytes bytes_to_sign = 1; + * @return string + */ + public function getBytesToSign() + { + return isset($this->bytes_to_sign) ? $this->bytes_to_sign : ''; + } + + public function hasBytesToSign() + { + return isset($this->bytes_to_sign); + } + + public function clearBytesToSign() + { + unset($this->bytes_to_sign); + } + + /** + * optional string app_id = 2; + * + * Generated from protobuf field bytes bytes_to_sign = 1; + * @param string $var + * @return $this + */ + public function setBytesToSign($var) + { + GPBUtil::checkString($var, False); + $this->bytes_to_sign = $var; + + return $this; + } + +} + diff --git a/src/Api/AppIdentity/SignForAppResponse.php b/src/Api/AppIdentity/SignForAppResponse.php new file mode 100644 index 00000000..0fa4a80e --- /dev/null +++ b/src/Api/AppIdentity/SignForAppResponse.php @@ -0,0 +1,105 @@ +google.appEngine.api.appIdentity.SignForAppResponse + */ +class SignForAppResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string key_name = 1; + */ + protected $key_name = null; + /** + * Generated from protobuf field bytes signature_bytes = 2; + */ + protected $signature_bytes = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $key_name + * @type string $signature_bytes + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\AppIdentityService::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string key_name = 1; + * @return string + */ + public function getKeyName() + { + return isset($this->key_name) ? $this->key_name : ''; + } + + public function hasKeyName() + { + return isset($this->key_name); + } + + public function clearKeyName() + { + unset($this->key_name); + } + + /** + * Generated from protobuf field string key_name = 1; + * @param string $var + * @return $this + */ + public function setKeyName($var) + { + GPBUtil::checkString($var, True); + $this->key_name = $var; + + return $this; + } + + /** + * Generated from protobuf field bytes signature_bytes = 2; + * @return string + */ + public function getSignatureBytes() + { + return isset($this->signature_bytes) ? $this->signature_bytes : ''; + } + + public function hasSignatureBytes() + { + return isset($this->signature_bytes); + } + + public function clearSignatureBytes() + { + unset($this->signature_bytes); + } + + /** + * Generated from protobuf field bytes signature_bytes = 2; + * @param string $var + * @return $this + */ + public function setSignatureBytes($var) + { + GPBUtil::checkString($var, False); + $this->signature_bytes = $var; + + return $this; + } + +} + diff --git a/src/Api/AppIdentity/app_identity_service_pb.php b/src/Api/AppIdentity/app_identity_service_pb.php deleted file mode 100644 index b53ff1e3..00000000 --- a/src/Api/AppIdentity/app_identity_service_pb.php +++ /dev/null @@ -1,1077 +0,0 @@ -avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - } - public function equals($x) { - if ($x === $this) { return true; } - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - return $res; - } - } -} -namespace google\appengine { - class SignForAppRequest extends \google\net\ProtocolMessage { - public function getBytesToSign() { - if (!isset($this->bytes_to_sign)) { - return ''; - } - return $this->bytes_to_sign; - } - public function setBytesToSign($val) { - $this->bytes_to_sign = $val; - return $this; - } - public function clearBytesToSign() { - unset($this->bytes_to_sign); - return $this; - } - public function hasBytesToSign() { - return isset($this->bytes_to_sign); - } - public function clear() { - $this->clearBytesToSign(); - } - public function byteSizePartial() { - $res = 0; - if (isset($this->bytes_to_sign)) { - $res += 1; - $res += $this->lengthString(strlen($this->bytes_to_sign)); - } - return $res; - } - public function outputPartial($out) { - if (isset($this->bytes_to_sign)) { - $out->putVarInt32(10); - $out->putPrefixedString($this->bytes_to_sign); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $this->setBytesToSign(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - if ($x->hasBytesToSign()) { - $this->setBytesToSign($x->getBytesToSign()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (isset($this->bytes_to_sign) !== isset($x->bytes_to_sign)) return false; - if (isset($this->bytes_to_sign) && $this->bytes_to_sign !== $x->bytes_to_sign) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - if (isset($this->bytes_to_sign)) { - $res .= $prefix . "bytes_to_sign: " . $this->debugFormatString($this->bytes_to_sign) . "\n"; - } - return $res; - } - } -} -namespace google\appengine { - class SignForAppResponse extends \google\net\ProtocolMessage { - public function getKeyName() { - if (!isset($this->key_name)) { - return ''; - } - return $this->key_name; - } - public function setKeyName($val) { - $this->key_name = $val; - return $this; - } - public function clearKeyName() { - unset($this->key_name); - return $this; - } - public function hasKeyName() { - return isset($this->key_name); - } - public function getSignatureBytes() { - if (!isset($this->signature_bytes)) { - return ''; - } - return $this->signature_bytes; - } - public function setSignatureBytes($val) { - $this->signature_bytes = $val; - return $this; - } - public function clearSignatureBytes() { - unset($this->signature_bytes); - return $this; - } - public function hasSignatureBytes() { - return isset($this->signature_bytes); - } - public function clear() { - $this->clearKeyName(); - $this->clearSignatureBytes(); - } - public function byteSizePartial() { - $res = 0; - if (isset($this->key_name)) { - $res += 1; - $res += $this->lengthString(strlen($this->key_name)); - } - if (isset($this->signature_bytes)) { - $res += 1; - $res += $this->lengthString(strlen($this->signature_bytes)); - } - return $res; - } - public function outputPartial($out) { - if (isset($this->key_name)) { - $out->putVarInt32(10); - $out->putPrefixedString($this->key_name); - } - if (isset($this->signature_bytes)) { - $out->putVarInt32(18); - $out->putPrefixedString($this->signature_bytes); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $this->setKeyName(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 18: - $length = $d->getVarInt32(); - $this->setSignatureBytes(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - if ($x->hasKeyName()) { - $this->setKeyName($x->getKeyName()); - } - if ($x->hasSignatureBytes()) { - $this->setSignatureBytes($x->getSignatureBytes()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (isset($this->key_name) !== isset($x->key_name)) return false; - if (isset($this->key_name) && $this->key_name !== $x->key_name) return false; - if (isset($this->signature_bytes) !== isset($x->signature_bytes)) return false; - if (isset($this->signature_bytes) && $this->signature_bytes !== $x->signature_bytes) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - if (isset($this->key_name)) { - $res .= $prefix . "key_name: " . $this->debugFormatString($this->key_name) . "\n"; - } - if (isset($this->signature_bytes)) { - $res .= $prefix . "signature_bytes: " . $this->debugFormatString($this->signature_bytes) . "\n"; - } - return $res; - } - } -} -namespace google\appengine { - class GetPublicCertificateForAppRequest extends \google\net\ProtocolMessage { - public function clear() { - } - public function byteSizePartial() { - $res = 0; - return $res; - } - public function outputPartial($out) { - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - } - public function equals($x) { - if ($x === $this) { return true; } - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - return $res; - } - } -} -namespace google\appengine { - class PublicCertificate extends \google\net\ProtocolMessage { - public function getKeyName() { - if (!isset($this->key_name)) { - return ''; - } - return $this->key_name; - } - public function setKeyName($val) { - $this->key_name = $val; - return $this; - } - public function clearKeyName() { - unset($this->key_name); - return $this; - } - public function hasKeyName() { - return isset($this->key_name); - } - public function getX509CertificatePem() { - if (!isset($this->x509_certificate_pem)) { - return ''; - } - return $this->x509_certificate_pem; - } - public function setX509CertificatePem($val) { - $this->x509_certificate_pem = $val; - return $this; - } - public function clearX509CertificatePem() { - unset($this->x509_certificate_pem); - return $this; - } - public function hasX509CertificatePem() { - return isset($this->x509_certificate_pem); - } - public function clear() { - $this->clearKeyName(); - $this->clearX509CertificatePem(); - } - public function byteSizePartial() { - $res = 0; - if (isset($this->key_name)) { - $res += 1; - $res += $this->lengthString(strlen($this->key_name)); - } - if (isset($this->x509_certificate_pem)) { - $res += 1; - $res += $this->lengthString(strlen($this->x509_certificate_pem)); - } - return $res; - } - public function outputPartial($out) { - if (isset($this->key_name)) { - $out->putVarInt32(10); - $out->putPrefixedString($this->key_name); - } - if (isset($this->x509_certificate_pem)) { - $out->putVarInt32(18); - $out->putPrefixedString($this->x509_certificate_pem); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $this->setKeyName(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 18: - $length = $d->getVarInt32(); - $this->setX509CertificatePem(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - if ($x->hasKeyName()) { - $this->setKeyName($x->getKeyName()); - } - if ($x->hasX509CertificatePem()) { - $this->setX509CertificatePem($x->getX509CertificatePem()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (isset($this->key_name) !== isset($x->key_name)) return false; - if (isset($this->key_name) && $this->key_name !== $x->key_name) return false; - if (isset($this->x509_certificate_pem) !== isset($x->x509_certificate_pem)) return false; - if (isset($this->x509_certificate_pem) && $this->x509_certificate_pem !== $x->x509_certificate_pem) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - if (isset($this->key_name)) { - $res .= $prefix . "key_name: " . $this->debugFormatString($this->key_name) . "\n"; - } - if (isset($this->x509_certificate_pem)) { - $res .= $prefix . "x509_certificate_pem: " . $this->debugFormatString($this->x509_certificate_pem) . "\n"; - } - return $res; - } - } -} -namespace google\appengine { - class GetPublicCertificateForAppResponse extends \google\net\ProtocolMessage { - private $public_certificate_list = array(); - public function getPublicCertificateListSize() { - return sizeof($this->public_certificate_list); - } - public function getPublicCertificateListList() { - return $this->public_certificate_list; - } - public function mutablePublicCertificateList($idx) { - if (!isset($this->public_certificate_list[$idx])) { - $val = new \google\appengine\PublicCertificate(); - $this->public_certificate_list[$idx] = $val; - return $val; - } - return $this->public_certificate_list[$idx]; - } - public function getPublicCertificateList($idx) { - if (isset($this->public_certificate_list[$idx])) { - return $this->public_certificate_list[$idx]; - } - if ($idx >= end(array_keys($this->public_certificate_list))) { - throw new \OutOfRangeException('index out of range: ' + $idx); - } - return new \google\appengine\PublicCertificate(); - } - public function addPublicCertificateList() { - $val = new \google\appengine\PublicCertificate(); - $this->public_certificate_list[] = $val; - return $val; - } - public function clearPublicCertificateList() { - $this->public_certificate_list = array(); - } - public function getMaxClientCacheTimeInSecond() { - if (!isset($this->max_client_cache_time_in_second)) { - return "0"; - } - return $this->max_client_cache_time_in_second; - } - public function setMaxClientCacheTimeInSecond($val) { - if (is_double($val)) { - $this->max_client_cache_time_in_second = sprintf('%0.0F', $val); - } else { - $this->max_client_cache_time_in_second = $val; - } - return $this; - } - public function clearMaxClientCacheTimeInSecond() { - unset($this->max_client_cache_time_in_second); - return $this; - } - public function hasMaxClientCacheTimeInSecond() { - return isset($this->max_client_cache_time_in_second); - } - public function clear() { - $this->clearPublicCertificateList(); - $this->clearMaxClientCacheTimeInSecond(); - } - public function byteSizePartial() { - $res = 0; - $this->checkProtoArray($this->public_certificate_list); - $res += 1 * sizeof($this->public_certificate_list); - foreach ($this->public_certificate_list as $value) { - $res += $this->lengthString($value->byteSizePartial()); - } - if (isset($this->max_client_cache_time_in_second)) { - $res += 1; - $res += $this->lengthVarInt64($this->max_client_cache_time_in_second); - } - return $res; - } - public function outputPartial($out) { - $this->checkProtoArray($this->public_certificate_list); - foreach ($this->public_certificate_list as $value) { - $out->putVarInt32(10); - $out->putVarInt32($value->byteSizePartial()); - $value->outputPartial($out); - } - if (isset($this->max_client_cache_time_in_second)) { - $out->putVarInt32(16); - $out->putVarInt64($this->max_client_cache_time_in_second); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $tmp = new \google\net\Decoder($d->buffer(), $d->pos(), $d->pos() + $length); - $d->skip($length); - $this->addPublicCertificateList()->tryMerge($tmp); - break; - case 16: - $this->setMaxClientCacheTimeInSecond($d->getVarInt64()); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - foreach ($this->public_certificate_list as $value) { - if (!$value->isInitialized()) return 'public_certificate_list'; - } - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - foreach ($x->getPublicCertificateListList() as $v) { - $this->addPublicCertificateList()->copyFrom($v); - } - if ($x->hasMaxClientCacheTimeInSecond()) { - $this->setMaxClientCacheTimeInSecond($x->getMaxClientCacheTimeInSecond()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (sizeof($this->public_certificate_list) !== sizeof($x->public_certificate_list)) return false; - foreach (array_map(null, $this->public_certificate_list, $x->public_certificate_list) as $v) { - if (!$v[0]->equals($v[1])) return false; - } - if (isset($this->max_client_cache_time_in_second) !== isset($x->max_client_cache_time_in_second)) return false; - if (isset($this->max_client_cache_time_in_second) && !$this->integerEquals($this->max_client_cache_time_in_second, $x->max_client_cache_time_in_second)) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - foreach ($this->public_certificate_list as $value) { - $res .= $prefix . "public_certificate_list <\n" . $value->shortDebugString($prefix . " ") . $prefix . ">\n"; - } - if (isset($this->max_client_cache_time_in_second)) { - $res .= $prefix . "max_client_cache_time_in_second: " . $this->debugFormatInt64($this->max_client_cache_time_in_second) . "\n"; - } - return $res; - } - } -} -namespace google\appengine { - class GetServiceAccountNameRequest extends \google\net\ProtocolMessage { - public function clear() { - } - public function byteSizePartial() { - $res = 0; - return $res; - } - public function outputPartial($out) { - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - } - public function equals($x) { - if ($x === $this) { return true; } - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - return $res; - } - } -} -namespace google\appengine { - class GetServiceAccountNameResponse extends \google\net\ProtocolMessage { - public function getServiceAccountName() { - if (!isset($this->service_account_name)) { - return ''; - } - return $this->service_account_name; - } - public function setServiceAccountName($val) { - $this->service_account_name = $val; - return $this; - } - public function clearServiceAccountName() { - unset($this->service_account_name); - return $this; - } - public function hasServiceAccountName() { - return isset($this->service_account_name); - } - public function clear() { - $this->clearServiceAccountName(); - } - public function byteSizePartial() { - $res = 0; - if (isset($this->service_account_name)) { - $res += 1; - $res += $this->lengthString(strlen($this->service_account_name)); - } - return $res; - } - public function outputPartial($out) { - if (isset($this->service_account_name)) { - $out->putVarInt32(10); - $out->putPrefixedString($this->service_account_name); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $this->setServiceAccountName(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - if ($x->hasServiceAccountName()) { - $this->setServiceAccountName($x->getServiceAccountName()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (isset($this->service_account_name) !== isset($x->service_account_name)) return false; - if (isset($this->service_account_name) && $this->service_account_name !== $x->service_account_name) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - if (isset($this->service_account_name)) { - $res .= $prefix . "service_account_name: " . $this->debugFormatString($this->service_account_name) . "\n"; - } - return $res; - } - } -} -namespace google\appengine { - class GetAccessTokenRequest extends \google\net\ProtocolMessage { - private $scope = array(); - public function getScopeSize() { - return sizeof($this->scope); - } - public function getScopeList() { - return $this->scope; - } - public function getScope($idx) { - return $this->scope[$idx]; - } - public function setScope($idx, $val) { - $this->scope[$idx] = $val; - return $this; - } - public function addScope($val) { - $this->scope[] = $val; - return $this; - } - public function clearScope() { - $this->scope = array(); - } - public function getServiceAccountId() { - if (!isset($this->service_account_id)) { - return "0"; - } - return $this->service_account_id; - } - public function setServiceAccountId($val) { - if (is_double($val)) { - $this->service_account_id = sprintf('%0.0F', $val); - } else { - $this->service_account_id = $val; - } - return $this; - } - public function clearServiceAccountId() { - unset($this->service_account_id); - return $this; - } - public function hasServiceAccountId() { - return isset($this->service_account_id); - } - public function getServiceAccountName() { - if (!isset($this->service_account_name)) { - return ''; - } - return $this->service_account_name; - } - public function setServiceAccountName($val) { - $this->service_account_name = $val; - return $this; - } - public function clearServiceAccountName() { - unset($this->service_account_name); - return $this; - } - public function hasServiceAccountName() { - return isset($this->service_account_name); - } - public function clear() { - $this->clearScope(); - $this->clearServiceAccountId(); - $this->clearServiceAccountName(); - } - public function byteSizePartial() { - $res = 0; - $this->checkProtoArray($this->scope); - $res += 1 * sizeof($this->scope); - foreach ($this->scope as $value) { - $res += $this->lengthString(strlen($value)); - } - if (isset($this->service_account_id)) { - $res += 1; - $res += $this->lengthVarInt64($this->service_account_id); - } - if (isset($this->service_account_name)) { - $res += 1; - $res += $this->lengthString(strlen($this->service_account_name)); - } - return $res; - } - public function outputPartial($out) { - $this->checkProtoArray($this->scope); - foreach ($this->scope as $value) { - $out->putVarInt32(10); - $out->putPrefixedString($value); - } - if (isset($this->service_account_id)) { - $out->putVarInt32(16); - $out->putVarInt64($this->service_account_id); - } - if (isset($this->service_account_name)) { - $out->putVarInt32(26); - $out->putPrefixedString($this->service_account_name); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $this->addScope(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 16: - $this->setServiceAccountId($d->getVarInt64()); - break; - case 26: - $length = $d->getVarInt32(); - $this->setServiceAccountName(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - foreach ($x->getScopeList() as $v) { - $this->addScope($v); - } - if ($x->hasServiceAccountId()) { - $this->setServiceAccountId($x->getServiceAccountId()); - } - if ($x->hasServiceAccountName()) { - $this->setServiceAccountName($x->getServiceAccountName()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (sizeof($this->scope) !== sizeof($x->scope)) return false; - foreach (array_map(null, $this->scope, $x->scope) as $v) { - if ($v[0] !== $v[1]) return false; - } - if (isset($this->service_account_id) !== isset($x->service_account_id)) return false; - if (isset($this->service_account_id) && !$this->integerEquals($this->service_account_id, $x->service_account_id)) return false; - if (isset($this->service_account_name) !== isset($x->service_account_name)) return false; - if (isset($this->service_account_name) && $this->service_account_name !== $x->service_account_name) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - foreach ($this->scope as $value) { - $res .= $prefix . "scope: " . $this->debugFormatString($value) . "\n"; - } - if (isset($this->service_account_id)) { - $res .= $prefix . "service_account_id: " . $this->debugFormatInt64($this->service_account_id) . "\n"; - } - if (isset($this->service_account_name)) { - $res .= $prefix . "service_account_name: " . $this->debugFormatString($this->service_account_name) . "\n"; - } - return $res; - } - } -} -namespace google\appengine { - class GetAccessTokenResponse extends \google\net\ProtocolMessage { - public function getAccessToken() { - if (!isset($this->access_token)) { - return ''; - } - return $this->access_token; - } - public function setAccessToken($val) { - $this->access_token = $val; - return $this; - } - public function clearAccessToken() { - unset($this->access_token); - return $this; - } - public function hasAccessToken() { - return isset($this->access_token); - } - public function getExpirationTime() { - if (!isset($this->expiration_time)) { - return "0"; - } - return $this->expiration_time; - } - public function setExpirationTime($val) { - if (is_double($val)) { - $this->expiration_time = sprintf('%0.0F', $val); - } else { - $this->expiration_time = $val; - } - return $this; - } - public function clearExpirationTime() { - unset($this->expiration_time); - return $this; - } - public function hasExpirationTime() { - return isset($this->expiration_time); - } - public function clear() { - $this->clearAccessToken(); - $this->clearExpirationTime(); - } - public function byteSizePartial() { - $res = 0; - if (isset($this->access_token)) { - $res += 1; - $res += $this->lengthString(strlen($this->access_token)); - } - if (isset($this->expiration_time)) { - $res += 1; - $res += $this->lengthVarInt64($this->expiration_time); - } - return $res; - } - public function outputPartial($out) { - if (isset($this->access_token)) { - $out->putVarInt32(10); - $out->putPrefixedString($this->access_token); - } - if (isset($this->expiration_time)) { - $out->putVarInt32(16); - $out->putVarInt64($this->expiration_time); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $this->setAccessToken(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 16: - $this->setExpirationTime($d->getVarInt64()); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - if ($x->hasAccessToken()) { - $this->setAccessToken($x->getAccessToken()); - } - if ($x->hasExpirationTime()) { - $this->setExpirationTime($x->getExpirationTime()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (isset($this->access_token) !== isset($x->access_token)) return false; - if (isset($this->access_token) && $this->access_token !== $x->access_token) return false; - if (isset($this->expiration_time) !== isset($x->expiration_time)) return false; - if (isset($this->expiration_time) && !$this->integerEquals($this->expiration_time, $x->expiration_time)) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - if (isset($this->access_token)) { - $res .= $prefix . "access_token: " . $this->debugFormatString($this->access_token) . "\n"; - } - if (isset($this->expiration_time)) { - $res .= $prefix . "expiration_time: " . $this->debugFormatInt64($this->expiration_time) . "\n"; - } - return $res; - } - } -} -namespace google\appengine { - class GetDefaultGcsBucketNameRequest extends \google\net\ProtocolMessage { - public function clear() { - } - public function byteSizePartial() { - $res = 0; - return $res; - } - public function outputPartial($out) { - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - } - public function equals($x) { - if ($x === $this) { return true; } - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - return $res; - } - } -} -namespace google\appengine { - class GetDefaultGcsBucketNameResponse extends \google\net\ProtocolMessage { - public function getDefaultGcsBucketName() { - if (!isset($this->default_gcs_bucket_name)) { - return ''; - } - return $this->default_gcs_bucket_name; - } - public function setDefaultGcsBucketName($val) { - $this->default_gcs_bucket_name = $val; - return $this; - } - public function clearDefaultGcsBucketName() { - unset($this->default_gcs_bucket_name); - return $this; - } - public function hasDefaultGcsBucketName() { - return isset($this->default_gcs_bucket_name); - } - public function clear() { - $this->clearDefaultGcsBucketName(); - } - public function byteSizePartial() { - $res = 0; - if (isset($this->default_gcs_bucket_name)) { - $res += 1; - $res += $this->lengthString(strlen($this->default_gcs_bucket_name)); - } - return $res; - } - public function outputPartial($out) { - if (isset($this->default_gcs_bucket_name)) { - $out->putVarInt32(10); - $out->putPrefixedString($this->default_gcs_bucket_name); - } - } - public function tryMerge($d) { - while($d->avail() > 0) { - $tt = $d->getVarInt32(); - switch ($tt) { - case 10: - $length = $d->getVarInt32(); - $this->setDefaultGcsBucketName(substr($d->buffer(), $d->pos(), $length)); - $d->skip($length); - break; - case 0: - throw new \google\net\ProtocolBufferDecodeError(); - break; - default: - $d->skipData($tt); - } - }; - } - public function checkInitialized() { - return null; - } - public function mergeFrom($x) { - if ($x === $this) { throw new \IllegalArgumentException('Cannot copy message to itself'); } - if ($x->hasDefaultGcsBucketName()) { - $this->setDefaultGcsBucketName($x->getDefaultGcsBucketName()); - } - } - public function equals($x) { - if ($x === $this) { return true; } - if (isset($this->default_gcs_bucket_name) !== isset($x->default_gcs_bucket_name)) return false; - if (isset($this->default_gcs_bucket_name) && $this->default_gcs_bucket_name !== $x->default_gcs_bucket_name) return false; - return true; - } - public function shortDebugString($prefix = "") { - $res = ''; - if (isset($this->default_gcs_bucket_name)) { - $res .= $prefix . "default_gcs_bucket_name: " . $this->debugFormatString($this->default_gcs_bucket_name) . "\n"; - } - return $res; - } - } -} diff --git a/src/Runtime/VmApiProxy.php b/src/Runtime/VmApiProxy.php index 480dc59d..e27f1720 100644 --- a/src/Runtime/VmApiProxy.php +++ b/src/Runtime/VmApiProxy.php @@ -205,7 +205,7 @@ public function makeSyncCall( $call_name); } - $response->parseFromString($remote_response->getResponse()); + $response->mergeFromString($remote_response->getResponse()); } /** diff --git a/src/Testing/ApiCallArguments.php b/src/Testing/ApiCallArguments.php index 11a990f3..8b481018 100644 --- a/src/Testing/ApiCallArguments.php +++ b/src/Testing/ApiCallArguments.php @@ -31,7 +31,7 @@ public function isInputEqual($other) { return $this->package === $other->package && $this->call_name === $other->call_name - && $this->req->equals($other->req); + && $this->equals($this->req,$other->req); } public function toString() { @@ -39,5 +39,12 @@ public function toString() { . "Call: " . $this->call_name . "\n" . $this->req->shortDebugString(); } + + private function equals($a, $b) { + if ($a === $b) { return true; } + if (isset($a->bytes_to_sign) !== isset($b->bytes_to_sign)) return false; + if (isset($a->bytes_to_sign) && $a->bytes_to_sign !== $b->bytes_to_sign) return false; + return true; + } }; diff --git a/src/Testing/ApiProxyMock.php b/src/Testing/ApiProxyMock.php index b2b50e01..ef86d3b8 100644 --- a/src/Testing/ApiProxyMock.php +++ b/src/Testing/ApiProxyMock.php @@ -47,12 +47,23 @@ public function makeSyncCall( if ($expectedCall->resp instanceof \Exception) { throw $expectedCall->resp; } else { - $resp->copyFrom($expectedCall->resp); + $this->copyFrom($resp, $expectedCall->resp); } } public function verify() { $this->testcase->assertSame(array(), $this->expected); } + + /** + * Copies data from another protocol buffer pb2 to pb1. + */ + private function copyFrom($pb1, $pb2) { + if ($pb1 === $pb2) { + return; + } + $pb1->clear(); + $pb1->mergeFrom($pb2); + } } diff --git a/tests/Api/AppIdentity/AppIdentityServiceTest.php b/tests/Api/AppIdentity/AppIdentityServiceTest.php index d808df54..c3715d6d 100644 --- a/tests/Api/AppIdentity/AppIdentityServiceTest.php +++ b/tests/Api/AppIdentity/AppIdentityServiceTest.php @@ -20,8 +20,9 @@ */ namespace Google\AppEngine\Api\AppIdentity; -use google\appengine\AppIdentityServiceError\ErrorCode; -use google\appengine\api\appidentity\AppIdentityService; +use Google\AppEngine\Api\AppIdentity\AppIdentityServiceError\ErrorCode; +use Google\AppEngine\Api\AppIdentity\PublicCertificate; +use Google\AppEngine\Api\AppIdentity\AppIdentityService; use Google\AppEngine\Testing\ApiProxyTestBase; /** @@ -77,10 +78,10 @@ public function testDown(): void { } public function testSignForApp() { - $req = new \google\appengine\SignForAppRequest(); + $req = new \Google\AppEngine\Api\AppIdentity\SignForAppRequest(); $req->setBytesToSign('these are the bytes'); - $resp = new \google\appengine\SignForAppResponse(); + $resp = new \Google\AppEngine\Api\AppIdentity\SignForAppResponse(); $resp->setSignatureBytes('signed bytes.'); $resp->setKeyName('the key_name'); @@ -102,15 +103,22 @@ public function testInvalidBytesToSign() { } public function testGetPublicCertificates() { - $req = new \google\appengine\GetPublicCertificateForAppRequest(); - $resp = new \google\appengine\GetPublicCertificateForAppResponse(); - - $cert = $resp->mutablePublicCertificateList(0); + $req = new \Google\AppEngine\Api\AppIdentity\GetPublicCertificateForAppRequest(); + $resp = new \Google\AppEngine\Api\AppIdentity\GetPublicCertificateForAppResponse(); + + // $public_certificate_list = $resp->getPublicCertificateList(); + $public_certificate_list = []; + $cert = new PublicCertificate(); $cert->setKeyName('key1'); $cert->setX509CertificatePem('cert1'); - $cert = $resp->mutablePublicCertificateList(1); + $public_certificate_list[0] = $cert; + + $cert = new PublicCertificate(); $cert->setKeyName('key2'); $cert->setX509CertificatePem('cert2'); + $public_certificate_list[1] = $cert; + + $resp->setPublicCertificateList($public_certificate_list); $this->apiProxyMock->expectCall('app_identity_service', 'GetPublicCertificatesForApp', @@ -120,19 +128,19 @@ public function testGetPublicCertificates() { $certs = AppIdentityService::getPublicCertificates(); $cert = $certs[0]; - $this->assertEquals($cert->getCertificateName(), 'key1'); - $this->assertEquals($cert->getX509CertificateInPemFormat(), 'cert1'); + $this->assertEquals($cert->getKeyName(), 'key1'); + $this->assertEquals($cert->getX509CertificatePem(), 'cert1'); $cert = $certs[1]; - $this->assertEquals($cert->getCertificateName(), 'key2'); - $this->assertEquals($cert->getX509CertificateInPemFormat(), 'cert2'); + $this->assertEquals($cert->getKeyName(), 'key2'); + $this->assertEquals($cert->getX509CertificatePem(), 'cert2'); $this->apiProxyMock->verify(); } public function testGetServiceAccountName() { - $req = new \google\appengine\GetServiceAccountNameRequest(); + $req = new \Google\AppEngine\Api\AppIdentity\GetServiceAccountNameRequest(); $service_account_result = 'foobar@gserviceaccount.google.com'; - $resp = new \google\appengine\GetServiceAccountNameResponse(); + $resp = new \Google\AppEngine\Api\AppIdentity\GetServiceAccountNameResponse(); $resp->setServiceAccountName($service_account_result); $this->apiProxyMock->expectCall('app_identity_service', @@ -172,13 +180,11 @@ private function expectGetAccessTokenRequest($scopes, $cached, if ($cached) { return; } - $req = new \google\appengine\GetAccessTokenRequest(); - foreach ($scopes as $scope) { - $req->addScope($scope); - } + $req = new \Google\AppEngine\Api\AppIdentity\GetAccessTokenRequest(); + $req->setScope($scopes); if (is_null($exception)) { - $resp = new \google\appengine\GetAccessTokenResponse(); + $resp = new \Google\AppEngine\Api\AppIdentity\GetAccessTokenResponse(); $resp->setAccessToken('foo token'); $resp->setExpirationTime(12345); } else { @@ -327,17 +333,17 @@ private function expectMemcacheGetRequest($scopes) { } public function testGetAccessTokenInvalidScopeArray() { - $scopes = ["foo", 1]; + $scopes = ['foo', 1]; self::expectMemcacheGetRequest($scopes); $this->expectException('\InvalidArgumentException'); $sign_result = AppIdentityService::getAccessToken($scopes); } public function testGetAccessTokenServiceInvalidScope() { - $req = new \google\appengine\GetAccessTokenRequest(); + $req = new \Google\AppEngine\Api\AppIdentity\GetAccessTokenRequest(); $scope = 'mail.google.com/invalid-scope'; - $req->addScope($scope); + $req->setScope([$scope]); $exception = new \Google\AppEngine\Runtime\ApplicationError( ErrorCode::UNKNOWN_SCOPE, "unknown scope"); @@ -396,10 +402,10 @@ public function testGetDefaultVersionHostname() { } private function executeServiceErrorTest($error, $expected_response) { - $req = new \google\appengine\GetAccessTokenRequest(); + $req = new \Google\AppEngine\Api\AppIdentity\GetAccessTokenRequest(); $scope = 'mail.google.com/invalid-scope'; - $req->addScope($scope); + $req->setScope([$scope]); $exception = new \Google\AppEngine\Runtime\ApplicationError( $error, "not initialized"); diff --git a/tests/Runtime/VmApiProxyTest.php b/tests/Runtime/VmApiProxyTest.php index 4bf3bdde..cad9d554 100644 --- a/tests/Runtime/VmApiProxyTest.php +++ b/tests/Runtime/VmApiProxyTest.php @@ -23,8 +23,8 @@ use google\appengine\ext\remote_api\Request; use google\appengine\ext\remote_api\Response; use google\appengine\ext\remote_api\RpcError\ErrorCode; -use google\appengine\SignForAppRequest; -use google\appengine\SignForAppResponse; +use Google\AppEngine\Api\AppIdentity\SignForAppRequest; +use Google\AppEngine\Api\AppIdentity\SignForAppResponse; use Google\AppEngine\Runtime\ApiProxy; use Google\AppEngine\Runtime\ApplicationError; use \PHPUnit\Framework\TestCase;