first commit

This commit is contained in:
2026-04-20 13:11:14 +02:00
commit e0b63ca5f9
7793 changed files with 1844488 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
<?php
/**
* Google Drive ADDON
*
* Name: Google Drive ADDON
* Version: 1
* Author: Duplicator
* Author URI: https://duplicator.com/
*
* PHP version 5.6
*
* @category Duplicator
* @package Plugin
* @author Duplicator
* @copyright 2011-2021 Snapcreek LLC
* @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
* @version GIT: $Id$
* @link https://duplicator.com/
*/
namespace Duplicator\Addons\GDriveAddon;
use Duplicator\Addons\GDriveAddon\Models\GDriveStorage;
use Duplicator\Addons\GDriveAddon\Utils\Autoloader;
use Duplicator\Core\Addons\AbstractAddonCore;
use Duplicator\Models\Storages\AbstractStorageEntity;
class GDriveAddon extends AbstractAddonCore
{
const ADDON_PATH = __DIR__;
/**
* @return void
*/
public function init()
{
Autoloader::register();
add_action('duplicator_pro_register_storage_types', [$this, 'registerStorages']);
add_filter('duplicator_template_file', array(__CLASS__, 'getTemplateFile'), 10, 2);
add_filter('duplicator_usage_stats_storages_infos', array(__CLASS__, 'getStorageUsageStats'), 10);
}
/**
* @return void
*/
public function registerStorages()
{
GDriveStorage::registerType();
}
/**
* Return template file path
*
* @param string $path path to the template file
* @param string $slugTpl slug of the template
*
* @return string
*/
public static function getTemplateFile($path, $slugTpl)
{
if (strpos($slugTpl, 'gdriveaddon/') === 0) {
return self::getAddonPath() . '/template/' . $slugTpl . '.php';
}
return $path;
}
/**
* Get storage usage stats
*
* @param array<string,int> $storageNums Storages num
*
* @return array<string,int>
*/
public static function getStorageUsageStats($storageNums)
{
if (($storages = AbstractStorageEntity::getAll()) === false) {
$storages = [];
}
$storageNums['storages_gdrive_count'] = 0;
foreach ($storages as $index => $storage) {
if ($storage->getSType() === GDriveStorage::getSType()) {
$storageNums['storages_gdrive_count']++;
}
}
return $storageNums;
}
/**
*
* @return string
*/
public static function getAddonPath()
{
return __DIR__;
}
/**
*
* @return string
*/
public static function getAddonFile()
{
return __FILE__;
}
}

View File

@@ -0,0 +1,903 @@
<?php
/**
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
namespace Duplicator\Addons\GDriveAddon\Models;
use Duplicator\Addons\GDriveAddon\Utils\GoogleClient;
use Duplicator\Models\Storages\AbstractStorageAdapter;
use Duplicator\Utils\OAuth\TokenEntity;
use Exception;
use VendorDuplicator\Psr\Http\Message\RequestInterface;
use VendorDuplicator\Google\Client;
use VendorDuplicator\Google\Http\MediaFileUpload;
use VendorDuplicator\Google\Service\Drive;
use VendorDuplicator\GuzzleHttp\Psr7\Request;
use VendorDuplicator\GuzzleHttp\Psr7\Response;
/**
* @method GDriveStoragePathInfo getPathInfo(string $path)
*/
class GDriveAdapter extends AbstractStorageAdapter
{
const FOLDER_MIME_TYPE = 'application/vnd.google-apps.folder';
const CHUNK_SIZE_STEP = 256 * KB_IN_BYTES;
/** @var Drive The Google Drive service */
protected $drive = null;
/** @var string The root storage path */
protected $storagePath = '';
/** @var string The root storage path id */
protected $storagePathId = '';
/** @var TokenEntity The OAuth token entity */
protected $token = null;
/** @var int */
protected $startTime = 0;
/** @var bool */
protected $sslVerify = true;
/** @var string If empty use server cert else use custom cert path */
protected $sslCert = '';
/** @var bool */
protected $ipv4Only = false;
/**
* Class constructor.
*
* @param TokenEntity $token The OAuth token entity.
* @param string $storagePath The root storage path.
* @param string $storagePathId The root storage path id.
* @param bool $sslVerify If true, use SSL
* @param string $sslCert If empty use server cert
* @param bool $ipv4Only If true, use IPv4 only
*/
public function __construct(
TokenEntity $token,
$storagePath,
$storagePathId = '',
$sslVerify = true,
$sslCert = '',
$ipv4Only = false
) {
$this->token = $token;
$this->storagePath = $storagePath;
$this->storagePathId = $storagePathId;
$this->sslVerify = $sslVerify;
$this->sslCert = $sslCert;
$this->ipv4Only = $ipv4Only;
if ($token->isAboutToExpire()) {
$token->refresh(true);
}
$httpOptions = [];
if ($this->sslVerify === false) {
$verify = false;
} elseif (strlen($this->sslCert) === 0) {
$verify = true;
} else {
$verify = $this->sslCert;
}
$httpOptions['verify'] = $verify;
if ($this->ipv4Only) {
$httpOptions['force_ip_resolve'] = 'v4';
}
$client = new GoogleClient();
$client->setHttpClientOptions($httpOptions);
$client->setAccessToken([
'created' => $token->getCreated(),
'access_token' => $token->getAccessToken(),
'refresh_token' => $token->getRefreshToken(),
'expires_in' => $token->getExpiresIn(),
'scope' => $token->getScope(),
]);
$this->drive = new Drive($client);
}
/**
* Get the Google Drive service.
*
* @return Drive
*/
public function getService()
{
return $this->drive;
}
/**
* Initialize the storage on creation.
*
* @param string $errorMsg The error message if storage is invalid.
*
* @return bool true on success or false on failure.
*/
public function initialize(&$errorMsg = '')
{
if (! $this->token->isValid()) {
$errorMsg = __('Invalid token supplied for google drive', 'duplicator-pro');
return false;
}
if (! $this->exists('/') && ! $this->createDir('/')) {
$errorMsg = __('Unable to create root directory on google drive', 'duplicator-pro');
return false;
}
if (empty($this->storagePathId)) {
$storage = $this->getPathInfo('/');
if ($storage->exists) {
$this->storagePathId = $storage->id;
} else {
$errorMsg = __('Unable to fetch root directory info from Google Drive', 'duplicator-pro');
return false;
}
}
return true;
}
/**
* Destroy the storage on deletion.
*
* @return bool true on success or false on failure.
*/
public function destroy()
{
$this->storagePathId = '';
return $this->delete('/', true);
}
/**
* Check if storage is valid and ready to use.
*
* @param string $errorMsg The error message if storage is invalid.
*
* @return bool
*/
public function isValid(&$errorMsg = '')
{
if (! $this->token->isValid()) {
$errorMsg = 'Invalid token supplied for google drive';
return false;
}
$root = $this->getPathInfo('/');
if (! $root || !$root->exists) {
$errorMsg = 'Root directory does not exist on google drive, false for isValid';
return false;
}
return true;
}
/**
* Create the directory specified by pathname, recursively if necessary.
*
* @param string $path The directory path.
*
* @return bool true on success or false on failure.
*/
protected function realCreateDir($path)
{
$path = trim($path, '/');
if (empty($this->storagePathId)) {
// if we don't have the storage path id set, we fetch it
$storageFolder = $this->getPathInfo('/');
if ($storageFolder->exists) {
$this->storagePathId = $storageFolder->id;
} else {
$path = $this->storagePath . '/' . $path;
}
}
$parts = array_filter(explode('/', $path));
$parent = $this->storagePathId;
// At this point, if we don't have a parent, we need to create from the root path.
// We assume that a partial path may exist
// So we try to search for the path and create it if it doesn't exist
// But once we create one directory, we assume that the rest of the path doesn't exist
// This saves us a lot of calls to the Google Drive API
$pathMayExist = true;
foreach ($parts as $part) {
$query = "name = '{$part}' and trashed = false and mimeType = '" . self::FOLDER_MIME_TYPE . "'";
if ($parent) {
$query .= " and '{$parent}' in parents";
}
if ($pathMayExist) {
// At first, we try to find the directory
$response = $this->drive->files->listFiles([
'q' => $query,
'fields' => 'files(id)',
]);
if ($response->count() > 0) {
$file = $response->getFiles()[0];
$parent = $file->getId();
continue;
}
}
$pathMayExist = false;
// If we didn't find the directory, we create it
$file = new Drive\DriveFile([
'name' => $part,
'mimeType' => self::FOLDER_MIME_TYPE,
]);
if (! empty($parent)) {
$file->setParents([$parent]);
}
try {
$file = $this->drive->files->create($file, ['fields' => 'id']);
} catch (\Exception $e) {
\DUP_PRO_Log::traceObject('[GDriveAdapter] Unable to create directory: ' . $e->getMessage(), $e);
return false;
}
$parent = $file->getId();
}
return true;
}
/**
* Create file with content.
*
* @param string $path The path to file.
* @param string $content The content of file.
*
* @return false|int The number of bytes that were written to the file, or false on failure.
*/
protected function realCreateFile($path, $content)
{
$response = $this->createNewFile($path, [
'data' => $content,
'uploadType' => 'multipart',
'fields' => 'id,size',
]);
if (!$response) {
return false;
}
return (int) $response->getSize();
}
/**
* Delete relative path from storage root.
*
* @param string $path The path to delete. (Accepts directories and files)
* @param bool $recursive Allows the deletion of nested directories specified in the pathname. Default to false.
*
* @return bool true on success or false on failure.
*/
protected function realDelete($path, $recursive = false)
{
$info = $this->getPathInfo($path);
if (! $info->exists) {
return true; // if the path doesn't exist, we can consider it deleted
}
if ($info->isDir && ! $recursive && ! $this->isDirEmpty($path)) {
return false; // if it's a directory and, we are not deleting recursively, we can't delete it
}
try {
$this->drive->files->delete($info->id);
} catch (\Exception $e) {
return false;
}
return true;
}
/**
* Get file content.
*
* @param string $path The path to file.
*
* @return string|false The content of file or false on failure.
*/
public function getFileContent($path)
{
$info = $this->getPathInfo($path);
if (! $info->exists) {
return false;
}
try {
/** @var Response $response */
$response = $this->drive->files->get($info->id, [
'alt' => 'media',
'acknowledgeAbuse' => true,
]);
return $response->getBody()->getContents();
} catch (\Exception $e) {
return false;
}
}
/**
* Move and/or rename a file or directory.
*
* @param string $oldPath Relative storage path
* @param string $newPath Relative storage path
*
* @return bool true on success or false on failure.
*/
protected function realMove($oldPath, $newPath)
{
$fileInfo = $this->getPathInfo($oldPath);
$oldDirInfo = $this->getPathInfo(dirname($oldPath));
$newDirInfo = $this->getPathInfo(dirname($newPath));
$file = $fileInfo->file;
try {
$this->drive->files->update($fileInfo->id, $file, [
'addParents' => $newDirInfo->id,
'removeParents' => $oldDirInfo->id,
]);
} catch (\Exception $e) {
return false;
}
return true;
}
/**
* Get path info and cache it, is path not exists return path info with exists property set to false.
*
* @param string $path Relative storage path, if empty, return root path info.
*
* @return GDriveStoragePathInfo|false The path info or false on error.
*/
protected function getRealPathInfo($path)
{
try {
$info = $this->nestedPathInfo($path);
} catch (\Exception $e) {
$info = false;
}
return $this->buildPathInfo($info);
}
/**
* Get the list of files and directories inside the specified path.
*
* @param string $path Relative storage path, if empty, scan root path.
* @param bool $files If true, add files to the list. Default to true.
* @param bool $folders If true, add folders to the list. Default to true.
*
* @return string[] The list of files and directories, empty array if path is invalid.
*/
public function scanDir($path, $files = true, $folders = true)
{
$info = $this->getPathInfo($path);
if (! $info->exists) {
return [];
}
$query = "'{$info->id}' in parents and trashed = false";
if (! $files) {
$query .= " and mimeType = '" . self::FOLDER_MIME_TYPE . "'";
}
if (! $folders) {
$query .= " and mimeType != '" . self::FOLDER_MIME_TYPE . "'";
}
$nextPageToken = null;
$result = [];
do {
$response = $this->drive->files->listFiles([
'q' => $query,
'pageToken' => $nextPageToken,
]);
$result = array_merge($result, array_map(function ($file) {
$info = $this->buildPathInfo($file);
return $info->path;
}, $response->getFiles()));
} while ($nextPageToken = $response->getNextPageToken());
return $result;
}
/**
* Check if directory is empty.
*
* @param string $path The folder path
* @param string[] $filters Filters to exclude files and folders from the check, if start and end with /, use regex.
*
* @return bool True is ok, false otherwise
*/
public function isDirEmpty($path, $filters = [])
{
$regexFilters = $normalFilters = [];
foreach ($filters as $filter) {
if ($filter[0] === '/' && substr($filter, -1) === '/') {
$regexFilters[] = $filter; // It's a regex filter as it starts and ends with a slash
} else {
$normalFilters[] = $filter;
}
}
$contents = $this->scanDir($path);
foreach ($contents as $item) {
if (in_array($item, $normalFilters)) {
continue;
}
foreach ($regexFilters as $regexFilter) {
if (preg_match($regexFilter, $item) === 1) {
continue 2;
}
}
return false;
}
return true;
}
/**
* Copy local file to storage, partial copy is supported.
* If destination file exists, it will be overwritten.
* If offset is less than the destination file size, the file will be truncated.
*
* @param string $sourceFile The source file full path
* @param string $storageFile Storage destination path
* @param int<0,max> $offset The offset where the data starts.
* @param int $length The maximum number of bytes read. Default to -1 (read all the remaining buffer).
* @param int $timeout The timeout for the copy operation in microseconds. Default to 0 (no timeout).
* @param array<string,mixed> $extraData Extra data to pass to copy function and updated during copy.
* Used for storages that need to maintain persistent data during copy intra-session.
*
* @return false|int The number of bytes that were written to the file, or false on failure.
*/
protected function realCopyToStorage($sourceFile, $storageFile, $offset = 0, $length = -1, $timeout = 0, &$extraData = [])
{
$this->startTrackingTime();
$chunkSize = max(self::CHUNK_SIZE_STEP, floor($length / self::CHUNK_SIZE_STEP) * self::CHUNK_SIZE_STEP);
$source = fopen($sourceFile, 'rb');
if (! $source) {
\DUP_PRO_Log::info(sprintf('[GDriveAdapter] Unable to open source file %s', $sourceFile));
return false;
}
fseek($source, $offset);
$storageFile = '/' . trim($storageFile, '/');
$targetPath = dirname($storageFile);
if ($targetPath === '/' && ! empty($this->storagePathId)) {
$target = new Drive\DriveFile();
$target->setId($this->storagePathId);
} else {
$target = $this->getPathInfo($targetPath);
if (! $target->exists) {
$this->createDir($targetPath);
$target = $this->getPathInfo($targetPath);
}
}
if (! $target) {
\DUP_PRO_Log::info(sprintf('[GDriveAdapter] Unable to get target path info for %s', $targetPath));
return false;
}
$client = $this->drive->getClient();
$client->setDefer(true);
$originalHttpClient = $client->getHttpClient();
$file = new Drive\DriveFile([
'name' => basename($storageFile),
'parents' => [$target->id],
]);
// The file create call returns the request object as we have set client defer to true
/** @var Request $request */
$request = $this->drive->files->create($file);
$media = new MediaFileUpload(
$client,
$request,
'application/octet-stream',
'',
true,
$chunkSize
);
$firstChunk = true;
$media->setFileSize($filesize = filesize($sourceFile));
if (! empty($extraData['resume_uri'])) {
$resumeUri = $extraData['resume_uri'];
try {
$this->forceSet($media, 'progress', $offset);
$this->forceSet($media, 'resumeUri', $resumeUri);
} catch (\Exception $e) {
$client->setHttpClient($originalHttpClient);
\DUP_PRO_Log::info('[GDriveAdapter] Unable to set resume uri: ' . $e->getMessage());
return false;
}
$firstChunk = false;
\DUP_PRO_Log::trace(sprintf('[GDriveAdapter] Resuming upload for %s from offset %s timeout %d', $sourceFile, $offset, $timeout));
}
do {
if ($timeout > 0) {
// Set the timeout for the client (in seconds)
$client->setHttpClient(new \VendorDuplicator\GuzzleHttp\Client([
'base_uri' => $originalHttpClient->getConfig('base_uri'),
'http_errors' => false,
'timeout' => $timeout / SECONDS_IN_MICROSECONDS, // convert microseconds to seconds
]));
}
$chunk = fread($source, $chunkSize);
if (! $chunk) {
\DUP_PRO_Log::trace(sprintf('[GDriveAdapter] Unable to read chunk from %s', $sourceFile));
$status = true; // we can't set it to false, because drive sdk returns false when chunk upload is successful.
break;
}
$status = $media->nextChunk($chunk);
if ($firstChunk) {
\DUP_PRO_Log::trace(sprintf('[GDriveAdapter] Created resume uri for %s and it\'s %s', $sourceFile, $media->getResumeUri()));
$extraData['resume_uri'] = $media->getResumeUri(); // we need to cache the resume uri for the next chunk
$firstChunk = false;
}
$message = '[GDriveAdapter] Uploaded %d/%d bytes, requested [%d, %d] of %s';
\DUP_PRO_Log::trace(sprintf($message, $media->getProgress(), $filesize, $offset, $length, $sourceFile));
if ($length > 0) {
// if we have a length, we need to stop when we reach it
break;
}
} while (!feof($source) && ! $status && ! $this->hasReachedTimeout($timeout));
if (feof($source)) {
// if we reached the end of the file, we can delete the cached resume uri
unset($extraData['resume_uri']);
\DUP_PRO_Log::trace(sprintf('[GDriveAdapter] File %s copied successfully to %s', $sourceFile, $storageFile));
}
$client->setDefer(false);
$client->setHttpClient($originalHttpClient);
// If we have false as status, it means the upload is not finished yet
// On the final chunk upload, we get the file info
if ($status === false || ($status instanceof Drive\DriveFile)) {
return $length > 0 ? $length : $filesize;
}
return false;
}
/**
* Generate info on create dir, this method is exendable by child classes if StoragePathInfo is extended.
*
* @param string $path Dir path
*
* @return GDriveStoragePathInfo
*/
protected function generateCreateDirInfo($path)
{
return $this->getRealPathInfo($path);
}
/**
* Start tracking the time for the current operation
*
* @return void
*/
protected function startTrackingTime()
{
$this->startTime = (int) (microtime(true) * 1000000);
}
/**
* Get the elapsed time since the start of the current operation
*
* @return int
*/
protected function getElapsedTime()
{
return (int) (microtime(true) * 1000000) - $this->startTime;
}
/**
* Check if the operation has reached the timeout
*
* @param int $timeout The timeout in microseconds
*
* @return bool
*/
protected function hasReachedTimeout($timeout)
{
return $timeout > 0 && $this->getElapsedTime() >= ($timeout - 1000000);
}
/**
* Generate info on delete item, this methos is exendable by child classes if StoragePathInfo is extended.
*
* @param string $path Item path
*
* @return GDriveStoragePathInfo
*/
protected function generateDeleteInfo($path)
{
$info = new GDriveStoragePathInfo();
$info->path = $path;
$info->exists = false;
$info->isDir = false;
$info->size = 0;
$info->created = 0;
$info->modified = 0;
return $info;
}
/**
* Create a new file in the specified path.
*
* @param string $path The path to create the file in
* @param array<string, string> $options The options to create the file with
*
* @return false|Drive\DriveFile
*/
protected function createNewFile($path, $options = [])
{
$path = '/' . trim($path, '/');
$parent = $this->getPathInfo(dirname($path));
if (! $parent->exists) {
if ($this->createDir(dirname($path))) {
$parent = $this->getPathInfo(dirname($path));
} else {
return false;
}
}
$file = new Drive\DriveFile([
'name' => basename($path),
'parents' => [$parent->id],
]);
try {
return $this->drive->files->create($file, $options);
} catch (\Exception $e) {
return false;
}
}
/**
* Traverse the path folder by folder and fetch the file info.
*
* @param string $path The path get information for
* @param ?string $parent The parent folder id
*
* @return false|Drive\DriveFile
*/
protected function nestedPathInfo($path, $parent = null)
{
$path = trim($path, '/');
$traversed = explode('/', $this->storagePath); // keep track of the traversed path, by default the root folder is traversed
if (! $parent) {
$parent = $this->storagePathId;
}
if (! $parent) {
// if we don't have a parent, we need to traverse from the root folder
$path = $this->storagePath . '/' . $path;
$traversed = []; // we are traversing from the root folder, so we reset the traversed path
$info = false;
} else {
$info = $this->drive->files->get($parent, ['fields' => 'id,name,mimeType,size,createdTime,modifiedTime,md5Checksum,webViewLink']);
}
$parts = array_filter(explode('/', $path));
foreach ($parts as $index => $part) {
$query = "name = '{$part}' and trashed = false";
if ($parent) {
$query .= " and '{$parent}' in parents";
}
if ($index < count($parts) - 1) {
// if we are not in the last iteration, it's most definitely a folder
$query .= " and mimeType = '" . self::FOLDER_MIME_TYPE . "'";
}
$result = $this->drive->files->listFiles([
'q' => $query,
'fields' => 'files(id,name,mimeType,size,createdTime,modifiedTime,md5Checksum,webViewLink)',
]);
$traversed[] = $part;
if ($result->count() === 0) {
// if we didn't find anything, we can stop here
return false;
}
foreach ($result->getFiles() as $file) {
if ($file->getName() !== $part) {
continue; // we are looking for a file/folder with the same name
}
if ($index < (count($parts) - 1) && $file->getMimeType() !== self::FOLDER_MIME_TYPE) {
// if we are not in the last iteration, we are most definitely looking for a folder, so we skip if it's not
continue;
}
// At this point we have found the file or folder we were looking for
$props = $file->getProperties();
$props['path'] = implode('/', $traversed);
$file->setProperties($props); // add the path to the file properties
$parent = $file->getId();
$info = $file;
// we need to keep looking for the next part
continue 2;
}
// if we got here, we didn't find the file or folder we were looking for
$info = false;
break;
}
return $info;
}
/**
* Build the path info object from Google Drive's file info.
*
* @param Drive\DriveFile|false $file The file info
*
* @return GDriveStoragePathInfo
*/
protected function buildPathInfo($file)
{
$info = new GDriveStoragePathInfo();
if (! $file) {
$info->exists = false;
return $info;
}
$props = $file->getProperties();
$info->exists = true;
$info->id = $file->getId();
$info->name = $file->getName();
$info->mimeType = $file->getMimeType();
$info->isDir = $info->mimeType === self::FOLDER_MIME_TYPE;
$info->size = (int) $file->getSize();
$info->webUrl = $file->getWebViewLink();
$info->created = $file->getCreatedTime() ? strtotime($file->getCreatedTime()) : time();
$info->modified = $file->getModifiedTime() ? strtotime($file->getModifiedTime()) : time();
$info->md5Checksum = $file->getMd5Checksum();
if (isset($props['path'])) {
// if we have the path in the properties, that's a path from the storage folder
// so we remove the storage folder and the slash after that from the path
$info->path = substr($props['path'], strlen($this->storagePath) + 1);
} else {
// if we don't have the path in the properties, we "assume" it's under the storage folder
$info->path = $file->getName();
}
$info->file = $file;
return $info;
}
/**
* Forcefully set a property on an object
*
* @param object $object The object to set the property on
* @param string $property The property to set
* @param mixed $value The value to set
*
* @return void
*/
protected function forceSet($object, $property, $value)
{
if (!is_object($object)) {
throw new Exception('Object must be an object');
}
if (!property_exists($object, $property)) {
throw new Exception('Property ' . $property . ' does not exist on object ' . get_class($object));
}
$reflection = new \ReflectionProperty($object, $property);
$reflection->setAccessible(true);
$reflection->setValue($object, $value);
}
/**
* Copy storage file to local file, partial copy is supported.
* If destination file exists, it will be overwritten.
* If offset is less than the destination file size, the file will be truncated.
*
* @param string $storageFile The storage file path
* @param string $destFile The destination local file full path
* @param int<0,max> $offset The offset where the data starts.
* @param int $length The maximum number of bytes read. Default to -1 (read all the remaining buffer).
* @param int $timeout The timeout for the copy operation in microseconds. Default to 0 (no timeout).
* @param array<string,mixed> $extraData Extra data to pass to copy function and updated during copy.
* Used for storages that need to maintain persistent data during copy intra-session.
*
* @return false|int The number of bytes that were written to the file, or false on failure.
*/
public function copyFromStorage($storageFile, $destFile, $offset = 0, $length = -1, $timeout = 0, &$extraData = [])
{
$client = $this->drive->getClient();
$originalHttpClient = $client->getHttpClient();
if ($timeout > 0) {
$baseUri = $originalHttpClient->getConfig('base_uri');
$client->setHttpClient(new \VendorDuplicator\GuzzleHttp\Client([
'base_uri' => $baseUri,
'http_errors' => \false,
'timeout' => $timeout / 1000000, // convert microseconds to seconds
]));
}
if ($offset == 0 && $length < 0) {
// If we are copying the entire file, we can use the export link
$contents = $this->getFileContent($storageFile);
if ($contents === false) {
$client->setHttpClient($originalHttpClient);
return false;
}
// This may return 0 if the file is empty, so we specifically check for false
return file_put_contents($destFile, $contents);
}
if (! isset($extraData['fileId'])) {
// this is the first chunk, we need to get the file id & make sure the destination is writable & empty.
if (file_put_contents($destFile, '') === false) {
\DUP_PRO_Log::trace('[GDriveAdapter] Unable to write to destination file: ' . $destFile);
$client->setHttpClient($originalHttpClient);
return false;
}
if (! $this->exists($storageFile)) {
$client->setHttpClient($originalHttpClient);
return false;
}
$extraData['fileId'] = $this->getPathInfo($storageFile)->id;
}
$fileId = $extraData['fileId'];
try {
$client->setDefer(true);
/** @var RequestInterface $request */
$request = $this->drive->files->get($fileId, [
'alt' => 'media',
'acknowledgeAbuse' => true,
]);
$client->setDefer(false);
$request = $request->withHeader('Range', 'bytes=' . $offset . '-' . ($length > 0 ? ($offset + $length - 1) : ''));
$response = $client->execute($request, null);
$contents = $response->getBody()->getContents();
$client->setHttpClient($originalHttpClient);
if (file_put_contents($destFile, $contents, FILE_APPEND) !== false) {
return $length;
}
return false;
} catch (\Exception $e) {
$client->setHttpClient($originalHttpClient);
\DUP_PRO_Log::trace('[GDriveAdapter] Unable to get file content: ' . $e->getMessage());
return false;
}
}
}

View File

@@ -0,0 +1,617 @@
<?php
/**
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
namespace Duplicator\Addons\GDriveAddon\Models;
use DUP_PRO_Global_Entity;
use DUP_PRO_Google_Drive_Transfer_Mode;
use DUP_PRO_Log;
use DUP_PRO_Package_Upload_Info;
use DUP_PRO_Server;
use Duplicator\Core\Views\TplMng;
use Duplicator\Libs\Snap\SnapUtil;
use Duplicator\Models\DynamicGlobalEntity;
use Duplicator\Models\Storages\AbstractStorageEntity;
use Duplicator\Models\Storages\StorageAuthInterface;
use Duplicator\Utils\OAuth\TokenEntity;
use Duplicator\Utils\OAuth\TokenService;
use Exception;
/**
* @property GDriveAdapter $adapter
*/
class GDriveStorage extends AbstractStorageEntity implements StorageAuthInterface
{
// These numbers represent clients created in Google Cloud Console
const GDRIVE_CLIENT_NATIVE = 1; // Native client 1
const GDRIVE_CLIENT_WEB0722 = 2; // Web client 07/2022
const GDRIVE_CLIENT_LATEST = 2; // Latest out of these above
const REQUIRED_SCOPES = [
"openid",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
// The drive.file scope limits access to just those files created by the plugin
"https://www.googleapis.com/auth/drive.file",
];
/**
* Get default config
*
* @return array<string,scalar>
*/
protected static function getDefaultConfig()
{
$config = parent::getDefaultConfig();
$config = array_merge(
$config,
[
'storage_folder_id' => '',
'storage_folder_web_url' => '',
'token_json' => '',
'refresh_token' => '',
'client_number' => -1,
'authorized' => false,
]
);
return $config;
}
/**
* Serialize
*
* Wakeup method.
*
* @return void
*/
public function __wakeup()
{
parent::__wakeup();
if ($this->legacyEntity) {
// Old storage entity
$this->legacyEntity = false;
// Make sure the storage type is right from the old entity
$this->storage_type = $this->getSType();
$this->config = [
'token_json' => $this->gdrive_access_token_set_json,
'refresh_token' => $this->gdrive_refresh_token,
'storage_folder' => ltrim($this->gdrive_storage_folder, '/\\'),
'client_number' => $this->gdrive_client_number,
'max_packages' => $this->gdrive_max_files,
'authorized' => ($this->gdrive_authorization_state == 1),
];
// reset old values
$this->gdrive_access_token_set_json = '';
$this->gdrive_refresh_token = '';
$this->gdrive_storage_folder = '';
$this->gdrive_client_number = -1;
$this->gdrive_max_files = 10;
$this->gdrive_authorization_state = 0;
}
}
/**
* Return the storage type
*
* @return int
*/
public static function getSType()
{
return 3;
}
/**
* Returns the storage type icon.
*
* @return string Returns the storage icon
*/
public static function getStypeIcon()
{
$imgUrl = DUPLICATOR_PRO_IMG_URL . '/google-drive.svg';
return '<img src="' . esc_url($imgUrl) . '" class="dup-storage-icon" alt="' . esc_attr(static::getStypeName()) . '" />';
}
/**
* Returns the storage type name.
*
* @return string
*/
public static function getStypeName()
{
return __('Google Drive', 'duplicator-pro');
}
/**
* Get storage location string
*
* @return string
*/
public function getLocationString()
{
if ($this->isAuthorized()) {
return $this->config['storage_folder_web_url'];
} else {
return __('Not Authenticated', 'duplicator-pro');
}
}
/**
* Check if storage is supported
*
* @return bool
*/
public static function isSupported()
{
return (SnapUtil::isCurlEnabled() || SnapUtil::isUrlFopenEnabled());
}
/**
* Get supported notice, displayed if storage isn't supported
*
* @return string html string or empty if storage is supported
*/
public static function getNotSupportedNotice()
{
if (static::isSupported()) {
return '';
}
if (!SnapUtil::isCurlEnabled() && !SnapUtil::isUrlFopenEnabled()) {
return esc_html__(
'Google Drive requires either the PHP CURL extension enabled or the allow_url_fopen runtime configuration to be enabled.',
'duplicator-pro'
);
} elseif (!SnapUtil::isCurlEnabled()) {
return esc_html__('Google Drive requires the PHP CURL extension enabled.', 'duplicator-pro');
} else {
return esc_html__('Google Drive requires the allow_url_fopen runtime configuration to be enabled.', 'duplicator-pro');
}
}
/**
* Get upload chunk size in bytes
*
* @return int bytes
*/
public function getUploadChunkSize()
{
$dGlobal = DynamicGlobalEntity::getInstance();
$chunkSizeKb = $dGlobal->getVal('gdrive_upload_chunksize_in_kb', 256);
return $chunkSizeKb * KB_IN_BYTES;
}
/**
* Get upload chunk timeout in seconds
*
* @return int timeout in microseconds, 0 unlimited
*/
public function getUploadChunkTimeout()
{
// @todo: fixed to 10 seconds for historical reasons, make it configurable.
return 10 * 1000000;
}
/**
* Check if storage is valid
*
* @return bool Return true if storage is valid and ready to use, false otherwise
*/
public function isValid()
{
return $this->isAuthorized();
}
/**
* Is autorized
*
* @return bool
*/
public function isAuthorized()
{
return $this->config['authorized'];
}
/**
* Returns an HTML anchor tag of location
*
* @return string Returns an HTML anchor tag with the storage location as a hyperlink.
*/
public function getHtmlLocationLink()
{
if (! $this->isAuthorized() || empty($this->config['storage_folder_web_url'])) {
return '<span>' . esc_html($this->getStorageFolder()) . '</span>';
}
return sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", esc_url($this->config['storage_folder_web_url']), esc_html($this->getStorageFolder()));
}
/**
* Authorized from HTTP request
*
* @param string $message Message
*
* @return bool True if authorized, false if failed
*/
public function authorizeFromRequest(&$message = '')
{
$tokenPairString = '';
try {
if (($refreshToken = SnapUtil::sanitizeTextInput(SnapUtil::INPUT_REQUEST, 'auth_code')) === '') {
throw new Exception(__('Authorization code is empty', 'duplicator-pro'));
}
$this->name = SnapUtil::sanitizeTextInput(SnapUtil::INPUT_REQUEST, 'name', '');
$this->notes = SnapUtil::sanitizeDefaultInput(SnapUtil::INPUT_REQUEST, 'notes', '');
$this->config['max_packages'] = SnapUtil::sanitizeIntInput(SnapUtil::INPUT_REQUEST, 'max_packages', 10);
$this->config['storage_folder'] = self::getSanitizedInputFolder('storage_folder', 'remove');
$this->revokeAuthorization();
$token = (new TokenEntity(static::getSType(), ['refresh_token' => $refreshToken]));
if (!$token->refresh(true)) {
throw new Exception(__('Failed to fetch information from Google Drive. Make sure the token is valid.', 'duplicator-pro'));
}
if (empty($token->getScope())) {
throw new Exception(__("Couldn't connect. Google Drive scopes not found.", 'duplicator-pro'));
}
if (! $token->hasScopes(static::REQUIRED_SCOPES)) {
throw new Exception(
__(
"Authorization failed. You did not allow all required permissions. Try again and make sure that you checked all checkboxes.",
'duplicator-pro'
)
);
}
$this->config['refresh_token'] = $token->getRefreshToken();
$this->config['token_json'] = wp_json_encode([
'created' => $token->getCreated(),
'access_token' => $token->getAccessToken(),
'refresh_token' => $token->getRefreshToken(),
'expires_in' => $token->getExpiresIn(),
'scope' => $token->getScope(),
]);
$this->config['client_number'] = self::GDRIVE_CLIENT_LATEST;
$this->config['authorized'] = $token->isValid();
} catch (Exception $e) {
DUP_PRO_Log::traceException($e, "Problem authorizing Google Drive access token");
DUP_PRO_Log::traceObject('Token pair string from authorization:', $tokenPairString);
$message = $e->getMessage();
return false;
}
$this->save();
$message = __('Google Drive is connected successfully and Storage Provider Updated.', 'duplicator-pro');
return true;
}
/**
* Revokes authorization
*
* @param string $message Message
*
* @return bool True if authorized, false if failed
*/
public function revokeAuthorization(&$message = '')
{
if (!$this->isAuthorized()) {
$message = __('Google Drive isn\'t authorized.', 'duplicator-pro');
return true;
}
try {
$client = $this->getAdapter()->getService()->getClient();
if (!empty($this->config['refresh_token'])) {
$client->revokeToken($this->config['refresh_token']);
}
$accessTokenObj = json_decode($this->config['token_json']);
if (is_object($accessTokenObj) && property_exists($accessTokenObj, 'access_token')) {
$gdrive_access_token = $accessTokenObj->access_token;
} else {
$gdrive_access_token = false;
}
if (!empty($gdrive_access_token)) {
$client->revokeToken($gdrive_access_token);
}
$this->config['token_json'] = '';
$this->config['refresh_token'] = '';
$this->config['client_number'] = -1;
$this->config['authorized'] = false;
} catch (Exception $e) {
DUP_PRO_Log::trace("Problem revoking Google Drive access token msg: " . $e->getMessage());
$message = $e->getMessage();
return false;
}
$message = __('Google Drive is disconnected successfully.', 'duplicator-pro');
return true;
}
/**
* Get authorization URL
*
* @return string
*/
public function getAuthorizationUrl()
{
return (new TokenService(static::getSType()))->getRedirectUri();
}
/**
* Get storage adapter
*
* @return GDriveAdapter
*/
public function getAdapter()
{
$global = DUP_PRO_Global_Entity::getInstance();
$token = $this->getTokenFromConfig();
if (! $this->adapter) {
if (! isset($this->config['storage_folder_id']) || empty($this->config['storage_folder_id'])) {
$this->adapter = new GDriveAdapter(
$token,
$this->config['storage_folder'],
'',
!$global->ssl_disableverify,
($global->ssl_useservercerts ? '' : DUPLICATOR_PRO_CERT_PATH),
$global->ipv4_only
);
$this->adapter->initialize();
$storageFolder = $this->adapter->getPathInfo('/');
$this->config['storage_folder_id'] = $storageFolder->id;
$this->config['storage_folder_web_url'] = $storageFolder->webUrl;
$this->save();
} else {
$this->adapter = new GDriveAdapter(
$token,
$this->config['storage_folder'],
$this->config['storage_folder_id'],
!$global->ssl_disableverify,
($global->ssl_useservercerts ? '' : DUPLICATOR_PRO_CERT_PATH),
$global->ipv4_only
);
$this->adapter->initialize();
}
}
$storageFolder = $this->adapter->getPathInfo('/');
if ($storageFolder->name !== basename($this->getStorageFolder())) {
// root folder id & storage folder name is different.
$this->adapter = new GDriveAdapter(
$token,
$this->config['storage_folder'],
'',
!$global->ssl_disableverify,
($global->ssl_useservercerts ? '' : DUPLICATOR_PRO_CERT_PATH),
$global->ipv4_only
);
$this->adapter->initialize();
$storageFolder = $this->adapter->getPathInfo('/');
$this->config['storage_folder_id'] = $storageFolder->id;
$this->config['storage_folder_web_url'] = $storageFolder->webUrl;
$this->save();
}
return $this->adapter;
}
/**
* Render form config fields
*
* @param bool $echo Echo or return
*
* @return string
*/
public function renderConfigFields($echo = true)
{
$userInfo = false;
$quotaString = '';
if ($this->isAuthorized()) {
$adapter = $this->getAdapter();
try {
$serviceDrive = $adapter->getService();
$optParams = array('fields' => '*');
$about = $serviceDrive->about->get($optParams);
$storageQuota = $about->getStorageQuota();
$quota_total = max($storageQuota->getLimit(), 1);
$quota_used = $storageQuota->getUsage();
$userInfo = $about->getUser();
if (is_numeric($quota_total) && is_numeric($quota_used)) {
$available_quota = $quota_total - $quota_used;
$used_perc = round($quota_used * 100 / $quota_total, 1);
$quotaString = sprintf(
__('%1$s%% used, %2$s available', 'duplicator-pro'),
$used_perc,
size_format($available_quota)
);
}
} catch (\Exception $e) {
DUP_PRO_Log::info("Problem getting Google Drive user info and quota: " . $e->getMessage());
$userInfo = $quotaString = null;
}
}
return TplMng::getInstance()->render(
'gdriveaddon/configs/google_drive',
[
'storage' => $this,
'storageFolder' => $this->config['storage_folder'],
'maxPackages' => $this->config['max_packages'],
'userInfo' => $userInfo,
'quotaString' => $quotaString,
],
$echo
);
}
/**
* Update data from http request, this method don't save data, just update object properties
*
* @param string $message Message
*
* @return bool True if success and all data is valid, false otherwise
*/
public function updateFromHttpRequest(&$message = '')
{
if ((parent::updateFromHttpRequest($message) === false)) {
return false;
}
$previousStorageFolder = $this->config['storage_folder'];
$this->config['max_packages'] = SnapUtil::sanitizeIntInput(SnapUtil::INPUT_REQUEST, 'gdrive_max_files', 10);
$this->config['storage_folder'] = self::getSanitizedInputFolder('_gdrive_storage_folder', 'remove');
if ($previousStorageFolder !== $this->config['storage_folder']) {
$this->config['storage_folder_id'] = '';
$this->config['storage_folder_web_url'] = '';
}
$message = sprintf(
__('Google Drive Storage Updated.', 'duplicator-pro'),
$this->config['server'],
$this->getStorageFolder()
);
return true;
}
/**
* Get the token entity from config
*
* @return TokenEntity
*/
protected function getTokenFromConfig()
{
$token = new TokenEntity(static::getSType(), $this->config['token_json']);
if ($token->isAboutToExpire()) {
try {
$token->refresh(true);
} catch (Exception $e) {
DUP_PRO_Log::traceException($e, "Problem refreshing Google Drive access token");
}
$this->config['token_json'] = wp_json_encode([
'created' => $token->getCreated(),
'access_token' => $token->getAccessToken(),
'refresh_token' => $token->getRefreshToken(),
'expires_in' => $token->getExpiresIn(),
'scope' => $token->getScope(),
]);
$this->save();
}
return $token;
}
/**
* @return void
*/
public static function registerType()
{
parent::registerType();
add_action('duplicator_update_global_storage_settings', function () {
$dGlobal = DynamicGlobalEntity::getInstance();
foreach (static::getDefaultSettings() as $key => $default) {
$value = SnapUtil::sanitizeIntInput(SnapUtil::INPUT_REQUEST, $key, $default);
$dGlobal->setVal($key, $value);
}
});
}
/**
* Get default settings
*
* @return array<string, scalar>
*/
protected static function getDefaultSettings()
{
return [
'gdrive_upload_chunksize_in_kb' => 1024,
'gdrive_transfer_mode' => DUP_PRO_Google_Drive_Transfer_Mode::Auto,
];
}
/**
* @return void
*/
public static function renderGlobalOptions()
{
$values = static::getDefaultSettings();
$dGlobal = DynamicGlobalEntity::getInstance();
foreach ($values as $key => $default) {
$values[$key] = $dGlobal->getVal($key, $default);
}
?>
<h3 class="title"><?php echo esc_html(static::getStypeName()); ?></h3>
<hr size="1" />
<table class="form-table">
<tr valign="top">
<th scope="row"><label><?php esc_html_e("Upload Chunk Size", 'duplicator-pro'); ?></label></th>
<td>
<input
class="dup-narrow-input text-right"
name="gdrive_upload_chunksize_in_kb"
id="gdrive_upload_chunksize_in_kb"
type="number"
min="256"
step="256"
data-parsley-required
data-parsley-type="number"
data-parsley-errors-container="#gdrive_upload_chunksize_in_kb_error_container"
value="<?php echo (int) $values['gdrive_upload_chunksize_in_kb']; ?>"
>&nbsp;<b>KB</b>
<div id="gdrive_upload_chunksize_in_kb_error_container" class="duplicator-error-container"></div>
<p class="description">
<?php esc_html_e(
'How much should be uploaded to Google Drive per attempt. Higher=faster but less reliable. It should be multiple of 256.',
'duplicator-pro'
); ?>
</p>
</td>
</tr>
<tr valign="top">
<th scope="row"><label><?php esc_html_e("Transfer Mode", 'duplicator-pro'); ?></label></th>
<td>
<input
type="radio"
value="<?php echo (int) DUP_PRO_Google_Drive_Transfer_Mode::Auto ?>"
name="gdrive_transfer_mode" id="gdrive_transfer_mode_auto"
<?php checked($values['gdrive_transfer_mode'], DUP_PRO_Google_Drive_Transfer_Mode::Auto); ?>
>
<label for="gdrive_transfer_mode_auto"><?php esc_html_e("Auto", 'duplicator-pro'); ?></label> &nbsp;
<input
type="radio" <?php disabled(!DUP_PRO_Server::isURLFopenEnabled()) ?>
value="<?php echo (int) DUP_PRO_Google_Drive_Transfer_Mode::FOpen_URL ?>"
name="gdrive_transfer_mode"
id="gdrive_transfer_mode_stream"
<?php checked($values['gdrive_transfer_mode'], DUP_PRO_Google_Drive_Transfer_Mode::FOpen_URL); ?>
>
<label for="gdrive_transfer_mode_stream"><?php esc_html_e("FOpen URL", 'duplicator-pro'); ?></label> &nbsp;
<?php if (!DUP_PRO_Server::isURLFopenEnabled()) : ?>
<i
class="fas fa-question-circle fa-sm"
data-tooltip-title="<?php esc_attr_e("FOpen URL", 'duplicator-pro'); ?>"
data-tooltip="<?php esc_attr_e('Not available because "allow_url_fopen" is turned off in the php.ini', 'duplicator-pro'); ?>">
</i>
<?php endif; ?>
</td>
</tr>
</table>
<?php
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
namespace Duplicator\Addons\GDriveAddon\Models;
use Duplicator\Models\Storages\StoragePathInfo;
use VendorDuplicator\Google\Service\Drive\DriveFile;
class GDriveStoragePathInfo extends StoragePathInfo
{
/** @var string */
public $id = '';
/** @var string */
public $name = '';
/** @var string */
public $mimeType = '';
/** @var string */
public $webUrl = '';
/** @var string */
public $md5Checksum = '';
/** @var DriveFile */
public $file;
}

View File

@@ -0,0 +1,71 @@
<?php
namespace Duplicator\Addons\GDriveAddon\Utils;
use Duplicator\Addons\GDriveAddon\GDriveAddon;
use Duplicator\Utils\AbstractAutoloader;
class Autoloader extends AbstractAutoloader
{
const VENDOR_PATH = GDriveAddon::ADDON_PATH . '/vendor-prefixed/';
/**
* Register autoloader function
*
* @return void
*/
public static function register()
{
spl_autoload_register([__CLASS__, 'load']);
require_once GDriveAddon::ADDON_PATH . '/vendor-prefixed/guzzlehttp/guzzle/src/functions_include.php';
require_once GDriveAddon::ADDON_PATH . '/vendor-prefixed/guzzlehttp/promises/src/functions_include.php';
require_once GDriveAddon::ADDON_PATH . '/vendor-prefixed/guzzlehttp/psr7/src/functions_include.php';
require_once GDriveAddon::ADDON_PATH . '/vendor-prefixed/ralouphie/getallheaders/src/getallheaders.php';
}
/**
* Load class
*
* @param string $className class name
*
* @return void
*/
public static function load($className)
{
if (strpos($className, self::ROOT_VENDOR) === 0) {
foreach (self::getNamespacesVendorMapping() as $namespace => $mappedPath) {
if (strpos($className, $namespace) !== 0) {
continue;
}
$filepath = self::getFilenameFromClass($className, $namespace, $mappedPath);
if (file_exists($filepath)) {
include $filepath;
return;
}
}
}
}
/**
* Return namespace mapping
*
* @return string[]
*/
protected static function getNamespacesVendorMapping()
{
return [
self::ROOT_VENDOR . 'Firebase\\JWT' => self::VENDOR_PATH . 'firebase/php-jwt/src/',
self::ROOT_VENDOR . 'Google\\Service' => self::VENDOR_PATH . 'google/apiclient-services/src',
self::ROOT_VENDOR . 'Google\\Auth' => self::VENDOR_PATH . 'google/auth/src',
self::ROOT_VENDOR . 'Google' => self::VENDOR_PATH . 'google/apiclient/src',
self::ROOT_VENDOR . 'GuzzleHttp\\Promise' => self::VENDOR_PATH . 'guzzlehttp/promises/src',
self::ROOT_VENDOR . 'GuzzleHttp\\Psr7' => self::VENDOR_PATH . 'guzzlehttp/psr7/src',
self::ROOT_VENDOR . 'GuzzleHttp' => self::VENDOR_PATH . 'guzzlehttp/guzzle/src',
self::ROOT_VENDOR . 'Monolog' => self::VENDOR_PATH . 'monolog/monolog/src/Monolog',
self::ROOT_VENDOR . 'Psr\\Http\\Message' => self::VENDOR_PATH . 'psr/http-message/src',
self::ROOT_VENDOR . 'Psr\\Log' => self::VENDOR_PATH . 'psr/log/Psr/Log',
self::ROOT_VENDOR . 'Psr\\Cache' => self::VENDOR_PATH . 'psr/cache/src',
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Duplicator\Addons\GDriveAddon\Utils;
use VendorDuplicator\Google\Client;
use VendorDuplicator\GuzzleHttp\Client as GuzzleClient;
class GoogleClient extends Client
{
/** @var array<string,mixed> */
protected $customHttpOptions = [];
/**
* Set http client options
*
* @param array<string,mixed> $options options
*
* @return void
*/
public function setHttpClientOptions(array $options)
{
$this->customHttpOptions = $options;
}
/**
* Create a new http client.
*
* @return GuzzleClient
*/
protected function createDefaultHttpClient()
{
$options = [
'base_uri' => $this->getConfig('base_path'),
'http_errors' => false,
];
$options = array_merge($options, $this->customHttpOptions);
$guzzleClient = new GuzzleClient($options);
return $guzzleClient;
}
}

View File

@@ -0,0 +1,263 @@
<?php
/**
* Duplicator messages sections
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
use Duplicator\Addons\GDriveAddon\Models\GDriveStorage;
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
* @var array<string, mixed> $tplData
* @var GDriveStorage $storage
*/
$storage = $tplData["storage"];
/** @var string */
$storageFolder = $tplData["storageFolder"];
/** @var int */
$maxPackages = $tplData["maxPackages"];
/** @var \VendorDuplicator\Google\Service\Drive\User $userInfo */
$userInfo = $tplData["userInfo"];
/** @var string */
$quotaString = $tplData["quotaString"];
$tplMng->render('admin_pages/storages/parts/provider_head');
?>
<tr>
<th scope="row"><label for=""><?php esc_html_e("Authorization", 'duplicator-pro'); ?></label></th>
<td class="gdrive-authorize">
<?php if (!$storage->isAuthorized()) : ?>
<div class='gdrive-authorization-state' id="gdrive-state-unauthorized">
<!-- CONNECT -->
<div id="dpro-gdrive-connect-btn-area">
<button
id="dpro-gdrive-connect-btn"
type="button"
class="button button-large"
onclick="DupPro.Storage.GDrive.GoogleGetAuthUrl();"
>
<i class="fa fa-plug"></i> <?php esc_html_e('Connect to Google Drive', 'duplicator-pro'); ?>
<img
src="<?php echo esc_url(DUPLICATOR_PRO_IMG_URL . '/google-drive.svg'); ?>"
style='vertical-align: middle; margin:-2px 0 0 3px; height:18px; width:18px'
/>
</button>
</div>
<div class="authorization-state" id="dpro-gdrive-connect-progress">
<div style="padding:10px">
<i class="fas fa-circle-notch fa-spin"></i> <?php esc_html_e('Getting Google Drive Request Token...', 'duplicator-pro'); ?>
</div>
</div>
<!-- STEPS -->
<div id="dpro-gdrive-steps">
<div>
<b><?php esc_html_e('Step 1:', 'duplicator-pro'); ?></b>&nbsp;
<?php
esc_html_e(
"Duplicator needs to authorize Google Drive. Make sure to allow all required permissions.",
'duplicator-pro'
); ?>
<div class="auth-code-popup-note">
<?php
echo esc_html__(
'Note: Clicking the button below will open a new tab/window. Please be sure your browser does not block popups.',
'duplicator-pro'
) . ' google_drive.php' .
esc_html__('If a new tab/window does not open check your browsers address bar to allow popups from this URL.', 'duplicator-pro');
?>
</div>
<button id="gdrive-auth-window-button" class="button" onclick="DupPro.Storage.GDrive.OpenAuthPage(); return false;">
<i class="fa fa-user"></i> <?php esc_html_e("Authorize Google Drive", 'duplicator-pro'); ?>
</button>
</div>
<div id="gdrive-auth-code-area">
<b><?php esc_html_e('Step 2:', 'duplicator-pro'); ?></b>
<?php esc_html_e("Paste code from Google authorization page.", 'duplicator-pro'); ?> <br/>
<input style="width:400px" id="gdrive-auth-code" name="gdrive-auth-code" />
</div>
<b><?php esc_html_e('Step 3:', 'duplicator-pro'); ?></b>
<?php esc_html_e('Finalize Google Drive setup by clicking the "Finalize Setup" button.', 'duplicator-pro') ?>
<br/>
<button
id="gdrive-finalize-setup"
type="button"
class="button"
>
<i class="fa fa-check-square"></i> <?php esc_html_e('Finalize Setup', 'duplicator-pro'); ?>
</button>
</div>
</div>
<?php else : ?>
<div class='gdrive-authorization-state' id="gdrive-state-authorized" style="margin-top:-10px">
<?php if ($userInfo != null) : ?>
<h3>
<?php esc_html_e('Google Drive Account', 'duplicator-pro'); ?><br/>
<i class="dpro-edit-info">
<?php esc_html_e('Duplicator has been authorized to access this user\'s Google Drive account', 'duplicator-pro'); ?>
</i>
</h3>
<div id="gdrive-account-info">
<label><?php esc_html_e('Name', 'duplicator-pro'); ?>:</label>
<?php echo esc_html($userInfo->getDisplayName()); ?><br/>
<label><?php esc_html_e('Email', 'duplicator-pro'); ?>:</label> <?php echo esc_html($userInfo->getEmailAddress()); ?>
<?php if (strlen($quotaString) > 0) { ?>
<br>
<label><?php esc_html_e('Quota', 'duplicator-pro'); ?>:</label> <?php echo esc_html($quotaString); ?>
<?php } ?>
</div><br/>
<?php else : ?>
<div><?php esc_html_e('Error retrieving user information.', 'duplicator-pro'); ?></div>
<?php endif ?>
<button
id="dup-gdrive-cancel-authorization"
type="button"
class="button"
>
<?php esc_html_e('Cancel Authorization', 'duplicator-pro'); ?>
</button><br/>
<i class="dpro-edit-info">
<?php
esc_html_e(
'Disassociates storage provider with the Google Drive account. Will require re-authorization.',
'duplicator-pro'
); ?>
</i>
</div>
<?php endif ?>
</td>
</tr>
<tr>
<th scope="row">
<label for="_gdrive_storage_folder">
<?php esc_html_e("Storage Folder", 'duplicator-pro'); ?>
</label>
</th>
<td>
<b>//Google Drive/</b>
<input
id="_gdrive_storage_folder"
name="_gdrive_storage_folder"
type="text"
value="<?php echo esc_attr($storageFolder); ?>"
class="dpro-storeage-folder-path"
>
<p>
<i>
<?php
esc_html_e(
"Folder where packages will be stored. This should be unique for each web-site using Duplicator.",
'duplicator-pro'
); ?>
</i>
<?php
$tipContent = __(
'If the directory path above is already in Google Drive before connecting then a duplicate folder name will be made in the same path.',
'duplicator-pro'
) . ' google_drive.php' . __('This is because the plugin only has rights to folders it creates.', 'duplicator-pro');
?>
<i
class="fas fa-question-circle fa-sm"
data-tooltip-title="<?php esc_attr_e("Storage Folder Notice", 'duplicator-pro'); ?>"
data-tooltip="<?php esc_attr($tipContent); ?>"
>
</i>
</p>
</td>
</tr>
<tr>
<th scope="row"><label for=""><?php esc_html_e("Max Packages", 'duplicator-pro'); ?></label></th>
<td>
<label for="gdrive_max_files">
<input
id="gdrive_max_files"
name="gdrive_max_files"
type="number"
value="<?php echo (int) $maxPackages; ?>"
min="0"
maxlength="4"
data-parsley-errors-container="#gdrive_max_files_error_container"
data-parsley-required="true"
data-parsley-type="number"
data-parsley-min="0"
>&nbsp;
<?php esc_html_e("Number of packages to keep in folder.", 'duplicator-pro'); ?> <br/>
<i><?php esc_html_e("When this limit is exceeded, the oldest package will be deleted. Set to 0 for no limit.", 'duplicator-pro'); ?></i>
</label>
<div id="gdrive_max_files_error_container" class="duplicator-error-container"></div>
</td>
</tr>
<?php
$tplMng->render('admin_pages/storages/parts/provider_foot');
// Alerts for Google Drive
$alertConnStatus = new DUP_PRO_UI_Dialog();
$alertConnStatus->title = __('Google Drive Authorization Error', 'duplicator-pro');
$alertConnStatus->message = ''; // javascript inserted message
$alertConnStatus->initAlert();
?>
<script>
jQuery(document).ready(function ($) {
DupPro.Storage.GDrive = DupPro.Storage.GDrive || {};
$('#dup-gdrive-cancel-authorization').click(function (event) {
event.stopPropagation();
DupPro.Storage.RevokeAuth(<?php echo (int) $storage->getId(); ?>);
});
DupPro.Storage.GDrive.GoogleGetAuthUrl = function ()
{
$('#dpro-gdrive-connect-btn-area').hide();
$('#dpro-gdrive-steps').show();
DupPro.Storage.GDrive.AuthUrl = <?php echo json_encode($storage->getAuthorizationUrl()); ?>;
}
DupPro.Storage.GDrive.OpenAuthPage = function ()
{
window.open(DupPro.Storage.GDrive.AuthUrl, '_blank');
}
$('#gdrive-finalize-setup').click(function (event) {
event.stopPropagation();
if ($('#gdrive-auth-code').val().length > 5) {
DupPro.Storage.PrepareForSubmit();
//$("#dup-storage-form").submit();
DupPro.Storage.Authorize(
<?php echo (int) $storage->getId(); ?>,
<?php echo (int) $storage->getSType(); ?>,
{
'name': $('#name').val(),
'notes': $('#notes').val(),
'storage_folder': $('#_gdrive_storage_folder').val(),
'max_packages': $('#gdrive_max_files').val(),
'auth_code' : $('#gdrive-auth-code').val()
}
);
} else {
<?php $alertConnStatus->showAlert(); ?>
let alertMsg = "<i class='fas fa-exclamation-triangle'></i> " +
"<?php esc_html_e('Please enter your Google Drive authorization code!', 'duplicator-pro'); ?>";
<?php $alertConnStatus->updateMessage("alertMsg"); ?>
}
return false;
});
});
</script>

View File

@@ -0,0 +1,7 @@
<?php
namespace VendorDuplicator\Firebase\JWT;
class BeforeValidException extends \UnexpectedValueException
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace VendorDuplicator\Firebase\JWT;
class ExpiredException extends \UnexpectedValueException
{
}

View File

@@ -0,0 +1,137 @@
<?php
namespace VendorDuplicator\Firebase\JWT;
use DomainException;
use InvalidArgumentException;
use UnexpectedValueException;
/**
* JSON Web Key implementation, based on this spec:
* https://tools.ietf.org/html/draft-ietf-jose-json-web-key-41
*
* PHP version 5
*
* @category Authentication
* @package Authentication_JWT
* @author Bui Sy Nguyen <nguyenbs@gmail.com>
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
* @link https://github.com/firebase/php-jwt
*/
class JWK
{
/**
* Parse a set of JWK keys
*
* @param array $jwks The JSON Web Key Set as an associative array
*
* @return array An associative array that represents the set of keys
*
* @throws InvalidArgumentException Provided JWK Set is empty
* @throws UnexpectedValueException Provided JWK Set was invalid
* @throws DomainException OpenSSL failure
*
* @uses parseKey
*/
public static function parseKeySet(array $jwks)
{
$keys = array();
if (!isset($jwks['keys'])) {
throw new UnexpectedValueException('"keys" member must exist in the JWK Set');
}
if (empty($jwks['keys'])) {
throw new InvalidArgumentException('JWK Set did not contain any keys');
}
foreach ($jwks['keys'] as $k => $v) {
$kid = isset($v['kid']) ? $v['kid'] : $k;
if ($key = self::parseKey($v)) {
$keys[$kid] = $key;
}
}
if (0 === \count($keys)) {
throw new UnexpectedValueException('No supported algorithms found in JWK Set');
}
return $keys;
}
/**
* Parse a JWK key
*
* @param array $jwk An individual JWK
*
* @return resource|array An associative array that represents the key
*
* @throws InvalidArgumentException Provided JWK is empty
* @throws UnexpectedValueException Provided JWK was invalid
* @throws DomainException OpenSSL failure
*
* @uses createPemFromModulusAndExponent
*/
public static function parseKey(array $jwk)
{
if (empty($jwk)) {
throw new InvalidArgumentException('JWK must not be empty');
}
if (!isset($jwk['kty'])) {
throw new UnexpectedValueException('JWK must contain a "kty" parameter');
}
switch ($jwk['kty']) {
case 'RSA':
if (!empty($jwk['d'])) {
throw new UnexpectedValueException('RSA private keys are not supported');
}
if (!isset($jwk['n']) || !isset($jwk['e'])) {
throw new UnexpectedValueException('RSA keys must contain values for both "n" and "e"');
}
$pem = self::createPemFromModulusAndExponent($jwk['n'], $jwk['e']);
$publicKey = \openssl_pkey_get_public($pem);
if (\false === $publicKey) {
throw new DomainException('OpenSSL error: ' . \openssl_error_string());
}
return $publicKey;
default:
// Currently only RSA is supported
break;
}
}
/**
* Create a public key represented in PEM format from RSA modulus and exponent information
*
* @param string $n The RSA modulus encoded in Base64
* @param string $e The RSA exponent encoded in Base64
*
* @return string The RSA public key represented in PEM format
*
* @uses encodeLength
*/
private static function createPemFromModulusAndExponent($n, $e)
{
$modulus = JWT::urlsafeB64Decode($n);
$publicExponent = JWT::urlsafeB64Decode($e);
$components = array('modulus' => \pack('Ca*a*', 2, self::encodeLength(\strlen($modulus)), $modulus), 'publicExponent' => \pack('Ca*a*', 2, self::encodeLength(\strlen($publicExponent)), $publicExponent));
$rsaPublicKey = \pack('Ca*a*a*', 48, self::encodeLength(\strlen($components['modulus']) + \strlen($components['publicExponent'])), $components['modulus'], $components['publicExponent']);
// sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption.
$rsaOID = \pack('H*', '300d06092a864886f70d0101010500');
// hex version of MA0GCSqGSIb3DQEBAQUA
$rsaPublicKey = \chr(0) . $rsaPublicKey;
$rsaPublicKey = \chr(3) . self::encodeLength(\strlen($rsaPublicKey)) . $rsaPublicKey;
$rsaPublicKey = \pack('Ca*a*', 48, self::encodeLength(\strlen($rsaOID . $rsaPublicKey)), $rsaOID . $rsaPublicKey);
$rsaPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . \chunk_split(\base64_encode($rsaPublicKey), 64) . '-----END PUBLIC KEY-----';
return $rsaPublicKey;
}
/**
* DER-encode the length
*
* DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See
* {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
*
* @param int $length
* @return string
*/
private static function encodeLength($length)
{
if ($length <= 0x7f) {
return \chr($length);
}
$temp = \ltrim(\pack('N', $length), \chr(0));
return \pack('Ca*', 0x80 | \strlen($temp), $temp);
}
}

View File

@@ -0,0 +1,519 @@
<?php
namespace VendorDuplicator\Firebase\JWT;
use ArrayAccess;
use DomainException;
use Exception;
use InvalidArgumentException;
use OpenSSLAsymmetricKey;
use UnexpectedValueException;
use DateTime;
/**
* JSON Web Token implementation, based on this spec:
* https://tools.ietf.org/html/rfc7519
*
* PHP version 5
*
* @category Authentication
* @package Authentication_JWT
* @author Neuman Vong <neuman@twilio.com>
* @author Anant Narayanan <anant@php.net>
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
* @link https://github.com/firebase/php-jwt
*/
class JWT
{
const ASN1_INTEGER = 0x2;
const ASN1_SEQUENCE = 0x10;
const ASN1_BIT_STRING = 0x3;
/**
* When checking nbf, iat or expiration times,
* we want to provide some extra leeway time to
* account for clock skew.
*/
public static $leeway = 0;
/**
* Allow the current timestamp to be specified.
* Useful for fixing a value within unit testing.
*
* Will default to PHP time() value if null.
*/
public static $timestamp = null;
public static $supported_algs = array('ES384' => array('openssl', 'SHA384'), 'ES256' => array('openssl', 'SHA256'), 'HS256' => array('hash_hmac', 'SHA256'), 'HS384' => array('hash_hmac', 'SHA384'), 'HS512' => array('hash_hmac', 'SHA512'), 'RS256' => array('openssl', 'SHA256'), 'RS384' => array('openssl', 'SHA384'), 'RS512' => array('openssl', 'SHA512'), 'EdDSA' => array('sodium_crypto', 'EdDSA'));
/**
* Decodes a JWT string into a PHP object.
*
* @param string $jwt The JWT
* @param Key|array<Key>|mixed $keyOrKeyArray The Key or array of Key objects.
* If the algorithm used is asymmetric, this is the public key
* Each Key object contains an algorithm and matching key.
* Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
* 'HS512', 'RS256', 'RS384', and 'RS512'
* @param array $allowed_algs [DEPRECATED] List of supported verification algorithms. Only
* should be used for backwards compatibility.
*
* @return object The JWT's payload as a PHP object
*
* @throws InvalidArgumentException Provided JWT was empty
* @throws UnexpectedValueException Provided JWT was invalid
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
* @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
* @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
*
* @uses jsonDecode
* @uses urlsafeB64Decode
*/
public static function decode($jwt, $keyOrKeyArray, array $allowed_algs = array())
{
$timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp;
if (empty($keyOrKeyArray)) {
throw new InvalidArgumentException('Key may not be empty');
}
$tks = \explode('.', $jwt);
if (\count($tks) != 3) {
throw new UnexpectedValueException('Wrong number of segments');
}
list($headb64, $bodyb64, $cryptob64) = $tks;
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
throw new UnexpectedValueException('Invalid header encoding');
}
if (null === ($payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64)))) {
throw new UnexpectedValueException('Invalid claims encoding');
}
if (\false === ($sig = static::urlsafeB64Decode($cryptob64))) {
throw new UnexpectedValueException('Invalid signature encoding');
}
if (empty($header->alg)) {
throw new UnexpectedValueException('Empty algorithm');
}
if (empty(static::$supported_algs[$header->alg])) {
throw new UnexpectedValueException('Algorithm not supported');
}
list($keyMaterial, $algorithm) = self::getKeyMaterialAndAlgorithm($keyOrKeyArray, empty($header->kid) ? null : $header->kid);
if (empty($algorithm)) {
// Use deprecated "allowed_algs" to determine if the algorithm is supported.
// This opens up the possibility of an attack in some implementations.
// @see https://github.com/firebase/php-jwt/issues/351
if (!\in_array($header->alg, $allowed_algs)) {
throw new UnexpectedValueException('Algorithm not allowed');
}
} else {
// Check the algorithm
if (!self::constantTimeEquals($algorithm, $header->alg)) {
// See issue #351
throw new UnexpectedValueException('Incorrect key for this algorithm');
}
}
if ($header->alg === 'ES256' || $header->alg === 'ES384') {
// OpenSSL expects an ASN.1 DER sequence for ES256/ES384 signatures
$sig = self::signatureToDER($sig);
}
if (!static::verify("{$headb64}.{$bodyb64}", $sig, $keyMaterial, $header->alg)) {
throw new SignatureInvalidException('Signature verification failed');
}
// Check the nbf if it is defined. This is the time that the
// token can actually be used. If it's not yet that time, abort.
if (isset($payload->nbf) && $payload->nbf > $timestamp + static::$leeway) {
throw new BeforeValidException('Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->nbf));
}
// Check that this token has been created before 'now'. This prevents
// using tokens that have been created for later use (and haven't
// correctly used the nbf claim).
if (isset($payload->iat) && $payload->iat > $timestamp + static::$leeway) {
throw new BeforeValidException('Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->iat));
}
// Check if this token has expired.
if (isset($payload->exp) && $timestamp - static::$leeway >= $payload->exp) {
throw new ExpiredException('Expired token');
}
return $payload;
}
/**
* Converts and signs a PHP object or array into a JWT string.
*
* @param object|array $payload PHP object or array
* @param string|resource $key The secret key.
* If the algorithm used is asymmetric, this is the private key
* @param string $alg The signing algorithm.
* Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
* 'HS512', 'RS256', 'RS384', and 'RS512'
* @param mixed $keyId
* @param array $head An array with header elements to attach
*
* @return string A signed JWT
*
* @uses jsonEncode
* @uses urlsafeB64Encode
*/
public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
{
$header = array('typ' => 'JWT', 'alg' => $alg);
if ($keyId !== null) {
$header['kid'] = $keyId;
}
if (isset($head) && \is_array($head)) {
$header = \array_merge($head, $header);
}
$segments = array();
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
$signing_input = \implode('.', $segments);
$signature = static::sign($signing_input, $key, $alg);
$segments[] = static::urlsafeB64Encode($signature);
return \implode('.', $segments);
}
/**
* Sign a string with a given key and algorithm.
*
* @param string $msg The message to sign
* @param string|resource $key The secret key
* @param string $alg The signing algorithm.
* Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
* 'HS512', 'RS256', 'RS384', and 'RS512'
*
* @return string An encrypted message
*
* @throws DomainException Unsupported algorithm or bad key was specified
*/
public static function sign($msg, $key, $alg = 'HS256')
{
if (empty(static::$supported_algs[$alg])) {
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch ($function) {
case 'hash_hmac':
return \hash_hmac($algorithm, $msg, $key, \true);
case 'openssl':
$signature = '';
$success = \openssl_sign($msg, $signature, $key, $algorithm);
if (!$success) {
throw new DomainException("OpenSSL unable to sign data");
}
if ($alg === 'ES256') {
$signature = self::signatureFromDER($signature, 256);
} elseif ($alg === 'ES384') {
$signature = self::signatureFromDER($signature, 384);
}
return $signature;
case 'sodium_crypto':
if (!\function_exists('sodium_crypto_sign_detached')) {
throw new DomainException('libsodium is not available');
}
try {
// The last non-empty line is used as the key.
$lines = \array_filter(\explode("\n", $key));
$key = \base64_decode(\end($lines));
return \sodium_crypto_sign_detached($msg, $key);
} catch (Exception $e) {
throw new DomainException($e->getMessage(), 0, $e);
}
}
}
/**
* Verify a signature with the message, key and method. Not all methods
* are symmetric, so we must have a separate verify and sign method.
*
* @param string $msg The original message (header and body)
* @param string $signature The original signature
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
* @param string $alg The algorithm
*
* @return bool
*
* @throws DomainException Invalid Algorithm, bad key, or OpenSSL failure
*/
private static function verify($msg, $signature, $key, $alg)
{
if (empty(static::$supported_algs[$alg])) {
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch ($function) {
case 'openssl':
$success = \openssl_verify($msg, $signature, $key, $algorithm);
if ($success === 1) {
return \true;
} elseif ($success === 0) {
return \false;
}
// returns 1 on success, 0 on failure, -1 on error.
throw new DomainException('OpenSSL error: ' . \openssl_error_string());
case 'sodium_crypto':
if (!\function_exists('sodium_crypto_sign_verify_detached')) {
throw new DomainException('libsodium is not available');
}
try {
// The last non-empty line is used as the key.
$lines = \array_filter(\explode("\n", $key));
$key = \base64_decode(\end($lines));
return \sodium_crypto_sign_verify_detached($signature, $msg, $key);
} catch (Exception $e) {
throw new DomainException($e->getMessage(), 0, $e);
}
case 'hash_hmac':
default:
$hash = \hash_hmac($algorithm, $msg, $key, \true);
return self::constantTimeEquals($signature, $hash);
}
}
/**
* Decode a JSON string into a PHP object.
*
* @param string $input JSON string
*
* @return object Object representation of JSON string
*
* @throws DomainException Provided string was invalid JSON
*/
public static function jsonDecode($input)
{
if (\version_compare(\PHP_VERSION, '5.4.0', '>=') && !(\defined('JSON_C_VERSION') && \PHP_INT_SIZE > 4)) {
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
* to specify that large ints (like Steam Transaction IDs) should be treated as
* strings, rather than the PHP default behaviour of converting them to floats.
*/
$obj = \json_decode($input, \false, 512, \JSON_BIGINT_AS_STRING);
} else {
/** Not all servers will support that, however, so for older versions we must
* manually detect large ints in the JSON string and quote them (thus converting
*them to strings) before decoding, hence the preg_replace() call.
*/
$max_int_length = \strlen((string) \PHP_INT_MAX) - 1;
$json_without_bigints = \preg_replace('/:\\s*(-?\\d{' . $max_int_length . ',})/', ': "$1"', $input);
$obj = \json_decode($json_without_bigints);
}
if ($errno = \json_last_error()) {
static::handleJsonError($errno);
} elseif ($obj === null && $input !== 'null') {
throw new DomainException('Null result with non-null input');
}
return $obj;
}
/**
* Encode a PHP object into a JSON string.
*
* @param object|array $input A PHP object or array
*
* @return string JSON representation of the PHP object or array
*
* @throws DomainException Provided object could not be encoded to valid JSON
*/
public static function jsonEncode($input)
{
$json = \json_encode($input);
if ($errno = \json_last_error()) {
static::handleJsonError($errno);
} elseif ($json === 'null' && $input !== null) {
throw new DomainException('Null result with non-null input');
}
return $json;
}
/**
* Decode a string with URL-safe Base64.
*
* @param string $input A Base64 encoded string
*
* @return string A decoded string
*/
public static function urlsafeB64Decode($input)
{
$remainder = \strlen($input) % 4;
if ($remainder) {
$padlen = 4 - $remainder;
$input .= \str_repeat('=', $padlen);
}
return \base64_decode(\strtr($input, '-_', '+/'));
}
/**
* Encode a string with URL-safe Base64.
*
* @param string $input The string you want encoded
*
* @return string The base64 encode of what you passed in
*/
public static function urlsafeB64Encode($input)
{
return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_'));
}
/**
* Determine if an algorithm has been provided for each Key
*
* @param Key|array<Key>|mixed $keyOrKeyArray
* @param string|null $kid
*
* @throws UnexpectedValueException
*
* @return array containing the keyMaterial and algorithm
*/
private static function getKeyMaterialAndAlgorithm($keyOrKeyArray, $kid = null)
{
if (\is_string($keyOrKeyArray) || \is_resource($keyOrKeyArray) || $keyOrKeyArray instanceof OpenSSLAsymmetricKey) {
return array($keyOrKeyArray, null);
}
if ($keyOrKeyArray instanceof Key) {
return array($keyOrKeyArray->getKeyMaterial(), $keyOrKeyArray->getAlgorithm());
}
if (\is_array($keyOrKeyArray) || $keyOrKeyArray instanceof ArrayAccess) {
if (!isset($kid)) {
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
}
if (!isset($keyOrKeyArray[$kid])) {
throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
}
$key = $keyOrKeyArray[$kid];
if ($key instanceof Key) {
return array($key->getKeyMaterial(), $key->getAlgorithm());
}
return array($key, null);
}
throw new UnexpectedValueException('$keyOrKeyArray must be a string|resource key, an array of string|resource keys, ' . 'an instance of Firebase\\JWT\\Key key or an array of Firebase\\JWT\\Key keys');
}
/**
* @param string $left
* @param string $right
* @return bool
*/
public static function constantTimeEquals($left, $right)
{
if (\function_exists('hash_equals')) {
return \hash_equals($left, $right);
}
$len = \min(static::safeStrlen($left), static::safeStrlen($right));
$status = 0;
for ($i = 0; $i < $len; $i++) {
$status |= \ord($left[$i]) ^ \ord($right[$i]);
}
$status |= static::safeStrlen($left) ^ static::safeStrlen($right);
return $status === 0;
}
/**
* Helper method to create a JSON error.
*
* @param int $errno An error number from json_last_error()
*
* @return void
*/
private static function handleJsonError($errno)
{
$messages = array(\JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', \JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON', \JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', \JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', \JSON_ERROR_UTF8 => 'Malformed UTF-8 characters');
throw new DomainException(isset($messages[$errno]) ? $messages[$errno] : 'Unknown JSON error: ' . $errno);
}
/**
* Get the number of bytes in cryptographic strings.
*
* @param string $str
*
* @return int
*/
private static function safeStrlen($str)
{
if (\function_exists('mb_strlen')) {
return \mb_strlen($str, '8bit');
}
return \strlen($str);
}
/**
* Convert an ECDSA signature to an ASN.1 DER sequence
*
* @param string $sig The ECDSA signature to convert
* @return string The encoded DER object
*/
private static function signatureToDER($sig)
{
// Separate the signature into r-value and s-value
list($r, $s) = \str_split($sig, (int) (\strlen($sig) / 2));
// Trim leading zeros
$r = \ltrim($r, "\x00");
$s = \ltrim($s, "\x00");
// Convert r-value and s-value from unsigned big-endian integers to
// signed two's complement
if (\ord($r[0]) > 0x7f) {
$r = "\x00" . $r;
}
if (\ord($s[0]) > 0x7f) {
$s = "\x00" . $s;
}
return self::encodeDER(self::ASN1_SEQUENCE, self::encodeDER(self::ASN1_INTEGER, $r) . self::encodeDER(self::ASN1_INTEGER, $s));
}
/**
* Encodes a value into a DER object.
*
* @param int $type DER tag
* @param string $value the value to encode
* @return string the encoded object
*/
private static function encodeDER($type, $value)
{
$tag_header = 0;
if ($type === self::ASN1_SEQUENCE) {
$tag_header |= 0x20;
}
// Type
$der = \chr($tag_header | $type);
// Length
$der .= \chr(\strlen($value));
return $der . $value;
}
/**
* Encodes signature from a DER object.
*
* @param string $der binary signature in DER format
* @param int $keySize the number of bits in the key
* @return string the signature
*/
private static function signatureFromDER($der, $keySize)
{
// OpenSSL returns the ECDSA signatures as a binary ASN.1 DER SEQUENCE
list($offset, $_) = self::readDER($der);
list($offset, $r) = self::readDER($der, $offset);
list($offset, $s) = self::readDER($der, $offset);
// Convert r-value and s-value from signed two's compliment to unsigned
// big-endian integers
$r = \ltrim($r, "\x00");
$s = \ltrim($s, "\x00");
// Pad out r and s so that they are $keySize bits long
$r = \str_pad($r, $keySize / 8, "\x00", \STR_PAD_LEFT);
$s = \str_pad($s, $keySize / 8, "\x00", \STR_PAD_LEFT);
return $r . $s;
}
/**
* Reads binary DER-encoded data and decodes into a single object
*
* @param string $der the binary data in DER format
* @param int $offset the offset of the data stream containing the object
* to decode
* @return array [$offset, $data] the new offset and the decoded object
*/
private static function readDER($der, $offset = 0)
{
$pos = $offset;
$size = \strlen($der);
$constructed = \ord($der[$pos]) >> 5 & 0x1;
$type = \ord($der[$pos++]) & 0x1f;
// Length
$len = \ord($der[$pos++]);
if ($len & 0x80) {
$n = $len & 0x1f;
$len = 0;
while ($n-- && $pos < $size) {
$len = $len << 8 | \ord($der[$pos++]);
}
}
// Value
if ($type == self::ASN1_BIT_STRING) {
$pos++;
// Skip the first contents octet (padding indicator)
$data = \substr($der, $pos, $len - 1);
$pos += $len - 1;
} elseif (!$constructed) {
$data = \substr($der, $pos, $len);
$pos += $len;
} else {
$data = null;
}
return array($pos, $data);
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace VendorDuplicator\Firebase\JWT;
use InvalidArgumentException;
use OpenSSLAsymmetricKey;
class Key
{
/** @var string $algorithm */
private $algorithm;
/** @var string|resource|OpenSSLAsymmetricKey $keyMaterial */
private $keyMaterial;
/**
* @param string|resource|OpenSSLAsymmetricKey $keyMaterial
* @param string $algorithm
*/
public function __construct($keyMaterial, $algorithm)
{
if (!\is_string($keyMaterial) && !\is_resource($keyMaterial) && !$keyMaterial instanceof OpenSSLAsymmetricKey) {
throw new InvalidArgumentException('Type error: $keyMaterial must be a string, resource, or OpenSSLAsymmetricKey');
}
if (empty($keyMaterial)) {
throw new InvalidArgumentException('Type error: $keyMaterial must not be empty');
}
if (!\is_string($algorithm) || empty($keyMaterial)) {
throw new InvalidArgumentException('Type error: $algorithm must be a string');
}
$this->keyMaterial = $keyMaterial;
$this->algorithm = $algorithm;
}
/**
* Return the algorithm valid for this key
*
* @return string
*/
public function getAlgorithm()
{
return $this->algorithm;
}
/**
* @return string|resource|OpenSSLAsymmetricKey
*/
public function getKeyMaterial()
{
return $this->keyMaterial;
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace VendorDuplicator\Firebase\JWT;
class SignatureInvalidException extends \UnexpectedValueException
{
}

View File

@@ -0,0 +1,26 @@
<?php
namespace VendorDuplicator;
// For older (pre-2.7.2) verions of google/apiclient
if (\file_exists(__DIR__ . '/../apiclient/src/Google/Client.php') && !\class_exists('VendorDuplicator\\Google_Client', \false)) {
require_once __DIR__ . '/../apiclient/src/Google/Client.php';
if (\defined('VendorDuplicator\\Google_Client::LIBVER') && \version_compare(Google_Client::LIBVER, '2.7.2', '<=')) {
$servicesClassMap = ['VendorDuplicator\\Google\\Client' => 'VendorDuplicator\\Google_Client', 'VendorDuplicator\\Google\\Service' => 'VendorDuplicator\\Google_Service', 'VendorDuplicator\\Google\\Service\\Resource' => 'VendorDuplicator\\Google_Service_Resource', 'VendorDuplicator\\Google\\Model' => 'VendorDuplicator\\Google_Model', 'VendorDuplicator\\Google\\Collection' => 'VendorDuplicator\\Google_Collection'];
foreach ($servicesClassMap as $alias => $class) {
\class_alias($class, $alias);
}
}
}
\spl_autoload_register(function ($class) {
if (0 === \strpos($class, 'VendorDuplicator\\Google_Service_')) {
// Autoload the new class, which will also create an alias for the
// old class by changing underscores to namespaces:
// Google_Service_Speech_Resource_Operations
// => Google\Service\Speech\Resource\Operations
$classExists = \class_exists($newClass = \str_replace('_', '\\', $class));
if ($classExists) {
return \true;
}
}
}, \true, \true);

View File

@@ -0,0 +1,251 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class About extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'teamDriveThemes';
/**
* @var bool
*/
public $appInstalled;
/**
* @var bool
*/
public $canCreateDrives;
/**
* @var bool
*/
public $canCreateTeamDrives;
protected $driveThemesType = AboutDriveThemes::class;
protected $driveThemesDataType = 'array';
/**
* @var string[]
*/
public $exportFormats;
/**
* @var string[]
*/
public $folderColorPalette;
/**
* @var string[]
*/
public $importFormats;
/**
* @var string
*/
public $kind;
/**
* @var string[]
*/
public $maxImportSizes;
/**
* @var string
*/
public $maxUploadSize;
protected $storageQuotaType = AboutStorageQuota::class;
protected $storageQuotaDataType = '';
protected $teamDriveThemesType = AboutTeamDriveThemes::class;
protected $teamDriveThemesDataType = 'array';
protected $userType = User::class;
protected $userDataType = '';
/**
* @param bool
*/
public function setAppInstalled($appInstalled)
{
$this->appInstalled = $appInstalled;
}
/**
* @return bool
*/
public function getAppInstalled()
{
return $this->appInstalled;
}
/**
* @param bool
*/
public function setCanCreateDrives($canCreateDrives)
{
$this->canCreateDrives = $canCreateDrives;
}
/**
* @return bool
*/
public function getCanCreateDrives()
{
return $this->canCreateDrives;
}
/**
* @param bool
*/
public function setCanCreateTeamDrives($canCreateTeamDrives)
{
$this->canCreateTeamDrives = $canCreateTeamDrives;
}
/**
* @return bool
*/
public function getCanCreateTeamDrives()
{
return $this->canCreateTeamDrives;
}
/**
* @param AboutDriveThemes[]
*/
public function setDriveThemes($driveThemes)
{
$this->driveThemes = $driveThemes;
}
/**
* @return AboutDriveThemes[]
*/
public function getDriveThemes()
{
return $this->driveThemes;
}
/**
* @param string[]
*/
public function setExportFormats($exportFormats)
{
$this->exportFormats = $exportFormats;
}
/**
* @return string[]
*/
public function getExportFormats()
{
return $this->exportFormats;
}
/**
* @param string[]
*/
public function setFolderColorPalette($folderColorPalette)
{
$this->folderColorPalette = $folderColorPalette;
}
/**
* @return string[]
*/
public function getFolderColorPalette()
{
return $this->folderColorPalette;
}
/**
* @param string[]
*/
public function setImportFormats($importFormats)
{
$this->importFormats = $importFormats;
}
/**
* @return string[]
*/
public function getImportFormats()
{
return $this->importFormats;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string[]
*/
public function setMaxImportSizes($maxImportSizes)
{
$this->maxImportSizes = $maxImportSizes;
}
/**
* @return string[]
*/
public function getMaxImportSizes()
{
return $this->maxImportSizes;
}
/**
* @param string
*/
public function setMaxUploadSize($maxUploadSize)
{
$this->maxUploadSize = $maxUploadSize;
}
/**
* @return string
*/
public function getMaxUploadSize()
{
return $this->maxUploadSize;
}
/**
* @param AboutStorageQuota
*/
public function setStorageQuota(AboutStorageQuota $storageQuota)
{
$this->storageQuota = $storageQuota;
}
/**
* @return AboutStorageQuota
*/
public function getStorageQuota()
{
return $this->storageQuota;
}
/**
* @param AboutTeamDriveThemes[]
*/
public function setTeamDriveThemes($teamDriveThemes)
{
$this->teamDriveThemes = $teamDriveThemes;
}
/**
* @return AboutTeamDriveThemes[]
*/
public function getTeamDriveThemes()
{
return $this->teamDriveThemes;
}
/**
* @param User
*/
public function setUser(User $user)
{
$this->user = $user;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(About::class, 'VendorDuplicator\\Google_Service_Drive_About');

View File

@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class AboutDriveThemes extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $backgroundImageLink;
/**
* @var string
*/
public $colorRgb;
/**
* @var string
*/
public $id;
/**
* @param string
*/
public function setBackgroundImageLink($backgroundImageLink)
{
$this->backgroundImageLink = $backgroundImageLink;
}
/**
* @return string
*/
public function getBackgroundImageLink()
{
return $this->backgroundImageLink;
}
/**
* @param string
*/
public function setColorRgb($colorRgb)
{
$this->colorRgb = $colorRgb;
}
/**
* @return string
*/
public function getColorRgb()
{
return $this->colorRgb;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(AboutDriveThemes::class, 'VendorDuplicator\\Google_Service_Drive_AboutDriveThemes');

View File

@@ -0,0 +1,96 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class AboutStorageQuota extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $limit;
/**
* @var string
*/
public $usage;
/**
* @var string
*/
public $usageInDrive;
/**
* @var string
*/
public $usageInDriveTrash;
/**
* @param string
*/
public function setLimit($limit)
{
$this->limit = $limit;
}
/**
* @return string
*/
public function getLimit()
{
return $this->limit;
}
/**
* @param string
*/
public function setUsage($usage)
{
$this->usage = $usage;
}
/**
* @return string
*/
public function getUsage()
{
return $this->usage;
}
/**
* @param string
*/
public function setUsageInDrive($usageInDrive)
{
$this->usageInDrive = $usageInDrive;
}
/**
* @return string
*/
public function getUsageInDrive()
{
return $this->usageInDrive;
}
/**
* @param string
*/
public function setUsageInDriveTrash($usageInDriveTrash)
{
$this->usageInDriveTrash = $usageInDriveTrash;
}
/**
* @return string
*/
public function getUsageInDriveTrash()
{
return $this->usageInDriveTrash;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(AboutStorageQuota::class, 'VendorDuplicator\\Google_Service_Drive_AboutStorageQuota');

View File

@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class AboutTeamDriveThemes extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $backgroundImageLink;
/**
* @var string
*/
public $colorRgb;
/**
* @var string
*/
public $id;
/**
* @param string
*/
public function setBackgroundImageLink($backgroundImageLink)
{
$this->backgroundImageLink = $backgroundImageLink;
}
/**
* @return string
*/
public function getBackgroundImageLink()
{
return $this->backgroundImageLink;
}
/**
* @param string
*/
public function setColorRgb($colorRgb)
{
$this->colorRgb = $colorRgb;
}
/**
* @return string
*/
public function getColorRgb()
{
return $this->colorRgb;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(AboutTeamDriveThemes::class, 'VendorDuplicator\\Google_Service_Drive_AboutTeamDriveThemes');

View File

@@ -0,0 +1,216 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Change extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $changeType;
protected $driveType = Drive::class;
protected $driveDataType = '';
/**
* @var string
*/
public $driveId;
protected $fileType = DriveFile::class;
protected $fileDataType = '';
/**
* @var string
*/
public $fileId;
/**
* @var string
*/
public $kind;
/**
* @var bool
*/
public $removed;
protected $teamDriveType = TeamDrive::class;
protected $teamDriveDataType = '';
/**
* @var string
*/
public $teamDriveId;
/**
* @var string
*/
public $time;
/**
* @var string
*/
public $type;
/**
* @param string
*/
public function setChangeType($changeType)
{
$this->changeType = $changeType;
}
/**
* @return string
*/
public function getChangeType()
{
return $this->changeType;
}
/**
* @param Drive
*/
public function setDrive(Drive $drive)
{
$this->drive = $drive;
}
/**
* @return Drive
*/
public function getDrive()
{
return $this->drive;
}
/**
* @param string
*/
public function setDriveId($driveId)
{
$this->driveId = $driveId;
}
/**
* @return string
*/
public function getDriveId()
{
return $this->driveId;
}
/**
* @param DriveFile
*/
public function setFile(DriveFile $file)
{
$this->file = $file;
}
/**
* @return DriveFile
*/
public function getFile()
{
return $this->file;
}
/**
* @param string
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param bool
*/
public function setRemoved($removed)
{
$this->removed = $removed;
}
/**
* @return bool
*/
public function getRemoved()
{
return $this->removed;
}
/**
* @param TeamDrive
*/
public function setTeamDrive(TeamDrive $teamDrive)
{
$this->teamDrive = $teamDrive;
}
/**
* @return TeamDrive
*/
public function getTeamDrive()
{
return $this->teamDrive;
}
/**
* @param string
*/
public function setTeamDriveId($teamDriveId)
{
$this->teamDriveId = $teamDriveId;
}
/**
* @return string
*/
public function getTeamDriveId()
{
return $this->teamDriveId;
}
/**
* @param string
*/
public function setTime($time)
{
$this->time = $time;
}
/**
* @return string
*/
public function getTime()
{
return $this->time;
}
/**
* @param string
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Change::class, 'VendorDuplicator\\Google_Service_Drive_Change');

View File

@@ -0,0 +1,95 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class ChangeList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'changes';
protected $changesType = Change::class;
protected $changesDataType = 'array';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $newStartPageToken;
/**
* @var string
*/
public $nextPageToken;
/**
* @param Change[]
*/
public function setChanges($changes)
{
$this->changes = $changes;
}
/**
* @return Change[]
*/
public function getChanges()
{
return $this->changes;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNewStartPageToken($newStartPageToken)
{
$this->newStartPageToken = $newStartPageToken;
}
/**
* @return string
*/
public function getNewStartPageToken()
{
return $this->newStartPageToken;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(ChangeList::class, 'VendorDuplicator\\Google_Service_Drive_ChangeList');

View File

@@ -0,0 +1,204 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Channel extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $address;
/**
* @var string
*/
public $expiration;
/**
* @var string
*/
public $id;
/**
* @var string
*/
public $kind;
/**
* @var string[]
*/
public $params;
/**
* @var bool
*/
public $payload;
/**
* @var string
*/
public $resourceId;
/**
* @var string
*/
public $resourceUri;
/**
* @var string
*/
public $token;
/**
* @var string
*/
public $type;
/**
* @param string
*/
public function setAddress($address)
{
$this->address = $address;
}
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @param string
*/
public function setExpiration($expiration)
{
$this->expiration = $expiration;
}
/**
* @return string
*/
public function getExpiration()
{
return $this->expiration;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string[]
*/
public function setParams($params)
{
$this->params = $params;
}
/**
* @return string[]
*/
public function getParams()
{
return $this->params;
}
/**
* @param bool
*/
public function setPayload($payload)
{
$this->payload = $payload;
}
/**
* @return bool
*/
public function getPayload()
{
return $this->payload;
}
/**
* @param string
*/
public function setResourceId($resourceId)
{
$this->resourceId = $resourceId;
}
/**
* @return string
*/
public function getResourceId()
{
return $this->resourceId;
}
/**
* @param string
*/
public function setResourceUri($resourceUri)
{
$this->resourceUri = $resourceUri;
}
/**
* @return string
*/
public function getResourceUri()
{
return $this->resourceUri;
}
/**
* @param string
*/
public function setToken($token)
{
$this->token = $token;
}
/**
* @return string
*/
public function getToken()
{
return $this->token;
}
/**
* @param string
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Channel::class, 'VendorDuplicator\\Google_Service_Drive_Channel');

View File

@@ -0,0 +1,235 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Comment extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'replies';
/**
* @var string
*/
public $anchor;
protected $authorType = User::class;
protected $authorDataType = '';
/**
* @var string
*/
public $content;
/**
* @var string
*/
public $createdTime;
/**
* @var bool
*/
public $deleted;
/**
* @var string
*/
public $htmlContent;
/**
* @var string
*/
public $id;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $modifiedTime;
protected $quotedFileContentType = CommentQuotedFileContent::class;
protected $quotedFileContentDataType = '';
protected $repliesType = Reply::class;
protected $repliesDataType = 'array';
/**
* @var bool
*/
public $resolved;
/**
* @param string
*/
public function setAnchor($anchor)
{
$this->anchor = $anchor;
}
/**
* @return string
*/
public function getAnchor()
{
return $this->anchor;
}
/**
* @param User
*/
public function setAuthor(User $author)
{
$this->author = $author;
}
/**
* @return User
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param string
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* @param string
*/
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
/**
* @return string
*/
public function getCreatedTime()
{
return $this->createdTime;
}
/**
* @param bool
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
/**
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* @param string
*/
public function setHtmlContent($htmlContent)
{
$this->htmlContent = $htmlContent;
}
/**
* @return string
*/
public function getHtmlContent()
{
return $this->htmlContent;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
/**
* @return string
*/
public function getModifiedTime()
{
return $this->modifiedTime;
}
/**
* @param CommentQuotedFileContent
*/
public function setQuotedFileContent(CommentQuotedFileContent $quotedFileContent)
{
$this->quotedFileContent = $quotedFileContent;
}
/**
* @return CommentQuotedFileContent
*/
public function getQuotedFileContent()
{
return $this->quotedFileContent;
}
/**
* @param Reply[]
*/
public function setReplies($replies)
{
$this->replies = $replies;
}
/**
* @return Reply[]
*/
public function getReplies()
{
return $this->replies;
}
/**
* @param bool
*/
public function setResolved($resolved)
{
$this->resolved = $resolved;
}
/**
* @return bool
*/
public function getResolved()
{
return $this->resolved;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Comment::class, 'VendorDuplicator\\Google_Service_Drive_Comment');

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class CommentList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'comments';
protected $commentsType = Comment::class;
protected $commentsDataType = 'array';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $nextPageToken;
/**
* @param Comment[]
*/
public function setComments($comments)
{
$this->comments = $comments;
}
/**
* @return Comment[]
*/
public function getComments()
{
return $this->comments;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(CommentList::class, 'VendorDuplicator\\Google_Service_Drive_CommentList');

View File

@@ -0,0 +1,60 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class CommentQuotedFileContent extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $mimeType;
/**
* @var string
*/
public $value;
/**
* @param string
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* @param string
*/
public function setValue($value)
{
$this->value = $value;
}
/**
* @return string
*/
public function getValue()
{
return $this->value;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(CommentQuotedFileContent::class, 'VendorDuplicator\\Google_Service_Drive_CommentQuotedFileContent');

View File

@@ -0,0 +1,112 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class ContentRestriction extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $readOnly;
/**
* @var string
*/
public $reason;
protected $restrictingUserType = User::class;
protected $restrictingUserDataType = '';
/**
* @var string
*/
public $restrictionTime;
/**
* @var string
*/
public $type;
/**
* @param bool
*/
public function setReadOnly($readOnly)
{
$this->readOnly = $readOnly;
}
/**
* @return bool
*/
public function getReadOnly()
{
return $this->readOnly;
}
/**
* @param string
*/
public function setReason($reason)
{
$this->reason = $reason;
}
/**
* @return string
*/
public function getReason()
{
return $this->reason;
}
/**
* @param User
*/
public function setRestrictingUser(User $restrictingUser)
{
$this->restrictingUser = $restrictingUser;
}
/**
* @return User
*/
public function getRestrictingUser()
{
return $this->restrictingUser;
}
/**
* @param string
*/
public function setRestrictionTime($restrictionTime)
{
$this->restrictionTime = $restrictionTime;
}
/**
* @return string
*/
public function getRestrictionTime()
{
return $this->restrictionTime;
}
/**
* @param string
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(ContentRestriction::class, 'VendorDuplicator\\Google_Service_Drive_ContentRestriction');

View File

@@ -0,0 +1,234 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Drive extends \VendorDuplicator\Google\Model
{
protected $backgroundImageFileType = DriveBackgroundImageFile::class;
protected $backgroundImageFileDataType = '';
/**
* @var string
*/
public $backgroundImageLink;
protected $capabilitiesType = DriveCapabilities::class;
protected $capabilitiesDataType = '';
/**
* @var string
*/
public $colorRgb;
/**
* @var string
*/
public $createdTime;
/**
* @var bool
*/
public $hidden;
/**
* @var string
*/
public $id;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $name;
/**
* @var string
*/
public $orgUnitId;
protected $restrictionsType = DriveRestrictions::class;
protected $restrictionsDataType = '';
/**
* @var string
*/
public $themeId;
/**
* @param DriveBackgroundImageFile
*/
public function setBackgroundImageFile(DriveBackgroundImageFile $backgroundImageFile)
{
$this->backgroundImageFile = $backgroundImageFile;
}
/**
* @return DriveBackgroundImageFile
*/
public function getBackgroundImageFile()
{
return $this->backgroundImageFile;
}
/**
* @param string
*/
public function setBackgroundImageLink($backgroundImageLink)
{
$this->backgroundImageLink = $backgroundImageLink;
}
/**
* @return string
*/
public function getBackgroundImageLink()
{
return $this->backgroundImageLink;
}
/**
* @param DriveCapabilities
*/
public function setCapabilities(DriveCapabilities $capabilities)
{
$this->capabilities = $capabilities;
}
/**
* @return DriveCapabilities
*/
public function getCapabilities()
{
return $this->capabilities;
}
/**
* @param string
*/
public function setColorRgb($colorRgb)
{
$this->colorRgb = $colorRgb;
}
/**
* @return string
*/
public function getColorRgb()
{
return $this->colorRgb;
}
/**
* @param string
*/
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
/**
* @return string
*/
public function getCreatedTime()
{
return $this->createdTime;
}
/**
* @param bool
*/
public function setHidden($hidden)
{
$this->hidden = $hidden;
}
/**
* @return bool
*/
public function getHidden()
{
return $this->hidden;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string
*/
public function setOrgUnitId($orgUnitId)
{
$this->orgUnitId = $orgUnitId;
}
/**
* @return string
*/
public function getOrgUnitId()
{
return $this->orgUnitId;
}
/**
* @param DriveRestrictions
*/
public function setRestrictions(DriveRestrictions $restrictions)
{
$this->restrictions = $restrictions;
}
/**
* @return DriveRestrictions
*/
public function getRestrictions()
{
return $this->restrictions;
}
/**
* @param string
*/
public function setThemeId($themeId)
{
$this->themeId = $themeId;
}
/**
* @return string
*/
public function getThemeId()
{
return $this->themeId;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Drive::class, 'VendorDuplicator\\Google_Service_Drive_Drive');

View File

@@ -0,0 +1,96 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveBackgroundImageFile extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $id;
/**
* @var float
*/
public $width;
/**
* @var float
*/
public $xCoordinate;
/**
* @var float
*/
public $yCoordinate;
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param float
*/
public function setWidth($width)
{
$this->width = $width;
}
/**
* @return float
*/
public function getWidth()
{
return $this->width;
}
/**
* @param float
*/
public function setXCoordinate($xCoordinate)
{
$this->xCoordinate = $xCoordinate;
}
/**
* @return float
*/
public function getXCoordinate()
{
return $this->xCoordinate;
}
/**
* @param float
*/
public function setYCoordinate($yCoordinate)
{
$this->yCoordinate = $yCoordinate;
}
/**
* @return float
*/
public function getYCoordinate()
{
return $this->yCoordinate;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveBackgroundImageFile::class, 'VendorDuplicator\\Google_Service_Drive_DriveBackgroundImageFile');

View File

@@ -0,0 +1,384 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveCapabilities extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $canAddChildren;
/**
* @var bool
*/
public $canChangeCopyRequiresWriterPermissionRestriction;
/**
* @var bool
*/
public $canChangeDomainUsersOnlyRestriction;
/**
* @var bool
*/
public $canChangeDriveBackground;
/**
* @var bool
*/
public $canChangeDriveMembersOnlyRestriction;
/**
* @var bool
*/
public $canChangeSharingFoldersRequiresOrganizerPermissionRestriction;
/**
* @var bool
*/
public $canComment;
/**
* @var bool
*/
public $canCopy;
/**
* @var bool
*/
public $canDeleteChildren;
/**
* @var bool
*/
public $canDeleteDrive;
/**
* @var bool
*/
public $canDownload;
/**
* @var bool
*/
public $canEdit;
/**
* @var bool
*/
public $canListChildren;
/**
* @var bool
*/
public $canManageMembers;
/**
* @var bool
*/
public $canReadRevisions;
/**
* @var bool
*/
public $canRename;
/**
* @var bool
*/
public $canRenameDrive;
/**
* @var bool
*/
public $canResetDriveRestrictions;
/**
* @var bool
*/
public $canShare;
/**
* @var bool
*/
public $canTrashChildren;
/**
* @param bool
*/
public function setCanAddChildren($canAddChildren)
{
$this->canAddChildren = $canAddChildren;
}
/**
* @return bool
*/
public function getCanAddChildren()
{
return $this->canAddChildren;
}
/**
* @param bool
*/
public function setCanChangeCopyRequiresWriterPermissionRestriction($canChangeCopyRequiresWriterPermissionRestriction)
{
$this->canChangeCopyRequiresWriterPermissionRestriction = $canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* @return bool
*/
public function getCanChangeCopyRequiresWriterPermissionRestriction()
{
return $this->canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* @param bool
*/
public function setCanChangeDomainUsersOnlyRestriction($canChangeDomainUsersOnlyRestriction)
{
$this->canChangeDomainUsersOnlyRestriction = $canChangeDomainUsersOnlyRestriction;
}
/**
* @return bool
*/
public function getCanChangeDomainUsersOnlyRestriction()
{
return $this->canChangeDomainUsersOnlyRestriction;
}
/**
* @param bool
*/
public function setCanChangeDriveBackground($canChangeDriveBackground)
{
$this->canChangeDriveBackground = $canChangeDriveBackground;
}
/**
* @return bool
*/
public function getCanChangeDriveBackground()
{
return $this->canChangeDriveBackground;
}
/**
* @param bool
*/
public function setCanChangeDriveMembersOnlyRestriction($canChangeDriveMembersOnlyRestriction)
{
$this->canChangeDriveMembersOnlyRestriction = $canChangeDriveMembersOnlyRestriction;
}
/**
* @return bool
*/
public function getCanChangeDriveMembersOnlyRestriction()
{
return $this->canChangeDriveMembersOnlyRestriction;
}
/**
* @param bool
*/
public function setCanChangeSharingFoldersRequiresOrganizerPermissionRestriction($canChangeSharingFoldersRequiresOrganizerPermissionRestriction)
{
$this->canChangeSharingFoldersRequiresOrganizerPermissionRestriction = $canChangeSharingFoldersRequiresOrganizerPermissionRestriction;
}
/**
* @return bool
*/
public function getCanChangeSharingFoldersRequiresOrganizerPermissionRestriction()
{
return $this->canChangeSharingFoldersRequiresOrganizerPermissionRestriction;
}
/**
* @param bool
*/
public function setCanComment($canComment)
{
$this->canComment = $canComment;
}
/**
* @return bool
*/
public function getCanComment()
{
return $this->canComment;
}
/**
* @param bool
*/
public function setCanCopy($canCopy)
{
$this->canCopy = $canCopy;
}
/**
* @return bool
*/
public function getCanCopy()
{
return $this->canCopy;
}
/**
* @param bool
*/
public function setCanDeleteChildren($canDeleteChildren)
{
$this->canDeleteChildren = $canDeleteChildren;
}
/**
* @return bool
*/
public function getCanDeleteChildren()
{
return $this->canDeleteChildren;
}
/**
* @param bool
*/
public function setCanDeleteDrive($canDeleteDrive)
{
$this->canDeleteDrive = $canDeleteDrive;
}
/**
* @return bool
*/
public function getCanDeleteDrive()
{
return $this->canDeleteDrive;
}
/**
* @param bool
*/
public function setCanDownload($canDownload)
{
$this->canDownload = $canDownload;
}
/**
* @return bool
*/
public function getCanDownload()
{
return $this->canDownload;
}
/**
* @param bool
*/
public function setCanEdit($canEdit)
{
$this->canEdit = $canEdit;
}
/**
* @return bool
*/
public function getCanEdit()
{
return $this->canEdit;
}
/**
* @param bool
*/
public function setCanListChildren($canListChildren)
{
$this->canListChildren = $canListChildren;
}
/**
* @return bool
*/
public function getCanListChildren()
{
return $this->canListChildren;
}
/**
* @param bool
*/
public function setCanManageMembers($canManageMembers)
{
$this->canManageMembers = $canManageMembers;
}
/**
* @return bool
*/
public function getCanManageMembers()
{
return $this->canManageMembers;
}
/**
* @param bool
*/
public function setCanReadRevisions($canReadRevisions)
{
$this->canReadRevisions = $canReadRevisions;
}
/**
* @return bool
*/
public function getCanReadRevisions()
{
return $this->canReadRevisions;
}
/**
* @param bool
*/
public function setCanRename($canRename)
{
$this->canRename = $canRename;
}
/**
* @return bool
*/
public function getCanRename()
{
return $this->canRename;
}
/**
* @param bool
*/
public function setCanRenameDrive($canRenameDrive)
{
$this->canRenameDrive = $canRenameDrive;
}
/**
* @return bool
*/
public function getCanRenameDrive()
{
return $this->canRenameDrive;
}
/**
* @param bool
*/
public function setCanResetDriveRestrictions($canResetDriveRestrictions)
{
$this->canResetDriveRestrictions = $canResetDriveRestrictions;
}
/**
* @return bool
*/
public function getCanResetDriveRestrictions()
{
return $this->canResetDriveRestrictions;
}
/**
* @param bool
*/
public function setCanShare($canShare)
{
$this->canShare = $canShare;
}
/**
* @return bool
*/
public function getCanShare()
{
return $this->canShare;
}
/**
* @param bool
*/
public function setCanTrashChildren($canTrashChildren)
{
$this->canTrashChildren = $canTrashChildren;
}
/**
* @return bool
*/
public function getCanTrashChildren()
{
return $this->canTrashChildren;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveCapabilities::class, 'VendorDuplicator\\Google_Service_Drive_DriveCapabilities');

View File

@@ -0,0 +1,708 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileCapabilities extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $canAcceptOwnership;
/**
* @var bool
*/
public $canAddChildren;
/**
* @var bool
*/
public $canAddFolderFromAnotherDrive;
/**
* @var bool
*/
public $canAddMyDriveParent;
/**
* @var bool
*/
public $canChangeCopyRequiresWriterPermission;
/**
* @var bool
*/
public $canChangeSecurityUpdateEnabled;
/**
* @var bool
*/
public $canChangeViewersCanCopyContent;
/**
* @var bool
*/
public $canComment;
/**
* @var bool
*/
public $canCopy;
/**
* @var bool
*/
public $canDelete;
/**
* @var bool
*/
public $canDeleteChildren;
/**
* @var bool
*/
public $canDownload;
/**
* @var bool
*/
public $canEdit;
/**
* @var bool
*/
public $canListChildren;
/**
* @var bool
*/
public $canModifyContent;
/**
* @var bool
*/
public $canModifyContentRestriction;
/**
* @var bool
*/
public $canModifyLabels;
/**
* @var bool
*/
public $canMoveChildrenOutOfDrive;
/**
* @var bool
*/
public $canMoveChildrenOutOfTeamDrive;
/**
* @var bool
*/
public $canMoveChildrenWithinDrive;
/**
* @var bool
*/
public $canMoveChildrenWithinTeamDrive;
/**
* @var bool
*/
public $canMoveItemIntoTeamDrive;
/**
* @var bool
*/
public $canMoveItemOutOfDrive;
/**
* @var bool
*/
public $canMoveItemOutOfTeamDrive;
/**
* @var bool
*/
public $canMoveItemWithinDrive;
/**
* @var bool
*/
public $canMoveItemWithinTeamDrive;
/**
* @var bool
*/
public $canMoveTeamDriveItem;
/**
* @var bool
*/
public $canReadDrive;
/**
* @var bool
*/
public $canReadLabels;
/**
* @var bool
*/
public $canReadRevisions;
/**
* @var bool
*/
public $canReadTeamDrive;
/**
* @var bool
*/
public $canRemoveChildren;
/**
* @var bool
*/
public $canRemoveMyDriveParent;
/**
* @var bool
*/
public $canRename;
/**
* @var bool
*/
public $canShare;
/**
* @var bool
*/
public $canTrash;
/**
* @var bool
*/
public $canTrashChildren;
/**
* @var bool
*/
public $canUntrash;
/**
* @param bool
*/
public function setCanAcceptOwnership($canAcceptOwnership)
{
$this->canAcceptOwnership = $canAcceptOwnership;
}
/**
* @return bool
*/
public function getCanAcceptOwnership()
{
return $this->canAcceptOwnership;
}
/**
* @param bool
*/
public function setCanAddChildren($canAddChildren)
{
$this->canAddChildren = $canAddChildren;
}
/**
* @return bool
*/
public function getCanAddChildren()
{
return $this->canAddChildren;
}
/**
* @param bool
*/
public function setCanAddFolderFromAnotherDrive($canAddFolderFromAnotherDrive)
{
$this->canAddFolderFromAnotherDrive = $canAddFolderFromAnotherDrive;
}
/**
* @return bool
*/
public function getCanAddFolderFromAnotherDrive()
{
return $this->canAddFolderFromAnotherDrive;
}
/**
* @param bool
*/
public function setCanAddMyDriveParent($canAddMyDriveParent)
{
$this->canAddMyDriveParent = $canAddMyDriveParent;
}
/**
* @return bool
*/
public function getCanAddMyDriveParent()
{
return $this->canAddMyDriveParent;
}
/**
* @param bool
*/
public function setCanChangeCopyRequiresWriterPermission($canChangeCopyRequiresWriterPermission)
{
$this->canChangeCopyRequiresWriterPermission = $canChangeCopyRequiresWriterPermission;
}
/**
* @return bool
*/
public function getCanChangeCopyRequiresWriterPermission()
{
return $this->canChangeCopyRequiresWriterPermission;
}
/**
* @param bool
*/
public function setCanChangeSecurityUpdateEnabled($canChangeSecurityUpdateEnabled)
{
$this->canChangeSecurityUpdateEnabled = $canChangeSecurityUpdateEnabled;
}
/**
* @return bool
*/
public function getCanChangeSecurityUpdateEnabled()
{
return $this->canChangeSecurityUpdateEnabled;
}
/**
* @param bool
*/
public function setCanChangeViewersCanCopyContent($canChangeViewersCanCopyContent)
{
$this->canChangeViewersCanCopyContent = $canChangeViewersCanCopyContent;
}
/**
* @return bool
*/
public function getCanChangeViewersCanCopyContent()
{
return $this->canChangeViewersCanCopyContent;
}
/**
* @param bool
*/
public function setCanComment($canComment)
{
$this->canComment = $canComment;
}
/**
* @return bool
*/
public function getCanComment()
{
return $this->canComment;
}
/**
* @param bool
*/
public function setCanCopy($canCopy)
{
$this->canCopy = $canCopy;
}
/**
* @return bool
*/
public function getCanCopy()
{
return $this->canCopy;
}
/**
* @param bool
*/
public function setCanDelete($canDelete)
{
$this->canDelete = $canDelete;
}
/**
* @return bool
*/
public function getCanDelete()
{
return $this->canDelete;
}
/**
* @param bool
*/
public function setCanDeleteChildren($canDeleteChildren)
{
$this->canDeleteChildren = $canDeleteChildren;
}
/**
* @return bool
*/
public function getCanDeleteChildren()
{
return $this->canDeleteChildren;
}
/**
* @param bool
*/
public function setCanDownload($canDownload)
{
$this->canDownload = $canDownload;
}
/**
* @return bool
*/
public function getCanDownload()
{
return $this->canDownload;
}
/**
* @param bool
*/
public function setCanEdit($canEdit)
{
$this->canEdit = $canEdit;
}
/**
* @return bool
*/
public function getCanEdit()
{
return $this->canEdit;
}
/**
* @param bool
*/
public function setCanListChildren($canListChildren)
{
$this->canListChildren = $canListChildren;
}
/**
* @return bool
*/
public function getCanListChildren()
{
return $this->canListChildren;
}
/**
* @param bool
*/
public function setCanModifyContent($canModifyContent)
{
$this->canModifyContent = $canModifyContent;
}
/**
* @return bool
*/
public function getCanModifyContent()
{
return $this->canModifyContent;
}
/**
* @param bool
*/
public function setCanModifyContentRestriction($canModifyContentRestriction)
{
$this->canModifyContentRestriction = $canModifyContentRestriction;
}
/**
* @return bool
*/
public function getCanModifyContentRestriction()
{
return $this->canModifyContentRestriction;
}
/**
* @param bool
*/
public function setCanModifyLabels($canModifyLabels)
{
$this->canModifyLabels = $canModifyLabels;
}
/**
* @return bool
*/
public function getCanModifyLabels()
{
return $this->canModifyLabels;
}
/**
* @param bool
*/
public function setCanMoveChildrenOutOfDrive($canMoveChildrenOutOfDrive)
{
$this->canMoveChildrenOutOfDrive = $canMoveChildrenOutOfDrive;
}
/**
* @return bool
*/
public function getCanMoveChildrenOutOfDrive()
{
return $this->canMoveChildrenOutOfDrive;
}
/**
* @param bool
*/
public function setCanMoveChildrenOutOfTeamDrive($canMoveChildrenOutOfTeamDrive)
{
$this->canMoveChildrenOutOfTeamDrive = $canMoveChildrenOutOfTeamDrive;
}
/**
* @return bool
*/
public function getCanMoveChildrenOutOfTeamDrive()
{
return $this->canMoveChildrenOutOfTeamDrive;
}
/**
* @param bool
*/
public function setCanMoveChildrenWithinDrive($canMoveChildrenWithinDrive)
{
$this->canMoveChildrenWithinDrive = $canMoveChildrenWithinDrive;
}
/**
* @return bool
*/
public function getCanMoveChildrenWithinDrive()
{
return $this->canMoveChildrenWithinDrive;
}
/**
* @param bool
*/
public function setCanMoveChildrenWithinTeamDrive($canMoveChildrenWithinTeamDrive)
{
$this->canMoveChildrenWithinTeamDrive = $canMoveChildrenWithinTeamDrive;
}
/**
* @return bool
*/
public function getCanMoveChildrenWithinTeamDrive()
{
return $this->canMoveChildrenWithinTeamDrive;
}
/**
* @param bool
*/
public function setCanMoveItemIntoTeamDrive($canMoveItemIntoTeamDrive)
{
$this->canMoveItemIntoTeamDrive = $canMoveItemIntoTeamDrive;
}
/**
* @return bool
*/
public function getCanMoveItemIntoTeamDrive()
{
return $this->canMoveItemIntoTeamDrive;
}
/**
* @param bool
*/
public function setCanMoveItemOutOfDrive($canMoveItemOutOfDrive)
{
$this->canMoveItemOutOfDrive = $canMoveItemOutOfDrive;
}
/**
* @return bool
*/
public function getCanMoveItemOutOfDrive()
{
return $this->canMoveItemOutOfDrive;
}
/**
* @param bool
*/
public function setCanMoveItemOutOfTeamDrive($canMoveItemOutOfTeamDrive)
{
$this->canMoveItemOutOfTeamDrive = $canMoveItemOutOfTeamDrive;
}
/**
* @return bool
*/
public function getCanMoveItemOutOfTeamDrive()
{
return $this->canMoveItemOutOfTeamDrive;
}
/**
* @param bool
*/
public function setCanMoveItemWithinDrive($canMoveItemWithinDrive)
{
$this->canMoveItemWithinDrive = $canMoveItemWithinDrive;
}
/**
* @return bool
*/
public function getCanMoveItemWithinDrive()
{
return $this->canMoveItemWithinDrive;
}
/**
* @param bool
*/
public function setCanMoveItemWithinTeamDrive($canMoveItemWithinTeamDrive)
{
$this->canMoveItemWithinTeamDrive = $canMoveItemWithinTeamDrive;
}
/**
* @return bool
*/
public function getCanMoveItemWithinTeamDrive()
{
return $this->canMoveItemWithinTeamDrive;
}
/**
* @param bool
*/
public function setCanMoveTeamDriveItem($canMoveTeamDriveItem)
{
$this->canMoveTeamDriveItem = $canMoveTeamDriveItem;
}
/**
* @return bool
*/
public function getCanMoveTeamDriveItem()
{
return $this->canMoveTeamDriveItem;
}
/**
* @param bool
*/
public function setCanReadDrive($canReadDrive)
{
$this->canReadDrive = $canReadDrive;
}
/**
* @return bool
*/
public function getCanReadDrive()
{
return $this->canReadDrive;
}
/**
* @param bool
*/
public function setCanReadLabels($canReadLabels)
{
$this->canReadLabels = $canReadLabels;
}
/**
* @return bool
*/
public function getCanReadLabels()
{
return $this->canReadLabels;
}
/**
* @param bool
*/
public function setCanReadRevisions($canReadRevisions)
{
$this->canReadRevisions = $canReadRevisions;
}
/**
* @return bool
*/
public function getCanReadRevisions()
{
return $this->canReadRevisions;
}
/**
* @param bool
*/
public function setCanReadTeamDrive($canReadTeamDrive)
{
$this->canReadTeamDrive = $canReadTeamDrive;
}
/**
* @return bool
*/
public function getCanReadTeamDrive()
{
return $this->canReadTeamDrive;
}
/**
* @param bool
*/
public function setCanRemoveChildren($canRemoveChildren)
{
$this->canRemoveChildren = $canRemoveChildren;
}
/**
* @return bool
*/
public function getCanRemoveChildren()
{
return $this->canRemoveChildren;
}
/**
* @param bool
*/
public function setCanRemoveMyDriveParent($canRemoveMyDriveParent)
{
$this->canRemoveMyDriveParent = $canRemoveMyDriveParent;
}
/**
* @return bool
*/
public function getCanRemoveMyDriveParent()
{
return $this->canRemoveMyDriveParent;
}
/**
* @param bool
*/
public function setCanRename($canRename)
{
$this->canRename = $canRename;
}
/**
* @return bool
*/
public function getCanRename()
{
return $this->canRename;
}
/**
* @param bool
*/
public function setCanShare($canShare)
{
$this->canShare = $canShare;
}
/**
* @return bool
*/
public function getCanShare()
{
return $this->canShare;
}
/**
* @param bool
*/
public function setCanTrash($canTrash)
{
$this->canTrash = $canTrash;
}
/**
* @return bool
*/
public function getCanTrash()
{
return $this->canTrash;
}
/**
* @param bool
*/
public function setCanTrashChildren($canTrashChildren)
{
$this->canTrashChildren = $canTrashChildren;
}
/**
* @return bool
*/
public function getCanTrashChildren()
{
return $this->canTrashChildren;
}
/**
* @param bool
*/
public function setCanUntrash($canUntrash)
{
$this->canUntrash = $canUntrash;
}
/**
* @return bool
*/
public function getCanUntrash()
{
return $this->canUntrash;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileCapabilities::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileCapabilities');

View File

@@ -0,0 +1,58 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileContentHints extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $indexableText;
protected $thumbnailType = DriveFileContentHintsThumbnail::class;
protected $thumbnailDataType = '';
/**
* @param string
*/
public function setIndexableText($indexableText)
{
$this->indexableText = $indexableText;
}
/**
* @return string
*/
public function getIndexableText()
{
return $this->indexableText;
}
/**
* @param DriveFileContentHintsThumbnail
*/
public function setThumbnail(DriveFileContentHintsThumbnail $thumbnail)
{
$this->thumbnail = $thumbnail;
}
/**
* @return DriveFileContentHintsThumbnail
*/
public function getThumbnail()
{
return $this->thumbnail;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileContentHints::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileContentHints');

View File

@@ -0,0 +1,60 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileContentHintsThumbnail extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $image;
/**
* @var string
*/
public $mimeType;
/**
* @param string
*/
public function setImage($image)
{
$this->image = $image;
}
/**
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* @param string
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileContentHintsThumbnail::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileContentHintsThumbnail');

View File

@@ -0,0 +1,400 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileImageMediaMetadata extends \VendorDuplicator\Google\Model
{
/**
* @var float
*/
public $aperture;
/**
* @var string
*/
public $cameraMake;
/**
* @var string
*/
public $cameraModel;
/**
* @var string
*/
public $colorSpace;
/**
* @var float
*/
public $exposureBias;
/**
* @var string
*/
public $exposureMode;
/**
* @var float
*/
public $exposureTime;
/**
* @var bool
*/
public $flashUsed;
/**
* @var float
*/
public $focalLength;
/**
* @var int
*/
public $height;
/**
* @var int
*/
public $isoSpeed;
/**
* @var string
*/
public $lens;
protected $locationType = DriveFileImageMediaMetadataLocation::class;
protected $locationDataType = '';
/**
* @var float
*/
public $maxApertureValue;
/**
* @var string
*/
public $meteringMode;
/**
* @var int
*/
public $rotation;
/**
* @var string
*/
public $sensor;
/**
* @var int
*/
public $subjectDistance;
/**
* @var string
*/
public $time;
/**
* @var string
*/
public $whiteBalance;
/**
* @var int
*/
public $width;
/**
* @param float
*/
public function setAperture($aperture)
{
$this->aperture = $aperture;
}
/**
* @return float
*/
public function getAperture()
{
return $this->aperture;
}
/**
* @param string
*/
public function setCameraMake($cameraMake)
{
$this->cameraMake = $cameraMake;
}
/**
* @return string
*/
public function getCameraMake()
{
return $this->cameraMake;
}
/**
* @param string
*/
public function setCameraModel($cameraModel)
{
$this->cameraModel = $cameraModel;
}
/**
* @return string
*/
public function getCameraModel()
{
return $this->cameraModel;
}
/**
* @param string
*/
public function setColorSpace($colorSpace)
{
$this->colorSpace = $colorSpace;
}
/**
* @return string
*/
public function getColorSpace()
{
return $this->colorSpace;
}
/**
* @param float
*/
public function setExposureBias($exposureBias)
{
$this->exposureBias = $exposureBias;
}
/**
* @return float
*/
public function getExposureBias()
{
return $this->exposureBias;
}
/**
* @param string
*/
public function setExposureMode($exposureMode)
{
$this->exposureMode = $exposureMode;
}
/**
* @return string
*/
public function getExposureMode()
{
return $this->exposureMode;
}
/**
* @param float
*/
public function setExposureTime($exposureTime)
{
$this->exposureTime = $exposureTime;
}
/**
* @return float
*/
public function getExposureTime()
{
return $this->exposureTime;
}
/**
* @param bool
*/
public function setFlashUsed($flashUsed)
{
$this->flashUsed = $flashUsed;
}
/**
* @return bool
*/
public function getFlashUsed()
{
return $this->flashUsed;
}
/**
* @param float
*/
public function setFocalLength($focalLength)
{
$this->focalLength = $focalLength;
}
/**
* @return float
*/
public function getFocalLength()
{
return $this->focalLength;
}
/**
* @param int
*/
public function setHeight($height)
{
$this->height = $height;
}
/**
* @return int
*/
public function getHeight()
{
return $this->height;
}
/**
* @param int
*/
public function setIsoSpeed($isoSpeed)
{
$this->isoSpeed = $isoSpeed;
}
/**
* @return int
*/
public function getIsoSpeed()
{
return $this->isoSpeed;
}
/**
* @param string
*/
public function setLens($lens)
{
$this->lens = $lens;
}
/**
* @return string
*/
public function getLens()
{
return $this->lens;
}
/**
* @param DriveFileImageMediaMetadataLocation
*/
public function setLocation(DriveFileImageMediaMetadataLocation $location)
{
$this->location = $location;
}
/**
* @return DriveFileImageMediaMetadataLocation
*/
public function getLocation()
{
return $this->location;
}
/**
* @param float
*/
public function setMaxApertureValue($maxApertureValue)
{
$this->maxApertureValue = $maxApertureValue;
}
/**
* @return float
*/
public function getMaxApertureValue()
{
return $this->maxApertureValue;
}
/**
* @param string
*/
public function setMeteringMode($meteringMode)
{
$this->meteringMode = $meteringMode;
}
/**
* @return string
*/
public function getMeteringMode()
{
return $this->meteringMode;
}
/**
* @param int
*/
public function setRotation($rotation)
{
$this->rotation = $rotation;
}
/**
* @return int
*/
public function getRotation()
{
return $this->rotation;
}
/**
* @param string
*/
public function setSensor($sensor)
{
$this->sensor = $sensor;
}
/**
* @return string
*/
public function getSensor()
{
return $this->sensor;
}
/**
* @param int
*/
public function setSubjectDistance($subjectDistance)
{
$this->subjectDistance = $subjectDistance;
}
/**
* @return int
*/
public function getSubjectDistance()
{
return $this->subjectDistance;
}
/**
* @param string
*/
public function setTime($time)
{
$this->time = $time;
}
/**
* @return string
*/
public function getTime()
{
return $this->time;
}
/**
* @param string
*/
public function setWhiteBalance($whiteBalance)
{
$this->whiteBalance = $whiteBalance;
}
/**
* @return string
*/
public function getWhiteBalance()
{
return $this->whiteBalance;
}
/**
* @param int
*/
public function setWidth($width)
{
$this->width = $width;
}
/**
* @return int
*/
public function getWidth()
{
return $this->width;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileImageMediaMetadata::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileImageMediaMetadata');

View File

@@ -0,0 +1,51 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileImageMediaMetadataLocation extends \VendorDuplicator\Google\Model
{
public $altitude;
public $latitude;
public $longitude;
public function setAltitude($altitude)
{
$this->altitude = $altitude;
}
public function getAltitude()
{
return $this->altitude;
}
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
public function getLatitude()
{
return $this->latitude;
}
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
public function getLongitude()
{
return $this->longitude;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileImageMediaMetadataLocation::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileImageMediaMetadataLocation');

View File

@@ -0,0 +1,41 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileLabelInfo extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'labels';
protected $labelsType = Label::class;
protected $labelsDataType = 'array';
/**
* @param Label[]
*/
public function setLabels($labels)
{
$this->labels = $labels;
}
/**
* @return Label[]
*/
public function getLabels()
{
return $this->labels;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileLabelInfo::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileLabelInfo');

View File

@@ -0,0 +1,60 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileLinkShareMetadata extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $securityUpdateEligible;
/**
* @var bool
*/
public $securityUpdateEnabled;
/**
* @param bool
*/
public function setSecurityUpdateEligible($securityUpdateEligible)
{
$this->securityUpdateEligible = $securityUpdateEligible;
}
/**
* @return bool
*/
public function getSecurityUpdateEligible()
{
return $this->securityUpdateEligible;
}
/**
* @param bool
*/
public function setSecurityUpdateEnabled($securityUpdateEnabled)
{
$this->securityUpdateEnabled = $securityUpdateEnabled;
}
/**
* @return bool
*/
public function getSecurityUpdateEnabled()
{
return $this->securityUpdateEnabled;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileLinkShareMetadata::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileLinkShareMetadata');

View File

@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileShortcutDetails extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $targetId;
/**
* @var string
*/
public $targetMimeType;
/**
* @var string
*/
public $targetResourceKey;
/**
* @param string
*/
public function setTargetId($targetId)
{
$this->targetId = $targetId;
}
/**
* @return string
*/
public function getTargetId()
{
return $this->targetId;
}
/**
* @param string
*/
public function setTargetMimeType($targetMimeType)
{
$this->targetMimeType = $targetMimeType;
}
/**
* @return string
*/
public function getTargetMimeType()
{
return $this->targetMimeType;
}
/**
* @param string
*/
public function setTargetResourceKey($targetResourceKey)
{
$this->targetResourceKey = $targetResourceKey;
}
/**
* @return string
*/
public function getTargetResourceKey()
{
return $this->targetResourceKey;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileShortcutDetails::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileShortcutDetails');

View File

@@ -0,0 +1,78 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveFileVideoMediaMetadata extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $durationMillis;
/**
* @var int
*/
public $height;
/**
* @var int
*/
public $width;
/**
* @param string
*/
public function setDurationMillis($durationMillis)
{
$this->durationMillis = $durationMillis;
}
/**
* @return string
*/
public function getDurationMillis()
{
return $this->durationMillis;
}
/**
* @param int
*/
public function setHeight($height)
{
$this->height = $height;
}
/**
* @return int
*/
public function getHeight()
{
return $this->height;
}
/**
* @param int
*/
public function setWidth($width)
{
$this->width = $width;
}
/**
* @return int
*/
public function getWidth()
{
return $this->width;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveFileVideoMediaMetadata::class, 'VendorDuplicator\\Google_Service_Drive_DriveFileVideoMediaMetadata');

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'drives';
protected $drivesType = Drive::class;
protected $drivesDataType = 'array';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $nextPageToken;
/**
* @param Drive[]
*/
public function setDrives($drives)
{
$this->drives = $drives;
}
/**
* @return Drive[]
*/
public function getDrives()
{
return $this->drives;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveList::class, 'VendorDuplicator\\Google_Service_Drive_DriveList');

View File

@@ -0,0 +1,114 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class DriveRestrictions extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $adminManagedRestrictions;
/**
* @var bool
*/
public $copyRequiresWriterPermission;
/**
* @var bool
*/
public $domainUsersOnly;
/**
* @var bool
*/
public $driveMembersOnly;
/**
* @var bool
*/
public $sharingFoldersRequiresOrganizerPermission;
/**
* @param bool
*/
public function setAdminManagedRestrictions($adminManagedRestrictions)
{
$this->adminManagedRestrictions = $adminManagedRestrictions;
}
/**
* @return bool
*/
public function getAdminManagedRestrictions()
{
return $this->adminManagedRestrictions;
}
/**
* @param bool
*/
public function setCopyRequiresWriterPermission($copyRequiresWriterPermission)
{
$this->copyRequiresWriterPermission = $copyRequiresWriterPermission;
}
/**
* @return bool
*/
public function getCopyRequiresWriterPermission()
{
return $this->copyRequiresWriterPermission;
}
/**
* @param bool
*/
public function setDomainUsersOnly($domainUsersOnly)
{
$this->domainUsersOnly = $domainUsersOnly;
}
/**
* @return bool
*/
public function getDomainUsersOnly()
{
return $this->domainUsersOnly;
}
/**
* @param bool
*/
public function setDriveMembersOnly($driveMembersOnly)
{
$this->driveMembersOnly = $driveMembersOnly;
}
/**
* @return bool
*/
public function getDriveMembersOnly()
{
return $this->driveMembersOnly;
}
/**
* @param bool
*/
public function setSharingFoldersRequiresOrganizerPermission($sharingFoldersRequiresOrganizerPermission)
{
$this->sharingFoldersRequiresOrganizerPermission = $sharingFoldersRequiresOrganizerPermission;
}
/**
* @return bool
*/
public function getSharingFoldersRequiresOrganizerPermission()
{
return $this->sharingFoldersRequiresOrganizerPermission;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(DriveRestrictions::class, 'VendorDuplicator\\Google_Service_Drive_DriveRestrictions');

View File

@@ -0,0 +1,95 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class FileList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'files';
protected $filesType = DriveFile::class;
protected $filesDataType = 'array';
/**
* @var bool
*/
public $incompleteSearch;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $nextPageToken;
/**
* @param DriveFile[]
*/
public function setFiles($files)
{
$this->files = $files;
}
/**
* @return DriveFile[]
*/
public function getFiles()
{
return $this->files;
}
/**
* @param bool
*/
public function setIncompleteSearch($incompleteSearch)
{
$this->incompleteSearch = $incompleteSearch;
}
/**
* @return bool
*/
public function getIncompleteSearch()
{
return $this->incompleteSearch;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(FileList::class, 'VendorDuplicator\\Google_Service_Drive_FileList');

View File

@@ -0,0 +1,79 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class GeneratedIds extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'ids';
/**
* @var string[]
*/
public $ids;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $space;
/**
* @param string[]
*/
public function setIds($ids)
{
$this->ids = $ids;
}
/**
* @return string[]
*/
public function getIds()
{
return $this->ids;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setSpace($space)
{
$this->space = $space;
}
/**
* @return string
*/
public function getSpace()
{
return $this->space;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(GeneratedIds::class, 'VendorDuplicator\\Google_Service_Drive_GeneratedIds');

View File

@@ -0,0 +1,94 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Label extends \VendorDuplicator\Google\Model
{
protected $fieldsType = LabelField::class;
protected $fieldsDataType = 'map';
/**
* @var string
*/
public $id;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $revisionId;
/**
* @param LabelField[]
*/
public function setFields($fields)
{
$this->fields = $fields;
}
/**
* @return LabelField[]
*/
public function getFields()
{
return $this->fields;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setRevisionId($revisionId)
{
$this->revisionId = $revisionId;
}
/**
* @return string
*/
public function getRevisionId()
{
return $this->revisionId;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Label::class, 'VendorDuplicator\\Google_Service_Drive_Label');

View File

@@ -0,0 +1,167 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class LabelField extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'user';
/**
* @var string[]
*/
public $dateString;
/**
* @var string
*/
public $id;
/**
* @var string[]
*/
public $integer;
/**
* @var string
*/
public $kind;
/**
* @var string[]
*/
public $selection;
/**
* @var string[]
*/
public $text;
protected $userType = User::class;
protected $userDataType = 'array';
/**
* @var string
*/
public $valueType;
/**
* @param string[]
*/
public function setDateString($dateString)
{
$this->dateString = $dateString;
}
/**
* @return string[]
*/
public function getDateString()
{
return $this->dateString;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string[]
*/
public function setInteger($integer)
{
$this->integer = $integer;
}
/**
* @return string[]
*/
public function getInteger()
{
return $this->integer;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string[]
*/
public function setSelection($selection)
{
$this->selection = $selection;
}
/**
* @return string[]
*/
public function getSelection()
{
return $this->selection;
}
/**
* @param string[]
*/
public function setText($text)
{
$this->text = $text;
}
/**
* @return string[]
*/
public function getText()
{
return $this->text;
}
/**
* @param User[]
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* @return User[]
*/
public function getUser()
{
return $this->user;
}
/**
* @param string
*/
public function setValueType($valueType)
{
$this->valueType = $valueType;
}
/**
* @return string
*/
public function getValueType()
{
return $this->valueType;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(LabelField::class, 'VendorDuplicator\\Google_Service_Drive_LabelField');

View File

@@ -0,0 +1,169 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class LabelFieldModification extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'setUserValues';
/**
* @var string
*/
public $fieldId;
/**
* @var string
*/
public $kind;
/**
* @var string[]
*/
public $setDateValues;
/**
* @var string[]
*/
public $setIntegerValues;
/**
* @var string[]
*/
public $setSelectionValues;
/**
* @var string[]
*/
public $setTextValues;
/**
* @var string[]
*/
public $setUserValues;
/**
* @var bool
*/
public $unsetValues;
/**
* @param string
*/
public function setFieldId($fieldId)
{
$this->fieldId = $fieldId;
}
/**
* @return string
*/
public function getFieldId()
{
return $this->fieldId;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string[]
*/
public function setSetDateValues($setDateValues)
{
$this->setDateValues = $setDateValues;
}
/**
* @return string[]
*/
public function getSetDateValues()
{
return $this->setDateValues;
}
/**
* @param string[]
*/
public function setSetIntegerValues($setIntegerValues)
{
$this->setIntegerValues = $setIntegerValues;
}
/**
* @return string[]
*/
public function getSetIntegerValues()
{
return $this->setIntegerValues;
}
/**
* @param string[]
*/
public function setSetSelectionValues($setSelectionValues)
{
$this->setSelectionValues = $setSelectionValues;
}
/**
* @return string[]
*/
public function getSetSelectionValues()
{
return $this->setSelectionValues;
}
/**
* @param string[]
*/
public function setSetTextValues($setTextValues)
{
$this->setTextValues = $setTextValues;
}
/**
* @return string[]
*/
public function getSetTextValues()
{
return $this->setTextValues;
}
/**
* @param string[]
*/
public function setSetUserValues($setUserValues)
{
$this->setUserValues = $setUserValues;
}
/**
* @return string[]
*/
public function getSetUserValues()
{
return $this->setUserValues;
}
/**
* @param bool
*/
public function setUnsetValues($unsetValues)
{
$this->unsetValues = $unsetValues;
}
/**
* @return bool
*/
public function getUnsetValues()
{
return $this->unsetValues;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(LabelFieldModification::class, 'VendorDuplicator\\Google_Service_Drive_LabelFieldModification');

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class LabelList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'labels';
/**
* @var string
*/
public $kind;
protected $labelsType = Label::class;
protected $labelsDataType = 'array';
/**
* @var string
*/
public $nextPageToken;
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param Label[]
*/
public function setLabels($labels)
{
$this->labels = $labels;
}
/**
* @return Label[]
*/
public function getLabels()
{
return $this->labels;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(LabelList::class, 'VendorDuplicator\\Google_Service_Drive_LabelList');

View File

@@ -0,0 +1,95 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class LabelModification extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'fieldModifications';
protected $fieldModificationsType = LabelFieldModification::class;
protected $fieldModificationsDataType = 'array';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $labelId;
/**
* @var bool
*/
public $removeLabel;
/**
* @param LabelFieldModification[]
*/
public function setFieldModifications($fieldModifications)
{
$this->fieldModifications = $fieldModifications;
}
/**
* @return LabelFieldModification[]
*/
public function getFieldModifications()
{
return $this->fieldModifications;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setLabelId($labelId)
{
$this->labelId = $labelId;
}
/**
* @return string
*/
public function getLabelId()
{
return $this->labelId;
}
/**
* @param bool
*/
public function setRemoveLabel($removeLabel)
{
$this->removeLabel = $removeLabel;
}
/**
* @return bool
*/
public function getRemoveLabel()
{
return $this->removeLabel;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(LabelModification::class, 'VendorDuplicator\\Google_Service_Drive_LabelModification');

View File

@@ -0,0 +1,59 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class ModifyLabelsRequest extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'labelModifications';
/**
* @var string
*/
public $kind;
protected $labelModificationsType = LabelModification::class;
protected $labelModificationsDataType = 'array';
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param LabelModification[]
*/
public function setLabelModifications($labelModifications)
{
$this->labelModifications = $labelModifications;
}
/**
* @return LabelModification[]
*/
public function getLabelModifications()
{
return $this->labelModifications;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(ModifyLabelsRequest::class, 'VendorDuplicator\\Google_Service_Drive_ModifyLabelsRequest');

View File

@@ -0,0 +1,59 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class ModifyLabelsResponse extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'modifiedLabels';
/**
* @var string
*/
public $kind;
protected $modifiedLabelsType = Label::class;
protected $modifiedLabelsDataType = 'array';
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param Label[]
*/
public function setModifiedLabels($modifiedLabels)
{
$this->modifiedLabels = $modifiedLabels;
}
/**
* @return Label[]
*/
public function getModifiedLabels()
{
return $this->modifiedLabels;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(ModifyLabelsResponse::class, 'VendorDuplicator\\Google_Service_Drive_ModifyLabelsResponse');

View File

@@ -0,0 +1,291 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Permission extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'teamDrivePermissionDetails';
/**
* @var bool
*/
public $allowFileDiscovery;
/**
* @var bool
*/
public $deleted;
/**
* @var string
*/
public $displayName;
/**
* @var string
*/
public $domain;
/**
* @var string
*/
public $emailAddress;
/**
* @var string
*/
public $expirationTime;
/**
* @var string
*/
public $id;
/**
* @var string
*/
public $kind;
/**
* @var bool
*/
public $pendingOwner;
protected $permissionDetailsType = PermissionPermissionDetails::class;
protected $permissionDetailsDataType = 'array';
/**
* @var string
*/
public $photoLink;
/**
* @var string
*/
public $role;
protected $teamDrivePermissionDetailsType = PermissionTeamDrivePermissionDetails::class;
protected $teamDrivePermissionDetailsDataType = 'array';
/**
* @var string
*/
public $type;
/**
* @var string
*/
public $view;
/**
* @param bool
*/
public function setAllowFileDiscovery($allowFileDiscovery)
{
$this->allowFileDiscovery = $allowFileDiscovery;
}
/**
* @return bool
*/
public function getAllowFileDiscovery()
{
return $this->allowFileDiscovery;
}
/**
* @param bool
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
/**
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* @param string
*/
public function setDisplayName($displayName)
{
$this->displayName = $displayName;
}
/**
* @return string
*/
public function getDisplayName()
{
return $this->displayName;
}
/**
* @param string
*/
public function setDomain($domain)
{
$this->domain = $domain;
}
/**
* @return string
*/
public function getDomain()
{
return $this->domain;
}
/**
* @param string
*/
public function setEmailAddress($emailAddress)
{
$this->emailAddress = $emailAddress;
}
/**
* @return string
*/
public function getEmailAddress()
{
return $this->emailAddress;
}
/**
* @param string
*/
public function setExpirationTime($expirationTime)
{
$this->expirationTime = $expirationTime;
}
/**
* @return string
*/
public function getExpirationTime()
{
return $this->expirationTime;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param bool
*/
public function setPendingOwner($pendingOwner)
{
$this->pendingOwner = $pendingOwner;
}
/**
* @return bool
*/
public function getPendingOwner()
{
return $this->pendingOwner;
}
/**
* @param PermissionPermissionDetails[]
*/
public function setPermissionDetails($permissionDetails)
{
$this->permissionDetails = $permissionDetails;
}
/**
* @return PermissionPermissionDetails[]
*/
public function getPermissionDetails()
{
return $this->permissionDetails;
}
/**
* @param string
*/
public function setPhotoLink($photoLink)
{
$this->photoLink = $photoLink;
}
/**
* @return string
*/
public function getPhotoLink()
{
return $this->photoLink;
}
/**
* @param string
*/
public function setRole($role)
{
$this->role = $role;
}
/**
* @return string
*/
public function getRole()
{
return $this->role;
}
/**
* @param PermissionTeamDrivePermissionDetails[]
*/
public function setTeamDrivePermissionDetails($teamDrivePermissionDetails)
{
$this->teamDrivePermissionDetails = $teamDrivePermissionDetails;
}
/**
* @return PermissionTeamDrivePermissionDetails[]
*/
public function getTeamDrivePermissionDetails()
{
return $this->teamDrivePermissionDetails;
}
/**
* @param string
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string
*/
public function setView($view)
{
$this->view = $view;
}
/**
* @return string
*/
public function getView()
{
return $this->view;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Permission::class, 'VendorDuplicator\\Google_Service_Drive_Permission');

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class PermissionList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'permissions';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $nextPageToken;
protected $permissionsType = Permission::class;
protected $permissionsDataType = 'array';
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param Permission[]
*/
public function setPermissions($permissions)
{
$this->permissions = $permissions;
}
/**
* @return Permission[]
*/
public function getPermissions()
{
return $this->permissions;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(PermissionList::class, 'VendorDuplicator\\Google_Service_Drive_PermissionList');

View File

@@ -0,0 +1,96 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class PermissionPermissionDetails extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $inherited;
/**
* @var string
*/
public $inheritedFrom;
/**
* @var string
*/
public $permissionType;
/**
* @var string
*/
public $role;
/**
* @param bool
*/
public function setInherited($inherited)
{
$this->inherited = $inherited;
}
/**
* @return bool
*/
public function getInherited()
{
return $this->inherited;
}
/**
* @param string
*/
public function setInheritedFrom($inheritedFrom)
{
$this->inheritedFrom = $inheritedFrom;
}
/**
* @return string
*/
public function getInheritedFrom()
{
return $this->inheritedFrom;
}
/**
* @param string
*/
public function setPermissionType($permissionType)
{
$this->permissionType = $permissionType;
}
/**
* @return string
*/
public function getPermissionType()
{
return $this->permissionType;
}
/**
* @param string
*/
public function setRole($role)
{
$this->role = $role;
}
/**
* @return string
*/
public function getRole()
{
return $this->role;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(PermissionPermissionDetails::class, 'VendorDuplicator\\Google_Service_Drive_PermissionPermissionDetails');

View File

@@ -0,0 +1,96 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class PermissionTeamDrivePermissionDetails extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $inherited;
/**
* @var string
*/
public $inheritedFrom;
/**
* @var string
*/
public $role;
/**
* @var string
*/
public $teamDrivePermissionType;
/**
* @param bool
*/
public function setInherited($inherited)
{
$this->inherited = $inherited;
}
/**
* @return bool
*/
public function getInherited()
{
return $this->inherited;
}
/**
* @param string
*/
public function setInheritedFrom($inheritedFrom)
{
$this->inheritedFrom = $inheritedFrom;
}
/**
* @return string
*/
public function getInheritedFrom()
{
return $this->inheritedFrom;
}
/**
* @param string
*/
public function setRole($role)
{
$this->role = $role;
}
/**
* @return string
*/
public function getRole()
{
return $this->role;
}
/**
* @param string
*/
public function setTeamDrivePermissionType($teamDrivePermissionType)
{
$this->teamDrivePermissionType = $teamDrivePermissionType;
}
/**
* @return string
*/
public function getTeamDrivePermissionType()
{
return $this->teamDrivePermissionType;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(PermissionTeamDrivePermissionDetails::class, 'VendorDuplicator\\Google_Service_Drive_PermissionTeamDrivePermissionDetails');

View File

@@ -0,0 +1,184 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Reply extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $action;
protected $authorType = User::class;
protected $authorDataType = '';
/**
* @var string
*/
public $content;
/**
* @var string
*/
public $createdTime;
/**
* @var bool
*/
public $deleted;
/**
* @var string
*/
public $htmlContent;
/**
* @var string
*/
public $id;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $modifiedTime;
/**
* @param string
*/
public function setAction($action)
{
$this->action = $action;
}
/**
* @return string
*/
public function getAction()
{
return $this->action;
}
/**
* @param User
*/
public function setAuthor(User $author)
{
$this->author = $author;
}
/**
* @return User
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param string
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* @param string
*/
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
/**
* @return string
*/
public function getCreatedTime()
{
return $this->createdTime;
}
/**
* @param bool
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
/**
* @return bool
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* @param string
*/
public function setHtmlContent($htmlContent)
{
$this->htmlContent = $htmlContent;
}
/**
* @return string
*/
public function getHtmlContent()
{
return $this->htmlContent;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
/**
* @return string
*/
public function getModifiedTime()
{
return $this->modifiedTime;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Reply::class, 'VendorDuplicator\\Google_Service_Drive_Reply');

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class ReplyList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'replies';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $nextPageToken;
protected $repliesType = Reply::class;
protected $repliesDataType = 'array';
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param Reply[]
*/
public function setReplies($replies)
{
$this->replies = $replies;
}
/**
* @return Reply[]
*/
public function getReplies()
{
return $this->replies;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(ReplyList::class, 'VendorDuplicator\\Google_Service_Drive_ReplyList');

View File

@@ -0,0 +1,46 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\About as AboutModel;
/**
* The "about" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $about = $driveService->about;
* </code>
*/
class About extends \VendorDuplicator\Google\Service\Resource
{
/**
* Gets information about the user, the user's Drive, and system capabilities.
* (about.get)
*
* @param array $optParams Optional parameters.
* @return AboutModel
*/
public function get($optParams = [])
{
$params = [];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], AboutModel::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(About::class, 'VendorDuplicator\\Google_Service_Drive_Resource_About');

View File

@@ -0,0 +1,147 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\ChangeList;
use VendorDuplicator\Google\Service\Drive\Channel;
use VendorDuplicator\Google\Service\Drive\StartPageToken;
/**
* The "changes" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $changes = $driveService->changes;
* </code>
*/
class Changes extends \VendorDuplicator\Google\Service\Resource
{
/**
* Gets the starting pageToken for listing future changes.
* (changes.getStartPageToken)
*
* @param array $optParams Optional parameters.
*
* @opt_param string driveId The ID of the shared drive for which the starting
* pageToken for listing future changes from that shared drive is returned.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param string teamDriveId Deprecated use driveId instead.
* @return StartPageToken
*/
public function getStartPageToken($optParams = [])
{
$params = [];
$params = \array_merge($params, $optParams);
return $this->call('getStartPageToken', [$params], StartPageToken::class);
}
/**
* Lists the changes for a user or shared drive. (changes.listChanges)
*
* @param string $pageToken The token for continuing a previous list request on
* the next page. This should be set to the value of 'nextPageToken' from the
* previous response or to the response from the getStartPageToken method.
* @param array $optParams Optional parameters.
*
* @opt_param string driveId The shared drive from which changes are returned.
* If specified the change IDs will be reflective of the shared drive; use the
* combined drive ID and change ID as an identifier.
* @opt_param bool includeCorpusRemovals Whether changes should include the file
* resource if the file is still accessible by the user at the time of the
* request, even when a file was removed from the list of changes and there will
* be no further change entries for this file.
* @opt_param bool includeItemsFromAllDrives Whether both My Drive and shared
* drive items should be included in results.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool includeRemoved Whether to include changes indicating that
* items have been removed from the list of changes, for example by deletion or
* loss of access.
* @opt_param bool includeTeamDriveItems Deprecated use
* includeItemsFromAllDrives instead.
* @opt_param int pageSize The maximum number of changes to return per page.
* @opt_param bool restrictToMyDrive Whether to restrict the results to changes
* inside the My Drive hierarchy. This omits changes to files such as those in
* the Application Data folder or shared files which have not been added to My
* Drive.
* @opt_param string spaces A comma-separated list of spaces to query within the
* corpora. Supported values are 'drive' and 'appDataFolder'.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param string teamDriveId Deprecated use driveId instead.
* @return ChangeList
*/
public function listChanges($pageToken, $optParams = [])
{
$params = ['pageToken' => $pageToken];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], ChangeList::class);
}
/**
* Subscribes to changes for a user. To use this method, you must include the
* pageToken query parameter. (changes.watch)
*
* @param string $pageToken The token for continuing a previous list request on
* the next page. This should be set to the value of 'nextPageToken' from the
* previous response or to the response from the getStartPageToken method.
* @param Channel $postBody
* @param array $optParams Optional parameters.
*
* @opt_param string driveId The shared drive from which changes are returned.
* If specified the change IDs will be reflective of the shared drive; use the
* combined drive ID and change ID as an identifier.
* @opt_param bool includeCorpusRemovals Whether changes should include the file
* resource if the file is still accessible by the user at the time of the
* request, even when a file was removed from the list of changes and there will
* be no further change entries for this file.
* @opt_param bool includeItemsFromAllDrives Whether both My Drive and shared
* drive items should be included in results.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool includeRemoved Whether to include changes indicating that
* items have been removed from the list of changes, for example by deletion or
* loss of access.
* @opt_param bool includeTeamDriveItems Deprecated use
* includeItemsFromAllDrives instead.
* @opt_param int pageSize The maximum number of changes to return per page.
* @opt_param bool restrictToMyDrive Whether to restrict the results to changes
* inside the My Drive hierarchy. This omits changes to files such as those in
* the Application Data folder or shared files which have not been added to My
* Drive.
* @opt_param string spaces A comma-separated list of spaces to query within the
* corpora. Supported values are 'drive' and 'appDataFolder'.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param string teamDriveId Deprecated use driveId instead.
* @return Channel
*/
public function watch($pageToken, Channel $postBody, $optParams = [])
{
$params = ['pageToken' => $pageToken, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('watch', [$params], Channel::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Changes::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Changes');

View File

@@ -0,0 +1,45 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\Channel;
/**
* The "channels" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $channels = $driveService->channels;
* </code>
*/
class Channels extends \VendorDuplicator\Google\Service\Resource
{
/**
* Stop watching resources through this channel (channels.stop)
*
* @param Channel $postBody
* @param array $optParams Optional parameters.
*/
public function stop(Channel $postBody, $optParams = [])
{
$params = ['postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('stop', [$params]);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Channels::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Channels');

View File

@@ -0,0 +1,115 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\Comment;
use VendorDuplicator\Google\Service\Drive\CommentList;
/**
* The "comments" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $comments = $driveService->comments;
* </code>
*/
class Comments extends \VendorDuplicator\Google\Service\Resource
{
/**
* Creates a comment on a file. (comments.create)
*
* @param string $fileId The ID of the file.
* @param Comment $postBody
* @param array $optParams Optional parameters.
* @return Comment
*/
public function create($fileId, Comment $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('create', [$params], Comment::class);
}
/**
* Deletes a comment. (comments.delete)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param array $optParams Optional parameters.
*/
public function delete($fileId, $commentId, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId];
$params = \array_merge($params, $optParams);
return $this->call('delete', [$params]);
}
/**
* Gets a comment by ID. (comments.get)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to return deleted comments. Deleted
* comments will not include their original content.
* @return Comment
*/
public function get($fileId, $commentId, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], Comment::class);
}
/**
* Lists a file's comments. (comments.listComments)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to include deleted comments. Deleted
* comments will not include their original content.
* @opt_param int pageSize The maximum number of comments to return per page.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @opt_param string startModifiedTime The minimum value of 'modifiedTime' for
* the result comments (RFC 3339 date-time).
* @return CommentList
*/
public function listComments($fileId, $optParams = [])
{
$params = ['fileId' => $fileId];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], CommentList::class);
}
/**
* Updates a comment with patch semantics. (comments.update)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param Comment $postBody
* @param array $optParams Optional parameters.
* @return Comment
*/
public function update($fileId, $commentId, Comment $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('update', [$params], Comment::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Comments::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Comments');

View File

@@ -0,0 +1,152 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\Drive;
use VendorDuplicator\Google\Service\Drive\DriveList;
/**
* The "drives" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $drives = $driveService->drives;
* </code>
*/
class Drives extends \VendorDuplicator\Google\Service\Resource
{
/**
* Creates a shared drive. (drives.create)
*
* @param string $requestId An ID, such as a random UUID, which uniquely
* identifies this user's request for idempotent creation of a shared drive. A
* repeated request by the same user and with the same request ID will avoid
* creating duplicates by attempting to create the same shared drive. If the
* shared drive already exists a 409 error will be returned.
* @param Drive $postBody
* @param array $optParams Optional parameters.
* @return Drive
*/
public function create($requestId, Drive $postBody, $optParams = [])
{
$params = ['requestId' => $requestId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('create', [$params], Drive::class);
}
/**
* Permanently deletes a shared drive for which the user is an organizer. The
* shared drive cannot contain any untrashed items. (drives.delete)
*
* @param string $driveId The ID of the shared drive.
* @param array $optParams Optional parameters.
*
* @opt_param bool allowItemDeletion Whether any items inside the shared drive
* should also be deleted. This option is only supported when
* useDomainAdminAccess is also set to true.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the shared drive belongs.
*/
public function delete($driveId, $optParams = [])
{
$params = ['driveId' => $driveId];
$params = \array_merge($params, $optParams);
return $this->call('delete', [$params]);
}
/**
* Gets a shared drive's metadata by ID. (drives.get)
*
* @param string $driveId The ID of the shared drive.
* @param array $optParams Optional parameters.
*
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the shared drive belongs.
* @return Drive
*/
public function get($driveId, $optParams = [])
{
$params = ['driveId' => $driveId];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], Drive::class);
}
/**
* Hides a shared drive from the default view. (drives.hide)
*
* @param string $driveId The ID of the shared drive.
* @param array $optParams Optional parameters.
* @return Drive
*/
public function hide($driveId, $optParams = [])
{
$params = ['driveId' => $driveId];
$params = \array_merge($params, $optParams);
return $this->call('hide', [$params], Drive::class);
}
/**
* Lists the user's shared drives. (drives.listDrives)
*
* @param array $optParams Optional parameters.
*
* @opt_param int pageSize Maximum number of shared drives to return per page.
* @opt_param string pageToken Page token for shared drives.
* @opt_param string q Query string for searching shared drives.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then all shared drives of the domain in which
* the requester is an administrator are returned.
* @return DriveList
*/
public function listDrives($optParams = [])
{
$params = [];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], DriveList::class);
}
/**
* Restores a shared drive to the default view. (drives.unhide)
*
* @param string $driveId The ID of the shared drive.
* @param array $optParams Optional parameters.
* @return Drive
*/
public function unhide($driveId, $optParams = [])
{
$params = ['driveId' => $driveId];
$params = \array_merge($params, $optParams);
return $this->call('unhide', [$params], Drive::class);
}
/**
* Updates the metadata for a shared drive. (drives.update)
*
* @param string $driveId The ID of the shared drive.
* @param Drive $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator. If set to true, then the requester is granted access if
* they're an administrator of the domain to which the shared drive belongs.
* @return Drive
*/
public function update($driveId, Drive $postBody, $optParams = [])
{
$params = ['driveId' => $driveId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('update', [$params], Drive::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Drives::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Drives');

View File

@@ -0,0 +1,360 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\Channel;
use VendorDuplicator\Google\Service\Drive\DriveFile;
use VendorDuplicator\Google\Service\Drive\FileList;
use VendorDuplicator\Google\Service\Drive\GeneratedIds;
use VendorDuplicator\Google\Service\Drive\LabelList;
use VendorDuplicator\Google\Service\Drive\ModifyLabelsRequest;
use VendorDuplicator\Google\Service\Drive\ModifyLabelsResponse;
/**
* The "files" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $files = $driveService->files;
* </code>
*/
class Files extends \VendorDuplicator\Google\Service\Resource
{
/**
* Creates a copy of a file and applies any requested updates with patch
* semantics. Folders cannot be copied. (files.copy)
*
* @param string $fileId The ID of the file.
* @param DriveFile $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool enforceSingleParent Deprecated. Copying files into multiple
* folders is no longer supported. Use shortcuts instead.
* @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
* default visibility settings for the created file. Domain administrators can
* choose to make all uploaded files visible to the domain by default; this
* parameter bypasses that behavior for the request. Permissions are still
* inherited from parent folders.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
* the new head revision. This is only applicable to files with binary content
* in Google Drive. Only 200 revisions for the file can be kept forever. If the
* limit is reached, try deleting pinned revisions.
* @opt_param string ocrLanguage A language hint for OCR processing during image
* import (ISO 639-1 code).
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @return DriveFile
*/
public function copy($fileId, DriveFile $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('copy', [$params], DriveFile::class);
}
/**
* Creates a file. (files.create)
*
* @param DriveFile $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool enforceSingleParent Deprecated. Creating files in multiple
* folders is no longer supported.
* @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
* default visibility settings for the created file. Domain administrators can
* choose to make all uploaded files visible to the domain by default; this
* parameter bypasses that behavior for the request. Permissions are still
* inherited from parent folders.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
* the new head revision. This is only applicable to files with binary content
* in Google Drive. Only 200 revisions for the file can be kept forever. If the
* limit is reached, try deleting pinned revisions.
* @opt_param string ocrLanguage A language hint for OCR processing during image
* import (ISO 639-1 code).
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param bool useContentAsIndexableText Whether to use the uploaded content
* as indexable text.
* @return DriveFile
*/
public function create(DriveFile $postBody, $optParams = [])
{
$params = ['postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('create', [$params], DriveFile::class);
}
/**
* Permanently deletes a file owned by the user without moving it to the trash.
* If the file belongs to a shared drive the user must be an organizer on the
* parent. If the target is a folder, all descendants owned by the user are also
* deleted. (files.delete)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param bool enforceSingleParent Deprecated. If an item is not in a shared
* drive and its last parent is deleted but the item itself is not, the item
* will be placed under its owner's root.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
*/
public function delete($fileId, $optParams = [])
{
$params = ['fileId' => $fileId];
$params = \array_merge($params, $optParams);
return $this->call('delete', [$params]);
}
/**
* Permanently deletes all trashed files of a user or shared drive.
* (files.emptyTrash)
*
* @param array $optParams Optional parameters.
*
* @opt_param string driveId If set, empties the trash of the provided shared
* drive.
* @opt_param bool enforceSingleParent Deprecated. If an item is not in a shared
* drive and its last parent is deleted but the item itself is not, the item
* will be placed under its owner's root.
*/
public function emptyTrash($optParams = [])
{
$params = [];
$params = \array_merge($params, $optParams);
return $this->call('emptyTrash', [$params]);
}
/**
* Exports a Google Workspace document to the requested MIME type and returns
* exported byte content. Note that the exported content is limited to 10MB.
* (files.export)
*
* @param string $fileId The ID of the file.
* @param string $mimeType The MIME type of the format requested for this
* export.
* @param array $optParams Optional parameters.
*/
public function export($fileId, $mimeType, $optParams = [])
{
$params = ['fileId' => $fileId, 'mimeType' => $mimeType];
$params = \array_merge($params, $optParams);
return $this->call('export', [$params]);
}
/**
* Generates a set of file IDs which can be provided in create or copy requests.
* (files.generateIds)
*
* @param array $optParams Optional parameters.
*
* @opt_param int count The number of IDs to return.
* @opt_param string space The space in which the IDs can be used to create new
* files. Supported values are 'drive' and 'appDataFolder'. (Default: 'drive')
* @opt_param string type The type of items which the IDs can be used for.
* Supported values are 'files' and 'shortcuts'. Note that 'shortcuts' are only
* supported in the drive 'space'. (Default: 'files')
* @return GeneratedIds
*/
public function generateIds($optParams = [])
{
$params = [];
$params = \array_merge($params, $optParams);
return $this->call('generateIds', [$params], GeneratedIds::class);
}
/**
* Gets a file's metadata or content by ID. (files.get)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
* of downloading known malware or other abusive files. This is only applicable
* when alt=media.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @return DriveFile
*/
public function get($fileId, $optParams = [])
{
$params = ['fileId' => $fileId];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], DriveFile::class);
}
/**
* Lists or searches files. (files.listFiles)
*
* @param array $optParams Optional parameters.
*
* @opt_param string corpora Groupings of files to which the query applies.
* Supported groupings are: 'user' (files created by, opened by, or shared
* directly with the user), 'drive' (files in the specified shared drive as
* indicated by the 'driveId'), 'domain' (files shared to the user's domain),
* and 'allDrives' (A combination of 'user' and 'drive' for all drives where the
* user is a member). When able, use 'user' or 'drive', instead of 'allDrives',
* for efficiency.
* @opt_param string corpus The source of files to list. Deprecated: use
* 'corpora' instead.
* @opt_param string driveId ID of the shared drive to search.
* @opt_param bool includeItemsFromAllDrives Whether both My Drive and shared
* drive items should be included in results.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool includeTeamDriveItems Deprecated use
* includeItemsFromAllDrives instead.
* @opt_param string orderBy A comma-separated list of sort keys. Valid keys are
* 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name',
* 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred',
* and 'viewedByMeTime'. Each key sorts ascending by default, but may be
* reversed with the 'desc' modifier. Example usage:
* ?orderBy=folder,modifiedTime desc,name. Please note that there is a current
* limitation for users with approximately one million files in which the
* requested sort order is ignored.
* @opt_param int pageSize The maximum number of files to return per page.
* Partial or empty result pages are possible even before the end of the files
* list has been reached.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @opt_param string q A query for filtering the file results. See the "Search
* for Files" guide for supported syntax.
* @opt_param string spaces A comma-separated list of spaces to query within the
* corpora. Supported values are 'drive' and 'appDataFolder'.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param string teamDriveId Deprecated use driveId instead.
* @return FileList
*/
public function listFiles($optParams = [])
{
$params = [];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], FileList::class);
}
/**
* Lists the labels on a file. (files.listLabels)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param int maxResults The maximum number of labels to return per page.
* When not set, this defaults to 100.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @return LabelList
*/
public function listLabels($fileId, $optParams = [])
{
$params = ['fileId' => $fileId];
$params = \array_merge($params, $optParams);
return $this->call('listLabels', [$params], LabelList::class);
}
/**
* Modifies the set of labels on a file. (files.modifyLabels)
*
* @param string $fileId The ID of the file for which the labels are modified.
* @param ModifyLabelsRequest $postBody
* @param array $optParams Optional parameters.
* @return ModifyLabelsResponse
*/
public function modifyLabels($fileId, ModifyLabelsRequest $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('modifyLabels', [$params], ModifyLabelsResponse::class);
}
/**
* Updates a file's metadata and/or content. When calling this method, only
* populate fields in the request that you want to modify. When updating fields,
* some fields might change automatically, such as modifiedDate. This method
* supports patch semantics. (files.update)
*
* @param string $fileId The ID of the file.
* @param DriveFile $postBody
* @param array $optParams Optional parameters.
*
* @opt_param string addParents A comma-separated list of parent IDs to add.
* @opt_param bool enforceSingleParent Deprecated. Adding files to multiple
* folders is no longer supported. Use shortcuts instead.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
* the new head revision. This is only applicable to files with binary content
* in Google Drive. Only 200 revisions for the file can be kept forever. If the
* limit is reached, try deleting pinned revisions.
* @opt_param string ocrLanguage A language hint for OCR processing during image
* import (ISO 639-1 code).
* @opt_param string removeParents A comma-separated list of parent IDs to
* remove.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param bool useContentAsIndexableText Whether to use the uploaded content
* as indexable text.
* @return DriveFile
*/
public function update($fileId, DriveFile $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('update', [$params], DriveFile::class);
}
/**
* Subscribe to changes on a file. (files.watch)
*
* @param string $fileId The ID of the file.
* @param Channel $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
* of downloading known malware or other abusive files. This is only applicable
* when alt=media.
* @opt_param string includeLabels A comma-separated list of IDs of labels to
* include in the labelInfo part of the response.
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @return Channel
*/
public function watch($fileId, Channel $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('watch', [$params], Channel::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Files::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Files');

View File

@@ -0,0 +1,183 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\Permission;
use VendorDuplicator\Google\Service\Drive\PermissionList;
/**
* The "permissions" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $permissions = $driveService->permissions;
* </code>
*/
class Permissions extends \VendorDuplicator\Google\Service\Resource
{
/**
* Creates a permission for a file or shared drive. For more information on
* creating permissions, see Share files, folders & drives. (permissions.create)
*
* @param string $fileId The ID of the file or shared drive.
* @param Permission $postBody
* @param array $optParams Optional parameters.
*
* @opt_param string emailMessage A plain text custom message to include in the
* notification email.
* @opt_param bool enforceSingleParent Deprecated. See moveToNewOwnersRoot for
* details.
* @opt_param bool moveToNewOwnersRoot This parameter will only take effect if
* the item is not in a shared drive and the request is attempting to transfer
* the ownership of the item. If set to true, the item will be moved to the new
* owner's My Drive root folder and all prior parents removed. If set to false,
* parents are not changed.
* @opt_param bool sendNotificationEmail Whether to send a notification email
* when sharing to users or groups. This defaults to true for users and groups,
* and is not allowed for other requests. It must not be disabled for ownership
* transfers.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param bool transferOwnership Whether to transfer ownership to the
* specified user and downgrade the current owner to a writer. This parameter is
* required as an acknowledgement of the side effect. File owners can only
* transfer ownership of files existing on My Drive. Files existing in a shared
* drive are owned by the organization that owns that shared drive. Ownership
* transfers are not supported for files and folders in shared drives.
* Organizers of a shared drive can move items from that shared drive into their
* My Drive which transfers the ownership to them.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* the file ID parameter refers to a shared drive and the requester is an
* administrator of the domain to which the shared drive belongs.
* @return Permission
*/
public function create($fileId, Permission $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('create', [$params], Permission::class);
}
/**
* Deletes a permission. (permissions.delete)
*
* @param string $fileId The ID of the file or shared drive.
* @param string $permissionId The ID of the permission.
* @param array $optParams Optional parameters.
*
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* the file ID parameter refers to a shared drive and the requester is an
* administrator of the domain to which the shared drive belongs.
*/
public function delete($fileId, $permissionId, $optParams = [])
{
$params = ['fileId' => $fileId, 'permissionId' => $permissionId];
$params = \array_merge($params, $optParams);
return $this->call('delete', [$params]);
}
/**
* Gets a permission by ID. (permissions.get)
*
* @param string $fileId The ID of the file.
* @param string $permissionId The ID of the permission.
* @param array $optParams Optional parameters.
*
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* the file ID parameter refers to a shared drive and the requester is an
* administrator of the domain to which the shared drive belongs.
* @return Permission
*/
public function get($fileId, $permissionId, $optParams = [])
{
$params = ['fileId' => $fileId, 'permissionId' => $permissionId];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], Permission::class);
}
/**
* Lists a file's or shared drive's permissions. (permissions.listPermissions)
*
* @param string $fileId The ID of the file or shared drive.
* @param array $optParams Optional parameters.
*
* @opt_param string includePermissionsForView Specifies which additional view's
* permissions to include in the response. Only 'published' is supported.
* @opt_param int pageSize The maximum number of permissions to return per page.
* When not set for files in a shared drive, at most 100 results will be
* returned. When not set for files that are not in a shared drive, the entire
* list will be returned.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* the file ID parameter refers to a shared drive and the requester is an
* administrator of the domain to which the shared drive belongs.
* @return PermissionList
*/
public function listPermissions($fileId, $optParams = [])
{
$params = ['fileId' => $fileId];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], PermissionList::class);
}
/**
* Updates a permission with patch semantics. (permissions.update)
*
* @param string $fileId The ID of the file or shared drive.
* @param string $permissionId The ID of the permission.
* @param Permission $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool removeExpiration Whether to remove the expiration date.
* @opt_param bool supportsAllDrives Whether the requesting application supports
* both My Drives and shared drives.
* @opt_param bool supportsTeamDrives Deprecated use supportsAllDrives instead.
* @opt_param bool transferOwnership Whether to transfer ownership to the
* specified user and downgrade the current owner to a writer. This parameter is
* required as an acknowledgement of the side effect. File owners can only
* transfer ownership of files existing on My Drive. Files existing in a shared
* drive are owned by the organization that owns that shared drive. Ownership
* transfers are not supported for files and folders in shared drives.
* Organizers of a shared drive can move items from that shared drive into their
* My Drive which transfers the ownership to them.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* the file ID parameter refers to a shared drive and the requester is an
* administrator of the domain to which the shared drive belongs.
* @return Permission
*/
public function update($fileId, $permissionId, Permission $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'permissionId' => $permissionId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('update', [$params], Permission::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Permissions::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Permissions');

View File

@@ -0,0 +1,118 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\Reply;
use VendorDuplicator\Google\Service\Drive\ReplyList;
/**
* The "replies" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $replies = $driveService->replies;
* </code>
*/
class Replies extends \VendorDuplicator\Google\Service\Resource
{
/**
* Creates a reply to a comment. (replies.create)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param Reply $postBody
* @param array $optParams Optional parameters.
* @return Reply
*/
public function create($fileId, $commentId, Reply $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('create', [$params], Reply::class);
}
/**
* Deletes a reply. (replies.delete)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param string $replyId The ID of the reply.
* @param array $optParams Optional parameters.
*/
public function delete($fileId, $commentId, $replyId, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId];
$params = \array_merge($params, $optParams);
return $this->call('delete', [$params]);
}
/**
* Gets a reply by ID. (replies.get)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param string $replyId The ID of the reply.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to return deleted replies. Deleted
* replies will not include their original content.
* @return Reply
*/
public function get($fileId, $commentId, $replyId, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], Reply::class);
}
/**
* Lists a comment's replies. (replies.listReplies)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to include deleted replies. Deleted
* replies will not include their original content.
* @opt_param int pageSize The maximum number of replies to return per page.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @return ReplyList
*/
public function listReplies($fileId, $commentId, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], ReplyList::class);
}
/**
* Updates a reply with patch semantics. (replies.update)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param string $replyId The ID of the reply.
* @param Reply $postBody
* @param array $optParams Optional parameters.
* @return Reply
*/
public function update($fileId, $commentId, $replyId, Reply $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('update', [$params], Reply::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Replies::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Replies');

View File

@@ -0,0 +1,101 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\Revision;
use VendorDuplicator\Google\Service\Drive\RevisionList;
/**
* The "revisions" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $revisions = $driveService->revisions;
* </code>
*/
class Revisions extends \VendorDuplicator\Google\Service\Resource
{
/**
* Permanently deletes a file version. You can only delete revisions for files
* with binary content in Google Drive, like images or videos. Revisions for
* other files, like Google Docs or Sheets, and the last remaining file version
* can't be deleted. (revisions.delete)
*
* @param string $fileId The ID of the file.
* @param string $revisionId The ID of the revision.
* @param array $optParams Optional parameters.
*/
public function delete($fileId, $revisionId, $optParams = [])
{
$params = ['fileId' => $fileId, 'revisionId' => $revisionId];
$params = \array_merge($params, $optParams);
return $this->call('delete', [$params]);
}
/**
* Gets a revision's metadata or content by ID. (revisions.get)
*
* @param string $fileId The ID of the file.
* @param string $revisionId The ID of the revision.
* @param array $optParams Optional parameters.
*
* @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
* of downloading known malware or other abusive files. This is only applicable
* when alt=media.
* @return Revision
*/
public function get($fileId, $revisionId, $optParams = [])
{
$params = ['fileId' => $fileId, 'revisionId' => $revisionId];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], Revision::class);
}
/**
* Lists a file's revisions. (revisions.listRevisions)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param int pageSize The maximum number of revisions to return per page.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @return RevisionList
*/
public function listRevisions($fileId, $optParams = [])
{
$params = ['fileId' => $fileId];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], RevisionList::class);
}
/**
* Updates a revision with patch semantics. (revisions.update)
*
* @param string $fileId The ID of the file.
* @param string $revisionId The ID of the revision.
* @param Revision $postBody
* @param array $optParams Optional parameters.
* @return Revision
*/
public function update($fileId, $revisionId, Revision $postBody, $optParams = [])
{
$params = ['fileId' => $fileId, 'revisionId' => $revisionId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('update', [$params], Revision::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Revisions::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Revisions');

View File

@@ -0,0 +1,118 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive\Resource;
use VendorDuplicator\Google\Service\Drive\TeamDrive;
use VendorDuplicator\Google\Service\Drive\TeamDriveList;
/**
* The "teamdrives" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google\Service\Drive(...);
* $teamdrives = $driveService->teamdrives;
* </code>
*/
class Teamdrives extends \VendorDuplicator\Google\Service\Resource
{
/**
* Deprecated use drives.create instead. (teamdrives.create)
*
* @param string $requestId An ID, such as a random UUID, which uniquely
* identifies this user's request for idempotent creation of a Team Drive. A
* repeated request by the same user and with the same request ID will avoid
* creating duplicates by attempting to create the same Team Drive. If the Team
* Drive already exists a 409 error will be returned.
* @param TeamDrive $postBody
* @param array $optParams Optional parameters.
* @return TeamDrive
*/
public function create($requestId, TeamDrive $postBody, $optParams = [])
{
$params = ['requestId' => $requestId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('create', [$params], TeamDrive::class);
}
/**
* Deprecated use drives.delete instead. (teamdrives.delete)
*
* @param string $teamDriveId The ID of the Team Drive
* @param array $optParams Optional parameters.
*/
public function delete($teamDriveId, $optParams = [])
{
$params = ['teamDriveId' => $teamDriveId];
$params = \array_merge($params, $optParams);
return $this->call('delete', [$params]);
}
/**
* Deprecated use drives.get instead. (teamdrives.get)
*
* @param string $teamDriveId The ID of the Team Drive
* @param array $optParams Optional parameters.
*
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the Team Drive belongs.
* @return TeamDrive
*/
public function get($teamDriveId, $optParams = [])
{
$params = ['teamDriveId' => $teamDriveId];
$params = \array_merge($params, $optParams);
return $this->call('get', [$params], TeamDrive::class);
}
/**
* Deprecated use drives.list instead. (teamdrives.listTeamdrives)
*
* @param array $optParams Optional parameters.
*
* @opt_param int pageSize Maximum number of Team Drives to return.
* @opt_param string pageToken Page token for Team Drives.
* @opt_param string q Query string for searching Team Drives.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then all Team Drives of the domain in which
* the requester is an administrator are returned.
* @return TeamDriveList
*/
public function listTeamdrives($optParams = [])
{
$params = [];
$params = \array_merge($params, $optParams);
return $this->call('list', [$params], TeamDriveList::class);
}
/**
* Deprecated use drives.update instead (teamdrives.update)
*
* @param string $teamDriveId The ID of the Team Drive
* @param TeamDrive $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the Team Drive belongs.
* @return TeamDrive
*/
public function update($teamDriveId, TeamDrive $postBody, $optParams = [])
{
$params = ['teamDriveId' => $teamDriveId, 'postBody' => $postBody];
$params = \array_merge($params, $optParams);
return $this->call('update', [$params], TeamDrive::class);
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Teamdrives::class, 'VendorDuplicator\\Google_Service_Drive_Resource_Teamdrives');

View File

@@ -0,0 +1,274 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class Revision extends \VendorDuplicator\Google\Model
{
/**
* @var string[]
*/
public $exportLinks;
/**
* @var string
*/
public $id;
/**
* @var bool
*/
public $keepForever;
/**
* @var string
*/
public $kind;
protected $lastModifyingUserType = User::class;
protected $lastModifyingUserDataType = '';
/**
* @var string
*/
public $md5Checksum;
/**
* @var string
*/
public $mimeType;
/**
* @var string
*/
public $modifiedTime;
/**
* @var string
*/
public $originalFilename;
/**
* @var bool
*/
public $publishAuto;
/**
* @var bool
*/
public $published;
/**
* @var string
*/
public $publishedLink;
/**
* @var bool
*/
public $publishedOutsideDomain;
/**
* @var string
*/
public $size;
/**
* @param string[]
*/
public function setExportLinks($exportLinks)
{
$this->exportLinks = $exportLinks;
}
/**
* @return string[]
*/
public function getExportLinks()
{
return $this->exportLinks;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param bool
*/
public function setKeepForever($keepForever)
{
$this->keepForever = $keepForever;
}
/**
* @return bool
*/
public function getKeepForever()
{
return $this->keepForever;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param User
*/
public function setLastModifyingUser(User $lastModifyingUser)
{
$this->lastModifyingUser = $lastModifyingUser;
}
/**
* @return User
*/
public function getLastModifyingUser()
{
return $this->lastModifyingUser;
}
/**
* @param string
*/
public function setMd5Checksum($md5Checksum)
{
$this->md5Checksum = $md5Checksum;
}
/**
* @return string
*/
public function getMd5Checksum()
{
return $this->md5Checksum;
}
/**
* @param string
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* @param string
*/
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
/**
* @return string
*/
public function getModifiedTime()
{
return $this->modifiedTime;
}
/**
* @param string
*/
public function setOriginalFilename($originalFilename)
{
$this->originalFilename = $originalFilename;
}
/**
* @return string
*/
public function getOriginalFilename()
{
return $this->originalFilename;
}
/**
* @param bool
*/
public function setPublishAuto($publishAuto)
{
$this->publishAuto = $publishAuto;
}
/**
* @return bool
*/
public function getPublishAuto()
{
return $this->publishAuto;
}
/**
* @param bool
*/
public function setPublished($published)
{
$this->published = $published;
}
/**
* @return bool
*/
public function getPublished()
{
return $this->published;
}
/**
* @param string
*/
public function setPublishedLink($publishedLink)
{
$this->publishedLink = $publishedLink;
}
/**
* @return string
*/
public function getPublishedLink()
{
return $this->publishedLink;
}
/**
* @param bool
*/
public function setPublishedOutsideDomain($publishedOutsideDomain)
{
$this->publishedOutsideDomain = $publishedOutsideDomain;
}
/**
* @return bool
*/
public function getPublishedOutsideDomain()
{
return $this->publishedOutsideDomain;
}
/**
* @param string
*/
public function setSize($size)
{
$this->size = $size;
}
/**
* @return string
*/
public function getSize()
{
return $this->size;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(Revision::class, 'VendorDuplicator\\Google_Service_Drive_Revision');

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class RevisionList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'revisions';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $nextPageToken;
protected $revisionsType = Revision::class;
protected $revisionsDataType = 'array';
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param Revision[]
*/
public function setRevisions($revisions)
{
$this->revisions = $revisions;
}
/**
* @return Revision[]
*/
public function getRevisions()
{
return $this->revisions;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(RevisionList::class, 'VendorDuplicator\\Google_Service_Drive_RevisionList');

View File

@@ -0,0 +1,60 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class StartPageToken extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $startPageToken;
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setStartPageToken($startPageToken)
{
$this->startPageToken = $startPageToken;
}
/**
* @return string
*/
public function getStartPageToken()
{
return $this->startPageToken;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(StartPageToken::class, 'VendorDuplicator\\Google_Service_Drive_StartPageToken');

View File

@@ -0,0 +1,216 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class TeamDrive extends \VendorDuplicator\Google\Model
{
protected $backgroundImageFileType = TeamDriveBackgroundImageFile::class;
protected $backgroundImageFileDataType = '';
/**
* @var string
*/
public $backgroundImageLink;
protected $capabilitiesType = TeamDriveCapabilities::class;
protected $capabilitiesDataType = '';
/**
* @var string
*/
public $colorRgb;
/**
* @var string
*/
public $createdTime;
/**
* @var string
*/
public $id;
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $name;
/**
* @var string
*/
public $orgUnitId;
protected $restrictionsType = TeamDriveRestrictions::class;
protected $restrictionsDataType = '';
/**
* @var string
*/
public $themeId;
/**
* @param TeamDriveBackgroundImageFile
*/
public function setBackgroundImageFile(TeamDriveBackgroundImageFile $backgroundImageFile)
{
$this->backgroundImageFile = $backgroundImageFile;
}
/**
* @return TeamDriveBackgroundImageFile
*/
public function getBackgroundImageFile()
{
return $this->backgroundImageFile;
}
/**
* @param string
*/
public function setBackgroundImageLink($backgroundImageLink)
{
$this->backgroundImageLink = $backgroundImageLink;
}
/**
* @return string
*/
public function getBackgroundImageLink()
{
return $this->backgroundImageLink;
}
/**
* @param TeamDriveCapabilities
*/
public function setCapabilities(TeamDriveCapabilities $capabilities)
{
$this->capabilities = $capabilities;
}
/**
* @return TeamDriveCapabilities
*/
public function getCapabilities()
{
return $this->capabilities;
}
/**
* @param string
*/
public function setColorRgb($colorRgb)
{
$this->colorRgb = $colorRgb;
}
/**
* @return string
*/
public function getColorRgb()
{
return $this->colorRgb;
}
/**
* @param string
*/
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
/**
* @return string
*/
public function getCreatedTime()
{
return $this->createdTime;
}
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string
*/
public function setOrgUnitId($orgUnitId)
{
$this->orgUnitId = $orgUnitId;
}
/**
* @return string
*/
public function getOrgUnitId()
{
return $this->orgUnitId;
}
/**
* @param TeamDriveRestrictions
*/
public function setRestrictions(TeamDriveRestrictions $restrictions)
{
$this->restrictions = $restrictions;
}
/**
* @return TeamDriveRestrictions
*/
public function getRestrictions()
{
return $this->restrictions;
}
/**
* @param string
*/
public function setThemeId($themeId)
{
$this->themeId = $themeId;
}
/**
* @return string
*/
public function getThemeId()
{
return $this->themeId;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(TeamDrive::class, 'VendorDuplicator\\Google_Service_Drive_TeamDrive');

View File

@@ -0,0 +1,96 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class TeamDriveBackgroundImageFile extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $id;
/**
* @var float
*/
public $width;
/**
* @var float
*/
public $xCoordinate;
/**
* @var float
*/
public $yCoordinate;
/**
* @param string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param float
*/
public function setWidth($width)
{
$this->width = $width;
}
/**
* @return float
*/
public function getWidth()
{
return $this->width;
}
/**
* @param float
*/
public function setXCoordinate($xCoordinate)
{
$this->xCoordinate = $xCoordinate;
}
/**
* @return float
*/
public function getXCoordinate()
{
return $this->xCoordinate;
}
/**
* @param float
*/
public function setYCoordinate($yCoordinate)
{
$this->yCoordinate = $yCoordinate;
}
/**
* @return float
*/
public function getYCoordinate()
{
return $this->yCoordinate;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(TeamDriveBackgroundImageFile::class, 'VendorDuplicator\\Google_Service_Drive_TeamDriveBackgroundImageFile');

View File

@@ -0,0 +1,402 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class TeamDriveCapabilities extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $canAddChildren;
/**
* @var bool
*/
public $canChangeCopyRequiresWriterPermissionRestriction;
/**
* @var bool
*/
public $canChangeDomainUsersOnlyRestriction;
/**
* @var bool
*/
public $canChangeSharingFoldersRequiresOrganizerPermissionRestriction;
/**
* @var bool
*/
public $canChangeTeamDriveBackground;
/**
* @var bool
*/
public $canChangeTeamMembersOnlyRestriction;
/**
* @var bool
*/
public $canComment;
/**
* @var bool
*/
public $canCopy;
/**
* @var bool
*/
public $canDeleteChildren;
/**
* @var bool
*/
public $canDeleteTeamDrive;
/**
* @var bool
*/
public $canDownload;
/**
* @var bool
*/
public $canEdit;
/**
* @var bool
*/
public $canListChildren;
/**
* @var bool
*/
public $canManageMembers;
/**
* @var bool
*/
public $canReadRevisions;
/**
* @var bool
*/
public $canRemoveChildren;
/**
* @var bool
*/
public $canRename;
/**
* @var bool
*/
public $canRenameTeamDrive;
/**
* @var bool
*/
public $canResetTeamDriveRestrictions;
/**
* @var bool
*/
public $canShare;
/**
* @var bool
*/
public $canTrashChildren;
/**
* @param bool
*/
public function setCanAddChildren($canAddChildren)
{
$this->canAddChildren = $canAddChildren;
}
/**
* @return bool
*/
public function getCanAddChildren()
{
return $this->canAddChildren;
}
/**
* @param bool
*/
public function setCanChangeCopyRequiresWriterPermissionRestriction($canChangeCopyRequiresWriterPermissionRestriction)
{
$this->canChangeCopyRequiresWriterPermissionRestriction = $canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* @return bool
*/
public function getCanChangeCopyRequiresWriterPermissionRestriction()
{
return $this->canChangeCopyRequiresWriterPermissionRestriction;
}
/**
* @param bool
*/
public function setCanChangeDomainUsersOnlyRestriction($canChangeDomainUsersOnlyRestriction)
{
$this->canChangeDomainUsersOnlyRestriction = $canChangeDomainUsersOnlyRestriction;
}
/**
* @return bool
*/
public function getCanChangeDomainUsersOnlyRestriction()
{
return $this->canChangeDomainUsersOnlyRestriction;
}
/**
* @param bool
*/
public function setCanChangeSharingFoldersRequiresOrganizerPermissionRestriction($canChangeSharingFoldersRequiresOrganizerPermissionRestriction)
{
$this->canChangeSharingFoldersRequiresOrganizerPermissionRestriction = $canChangeSharingFoldersRequiresOrganizerPermissionRestriction;
}
/**
* @return bool
*/
public function getCanChangeSharingFoldersRequiresOrganizerPermissionRestriction()
{
return $this->canChangeSharingFoldersRequiresOrganizerPermissionRestriction;
}
/**
* @param bool
*/
public function setCanChangeTeamDriveBackground($canChangeTeamDriveBackground)
{
$this->canChangeTeamDriveBackground = $canChangeTeamDriveBackground;
}
/**
* @return bool
*/
public function getCanChangeTeamDriveBackground()
{
return $this->canChangeTeamDriveBackground;
}
/**
* @param bool
*/
public function setCanChangeTeamMembersOnlyRestriction($canChangeTeamMembersOnlyRestriction)
{
$this->canChangeTeamMembersOnlyRestriction = $canChangeTeamMembersOnlyRestriction;
}
/**
* @return bool
*/
public function getCanChangeTeamMembersOnlyRestriction()
{
return $this->canChangeTeamMembersOnlyRestriction;
}
/**
* @param bool
*/
public function setCanComment($canComment)
{
$this->canComment = $canComment;
}
/**
* @return bool
*/
public function getCanComment()
{
return $this->canComment;
}
/**
* @param bool
*/
public function setCanCopy($canCopy)
{
$this->canCopy = $canCopy;
}
/**
* @return bool
*/
public function getCanCopy()
{
return $this->canCopy;
}
/**
* @param bool
*/
public function setCanDeleteChildren($canDeleteChildren)
{
$this->canDeleteChildren = $canDeleteChildren;
}
/**
* @return bool
*/
public function getCanDeleteChildren()
{
return $this->canDeleteChildren;
}
/**
* @param bool
*/
public function setCanDeleteTeamDrive($canDeleteTeamDrive)
{
$this->canDeleteTeamDrive = $canDeleteTeamDrive;
}
/**
* @return bool
*/
public function getCanDeleteTeamDrive()
{
return $this->canDeleteTeamDrive;
}
/**
* @param bool
*/
public function setCanDownload($canDownload)
{
$this->canDownload = $canDownload;
}
/**
* @return bool
*/
public function getCanDownload()
{
return $this->canDownload;
}
/**
* @param bool
*/
public function setCanEdit($canEdit)
{
$this->canEdit = $canEdit;
}
/**
* @return bool
*/
public function getCanEdit()
{
return $this->canEdit;
}
/**
* @param bool
*/
public function setCanListChildren($canListChildren)
{
$this->canListChildren = $canListChildren;
}
/**
* @return bool
*/
public function getCanListChildren()
{
return $this->canListChildren;
}
/**
* @param bool
*/
public function setCanManageMembers($canManageMembers)
{
$this->canManageMembers = $canManageMembers;
}
/**
* @return bool
*/
public function getCanManageMembers()
{
return $this->canManageMembers;
}
/**
* @param bool
*/
public function setCanReadRevisions($canReadRevisions)
{
$this->canReadRevisions = $canReadRevisions;
}
/**
* @return bool
*/
public function getCanReadRevisions()
{
return $this->canReadRevisions;
}
/**
* @param bool
*/
public function setCanRemoveChildren($canRemoveChildren)
{
$this->canRemoveChildren = $canRemoveChildren;
}
/**
* @return bool
*/
public function getCanRemoveChildren()
{
return $this->canRemoveChildren;
}
/**
* @param bool
*/
public function setCanRename($canRename)
{
$this->canRename = $canRename;
}
/**
* @return bool
*/
public function getCanRename()
{
return $this->canRename;
}
/**
* @param bool
*/
public function setCanRenameTeamDrive($canRenameTeamDrive)
{
$this->canRenameTeamDrive = $canRenameTeamDrive;
}
/**
* @return bool
*/
public function getCanRenameTeamDrive()
{
return $this->canRenameTeamDrive;
}
/**
* @param bool
*/
public function setCanResetTeamDriveRestrictions($canResetTeamDriveRestrictions)
{
$this->canResetTeamDriveRestrictions = $canResetTeamDriveRestrictions;
}
/**
* @return bool
*/
public function getCanResetTeamDriveRestrictions()
{
return $this->canResetTeamDriveRestrictions;
}
/**
* @param bool
*/
public function setCanShare($canShare)
{
$this->canShare = $canShare;
}
/**
* @return bool
*/
public function getCanShare()
{
return $this->canShare;
}
/**
* @param bool
*/
public function setCanTrashChildren($canTrashChildren)
{
$this->canTrashChildren = $canTrashChildren;
}
/**
* @return bool
*/
public function getCanTrashChildren()
{
return $this->canTrashChildren;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(TeamDriveCapabilities::class, 'VendorDuplicator\\Google_Service_Drive_TeamDriveCapabilities');

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class TeamDriveList extends \VendorDuplicator\Google\Collection
{
protected $collection_key = 'teamDrives';
/**
* @var string
*/
public $kind;
/**
* @var string
*/
public $nextPageToken;
protected $teamDrivesType = TeamDrive::class;
protected $teamDrivesDataType = 'array';
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param string
*/
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
/**
* @return string
*/
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param TeamDrive[]
*/
public function setTeamDrives($teamDrives)
{
$this->teamDrives = $teamDrives;
}
/**
* @return TeamDrive[]
*/
public function getTeamDrives()
{
return $this->teamDrives;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(TeamDriveList::class, 'VendorDuplicator\\Google_Service_Drive_TeamDriveList');

View File

@@ -0,0 +1,114 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class TeamDriveRestrictions extends \VendorDuplicator\Google\Model
{
/**
* @var bool
*/
public $adminManagedRestrictions;
/**
* @var bool
*/
public $copyRequiresWriterPermission;
/**
* @var bool
*/
public $domainUsersOnly;
/**
* @var bool
*/
public $sharingFoldersRequiresOrganizerPermission;
/**
* @var bool
*/
public $teamMembersOnly;
/**
* @param bool
*/
public function setAdminManagedRestrictions($adminManagedRestrictions)
{
$this->adminManagedRestrictions = $adminManagedRestrictions;
}
/**
* @return bool
*/
public function getAdminManagedRestrictions()
{
return $this->adminManagedRestrictions;
}
/**
* @param bool
*/
public function setCopyRequiresWriterPermission($copyRequiresWriterPermission)
{
$this->copyRequiresWriterPermission = $copyRequiresWriterPermission;
}
/**
* @return bool
*/
public function getCopyRequiresWriterPermission()
{
return $this->copyRequiresWriterPermission;
}
/**
* @param bool
*/
public function setDomainUsersOnly($domainUsersOnly)
{
$this->domainUsersOnly = $domainUsersOnly;
}
/**
* @return bool
*/
public function getDomainUsersOnly()
{
return $this->domainUsersOnly;
}
/**
* @param bool
*/
public function setSharingFoldersRequiresOrganizerPermission($sharingFoldersRequiresOrganizerPermission)
{
$this->sharingFoldersRequiresOrganizerPermission = $sharingFoldersRequiresOrganizerPermission;
}
/**
* @return bool
*/
public function getSharingFoldersRequiresOrganizerPermission()
{
return $this->sharingFoldersRequiresOrganizerPermission;
}
/**
* @param bool
*/
public function setTeamMembersOnly($teamMembersOnly)
{
$this->teamMembersOnly = $teamMembersOnly;
}
/**
* @return bool
*/
public function getTeamMembersOnly()
{
return $this->teamMembersOnly;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(TeamDriveRestrictions::class, 'VendorDuplicator\\Google_Service_Drive_TeamDriveRestrictions');

View File

@@ -0,0 +1,132 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Service\Drive;
class User extends \VendorDuplicator\Google\Model
{
/**
* @var string
*/
public $displayName;
/**
* @var string
*/
public $emailAddress;
/**
* @var string
*/
public $kind;
/**
* @var bool
*/
public $me;
/**
* @var string
*/
public $permissionId;
/**
* @var string
*/
public $photoLink;
/**
* @param string
*/
public function setDisplayName($displayName)
{
$this->displayName = $displayName;
}
/**
* @return string
*/
public function getDisplayName()
{
return $this->displayName;
}
/**
* @param string
*/
public function setEmailAddress($emailAddress)
{
$this->emailAddress = $emailAddress;
}
/**
* @return string
*/
public function getEmailAddress()
{
return $this->emailAddress;
}
/**
* @param string
*/
public function setKind($kind)
{
$this->kind = $kind;
}
/**
* @return string
*/
public function getKind()
{
return $this->kind;
}
/**
* @param bool
*/
public function setMe($me)
{
$this->me = $me;
}
/**
* @return bool
*/
public function getMe()
{
return $this->me;
}
/**
* @param string
*/
public function setPermissionId($permissionId)
{
$this->permissionId = $permissionId;
}
/**
* @return string
*/
public function getPermissionId()
{
return $this->permissionId;
}
/**
* @param string
*/
public function setPhotoLink($photoLink)
{
$this->photoLink = $photoLink;
}
/**
* @return string
*/
public function getPhotoLink()
{
return $this->photoLink;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
\class_alias(User::class, 'VendorDuplicator\\Google_Service_Drive_User');

View File

@@ -0,0 +1,65 @@
<?php
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\AccessToken;
use VendorDuplicator\Google\Auth\HttpHandler\HttpHandlerFactory;
use VendorDuplicator\Google\Client;
use VendorDuplicator\GuzzleHttp\ClientInterface;
use VendorDuplicator\GuzzleHttp\Psr7;
use VendorDuplicator\GuzzleHttp\Psr7\Request;
/**
* Wrapper around Google Access Tokens which provides convenience functions
*
*/
class Revoke
{
/**
* @var ClientInterface The http client
*/
private $http;
/**
* Instantiates the class, but does not initiate the login flow, leaving it
* to the discretion of the caller.
*/
public function __construct(ClientInterface $http = null)
{
$this->http = $http;
}
/**
* Revoke an OAuth2 access token or refresh token. This method will revoke the current access
* token, if a token isn't provided.
*
* @param string|array $token The token (access token or a refresh token) that should be revoked.
* @return boolean Returns True if the revocation was successful, otherwise False.
*/
public function revokeToken($token)
{
if (\is_array($token)) {
if (isset($token['refresh_token'])) {
$token = $token['refresh_token'];
} else {
$token = $token['access_token'];
}
}
$body = Psr7\Utils::streamFor(\http_build_query(['token' => $token]));
$request = new Request('POST', Client::OAUTH2_REVOKE_URI, ['Cache-Control' => 'no-store', 'Content-Type' => 'application/x-www-form-urlencoded'], $body);
$httpHandler = HttpHandlerFactory::build($this->http);
$response = $httpHandler($request);
return $response->getStatusCode() == 200;
}
}

View File

@@ -0,0 +1,261 @@
<?php
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\AccessToken;
use DateTime;
use DomainException;
use Exception;
use VendorDuplicator\ExpiredException;
use VendorDuplicator\Firebase\JWT\ExpiredException as ExpiredExceptionV3;
use VendorDuplicator\Firebase\JWT\Key;
use VendorDuplicator\Firebase\JWT\SignatureInvalidException;
use VendorDuplicator\Google\Auth\Cache\MemoryCacheItemPool;
use VendorDuplicator\Google\Exception as GoogleException;
use VendorDuplicator\GuzzleHttp\Client;
use VendorDuplicator\GuzzleHttp\ClientInterface;
use InvalidArgumentException;
use LogicException;
use VendorDuplicator\phpseclib3\Crypt\PublicKeyLoader;
use VendorDuplicator\phpseclib3\Crypt\RSA\PublicKey;
// Firebase v2
use VendorDuplicator\Psr\Cache\CacheItemPoolInterface;
/**
* Wrapper around Google Access Tokens which provides convenience functions
*
*/
class Verify
{
const FEDERATED_SIGNON_CERT_URL = 'https://www.googleapis.com/oauth2/v3/certs';
const OAUTH2_ISSUER = 'accounts.google.com';
const OAUTH2_ISSUER_HTTPS = 'https://accounts.google.com';
/**
* @var ClientInterface The http client
*/
private $http;
/**
* @var CacheItemPoolInterface cache class
*/
private $cache;
/**
* @var \VendorDuplicator\Firebase\JWT\JWT
*/
public $jwt;
/**
* Instantiates the class, but does not initiate the login flow, leaving it
* to the discretion of the caller.
*/
public function __construct(ClientInterface $http = null, CacheItemPoolInterface $cache = null, $jwt = null)
{
if (null === $http) {
$http = new Client();
}
if (null === $cache) {
$cache = new MemoryCacheItemPool();
}
$this->http = $http;
$this->cache = $cache;
$this->jwt = $jwt ?: $this->getJwtService();
}
/**
* Verifies an id token and returns the authenticated apiLoginTicket.
* Throws an exception if the id token is not valid.
* The audience parameter can be used to control which id tokens are
* accepted. By default, the id token must have been issued to this OAuth2 client.
*
* @param string $idToken the ID token in JWT format
* @param string $audience Optional. The audience to verify against JWt "aud"
* @return array|false the token payload, if successful
*/
public function verifyIdToken($idToken, $audience = null)
{
if (empty($idToken)) {
throw new LogicException('id_token cannot be null');
}
// set phpseclib constants if applicable
$this->setPhpsecConstants();
// Check signature
$certs = $this->getFederatedSignOnCerts();
foreach ($certs as $cert) {
try {
$args = [$idToken];
$publicKey = $this->getPublicKey($cert);
if (\class_exists(Key::class)) {
$args[] = new Key($publicKey, 'RS256');
} else {
$args[] = $publicKey;
$args[] = ['RS256'];
}
$payload = \call_user_func_array([$this->jwt, 'decode'], $args);
if (\property_exists($payload, 'aud')) {
if ($audience && $payload->aud != $audience) {
return \false;
}
}
// support HTTP and HTTPS issuers
// @see https://developers.google.com/identity/sign-in/web/backend-auth
$issuers = [self::OAUTH2_ISSUER, self::OAUTH2_ISSUER_HTTPS];
if (!isset($payload->iss) || !\in_array($payload->iss, $issuers)) {
return \false;
}
return (array) $payload;
} catch (ExpiredException $e) {
// @phpstan-ignore-line
return \false;
} catch (ExpiredExceptionV3 $e) {
return \false;
} catch (SignatureInvalidException $e) {
// continue
} catch (DomainException $e) {
// continue
}
}
return \false;
}
private function getCache()
{
return $this->cache;
}
/**
* Retrieve and cache a certificates file.
*
* @param string $url location
* @throws \VendorDuplicator\Google\Exception
* @return array certificates
*/
private function retrieveCertsFromLocation($url)
{
// If we're retrieving a local file, just grab it.
if (0 !== \strpos($url, 'http')) {
if (!($file = \file_get_contents($url))) {
throw new GoogleException("Failed to retrieve verification certificates: '" . $url . "'.");
}
return \json_decode($file, \true);
}
// @phpstan-ignore-next-line
$response = $this->http->get($url);
if ($response->getStatusCode() == 200) {
return \json_decode((string) $response->getBody(), \true);
}
throw new GoogleException(\sprintf('Failed to retrieve verification certificates: "%s".', $response->getBody()->getContents()), $response->getStatusCode());
}
// Gets federated sign-on certificates to use for verifying identity tokens.
// Returns certs as array structure, where keys are key ids, and values
// are PEM encoded certificates.
private function getFederatedSignOnCerts()
{
$certs = null;
if ($cache = $this->getCache()) {
$cacheItem = $cache->getItem('federated_signon_certs_v3');
$certs = $cacheItem->get();
}
if (!$certs) {
$certs = $this->retrieveCertsFromLocation(self::FEDERATED_SIGNON_CERT_URL);
if ($cache) {
$cacheItem->expiresAt(new DateTime('+1 hour'));
$cacheItem->set($certs);
$cache->save($cacheItem);
}
}
if (!isset($certs['keys'])) {
throw new InvalidArgumentException('federated sign-on certs expects "keys" to be set');
}
return $certs['keys'];
}
private function getJwtService()
{
$jwtClass = 'JWT';
if (\class_exists('VendorDuplicator\\Firebase\\JWT\\JWT')) {
$jwtClass = 'VendorDuplicator\\Firebase\\JWT\\JWT';
}
if (\property_exists($jwtClass, 'leeway') && $jwtClass::$leeway < 1) {
// Ensures JWT leeway is at least 1
// @see https://github.com/google/google-api-php-client/issues/827
$jwtClass::$leeway = 1;
}
// @phpstan-ignore-next-line
return new $jwtClass();
}
private function getPublicKey($cert)
{
$bigIntClass = $this->getBigIntClass();
$modulus = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['n']), 256);
$exponent = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['e']), 256);
$component = ['n' => $modulus, 'e' => $exponent];
if (\class_exists('VendorDuplicator\\phpseclib3\\Crypt\\RSA\\PublicKey')) {
/** @var PublicKey $loader */
$loader = PublicKeyLoader::load($component);
return $loader->toString('PKCS8');
}
$rsaClass = $this->getRsaClass();
$rsa = new $rsaClass();
$rsa->loadKey($component);
return $rsa->getPublicKey();
}
private function getRsaClass()
{
if (\class_exists('VendorDuplicator\\phpseclib3\\Crypt\\RSA')) {
return 'VendorDuplicator\\phpseclib3\\Crypt\\RSA';
}
if (\class_exists('VendorDuplicator\\phpseclib\\Crypt\\RSA')) {
return 'VendorDuplicator\\phpseclib\\Crypt\\RSA';
}
return 'Crypt_RSA';
}
private function getBigIntClass()
{
if (\class_exists('VendorDuplicator\\phpseclib3\\Math\\BigInteger')) {
return 'VendorDuplicator\\phpseclib3\\Math\\BigInteger';
}
if (\class_exists('VendorDuplicator\\phpseclib\\Math\\BigInteger')) {
return 'VendorDuplicator\\phpseclib\\Math\\BigInteger';
}
return 'Math_BigInteger';
}
private function getOpenSslConstant()
{
if (\class_exists('VendorDuplicator\\phpseclib3\\Crypt\\AES')) {
return 'VendorDuplicator\\phpseclib3\\Crypt\\AES::ENGINE_OPENSSL';
}
if (\class_exists('VendorDuplicator\\phpseclib\\Crypt\\RSA')) {
return 'VendorDuplicator\\phpseclib\\Crypt\\RSA::MODE_OPENSSL';
}
if (\class_exists('VendorDuplicator\\Crypt_RSA')) {
return 'CRYPT_RSA_MODE_OPENSSL';
}
throw new Exception('Cannot find RSA class');
}
/**
* phpseclib calls "phpinfo" by default, which requires special
* whitelisting in the AppEngine VM environment. This function
* sets constants to bypass the need for phpseclib to check phpinfo
*
* @see phpseclib/Math/BigInteger
* @see https://github.com/GoogleCloudPlatform/getting-started-php/issues/85
*/
private function setPhpsecConstants()
{
if (\filter_var(\getenv('GAE_VM'), \FILTER_VALIDATE_BOOLEAN)) {
if (!\defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
\define('MATH_BIGINTEGER_OPENSSL_ENABLED', \true);
}
if (!\defined('CRYPT_RSA_MODE')) {
\define('CRYPT_RSA_MODE', \constant($this->getOpenSslConstant()));
}
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\AuthHandler;
use Exception;
use VendorDuplicator\GuzzleHttp\ClientInterface;
class AuthHandlerFactory
{
/**
* Builds out a default http handler for the installed version of guzzle.
*
* @return Guzzle5AuthHandler|Guzzle6AuthHandler|Guzzle7AuthHandler
* @throws Exception
*/
public static function build($cache = null, array $cacheConfig = [])
{
$guzzleVersion = null;
if (\defined('VendorDuplicator\\GuzzleHttp\\ClientInterface::MAJOR_VERSION')) {
$guzzleVersion = ClientInterface::MAJOR_VERSION;
} elseif (\defined('VendorDuplicator\\GuzzleHttp\\ClientInterface::VERSION')) {
$guzzleVersion = (int) \substr(ClientInterface::VERSION, 0, 1);
}
switch ($guzzleVersion) {
case 5:
return new Guzzle5AuthHandler($cache, $cacheConfig);
case 6:
return new Guzzle6AuthHandler($cache, $cacheConfig);
case 7:
return new Guzzle7AuthHandler($cache, $cacheConfig);
default:
throw new Exception('Version not supported');
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace VendorDuplicator\Google\AuthHandler;
use VendorDuplicator\Google\Auth\CredentialsLoader;
use VendorDuplicator\Google\Auth\FetchAuthTokenCache;
use VendorDuplicator\Google\Auth\HttpHandler\HttpHandlerFactory;
use VendorDuplicator\Google\Auth\Subscriber\AuthTokenSubscriber;
use VendorDuplicator\Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
use VendorDuplicator\Google\Auth\Subscriber\SimpleSubscriber;
use VendorDuplicator\GuzzleHttp\Client;
use VendorDuplicator\GuzzleHttp\ClientInterface;
use VendorDuplicator\Psr\Cache\CacheItemPoolInterface;
/**
* This supports Guzzle 5
*/
class Guzzle5AuthHandler
{
protected $cache;
protected $cacheConfig;
public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
{
$this->cache = $cache;
$this->cacheConfig = $cacheConfig;
}
public function attachCredentials(ClientInterface $http, CredentialsLoader $credentials, callable $tokenCallback = null)
{
// use the provided cache
if ($this->cache) {
$credentials = new FetchAuthTokenCache($credentials, $this->cacheConfig, $this->cache);
}
return $this->attachCredentialsCache($http, $credentials, $tokenCallback);
}
public function attachCredentialsCache(ClientInterface $http, FetchAuthTokenCache $credentials, callable $tokenCallback = null)
{
// if we end up needing to make an HTTP request to retrieve credentials, we
// can use our existing one, but we need to throw exceptions so the error
// bubbles up.
$authHttp = $this->createAuthHttp($http);
$authHttpHandler = HttpHandlerFactory::build($authHttp);
$subscriber = new AuthTokenSubscriber($credentials, $authHttpHandler, $tokenCallback);
$http->setDefaultOption('auth', 'google_auth');
$http->getEmitter()->attach($subscriber);
return $http;
}
public function attachToken(ClientInterface $http, array $token, array $scopes)
{
$tokenFunc = function ($scopes) use($token) {
return $token['access_token'];
};
$subscriber = new ScopedAccessTokenSubscriber($tokenFunc, $scopes, $this->cacheConfig, $this->cache);
$http->setDefaultOption('auth', 'scoped');
$http->getEmitter()->attach($subscriber);
return $http;
}
public function attachKey(ClientInterface $http, $key)
{
$subscriber = new SimpleSubscriber(['key' => $key]);
$http->setDefaultOption('auth', 'simple');
$http->getEmitter()->attach($subscriber);
return $http;
}
private function createAuthHttp(ClientInterface $http)
{
return new Client(['base_url' => $http->getBaseUrl(), 'defaults' => ['exceptions' => \true, 'verify' => $http->getDefaultOption('verify'), 'proxy' => $http->getDefaultOption('proxy')]]);
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace VendorDuplicator\Google\AuthHandler;
use VendorDuplicator\Google\Auth\CredentialsLoader;
use VendorDuplicator\Google\Auth\FetchAuthTokenCache;
use VendorDuplicator\Google\Auth\HttpHandler\HttpHandlerFactory;
use VendorDuplicator\Google\Auth\Middleware\AuthTokenMiddleware;
use VendorDuplicator\Google\Auth\Middleware\ScopedAccessTokenMiddleware;
use VendorDuplicator\Google\Auth\Middleware\SimpleMiddleware;
use VendorDuplicator\GuzzleHttp\Client;
use VendorDuplicator\GuzzleHttp\ClientInterface;
use VendorDuplicator\Psr\Cache\CacheItemPoolInterface;
/**
* This supports Guzzle 6
*/
class Guzzle6AuthHandler
{
protected $cache;
protected $cacheConfig;
public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
{
$this->cache = $cache;
$this->cacheConfig = $cacheConfig;
}
public function attachCredentials(ClientInterface $http, CredentialsLoader $credentials, callable $tokenCallback = null)
{
// use the provided cache
if ($this->cache) {
$credentials = new FetchAuthTokenCache($credentials, $this->cacheConfig, $this->cache);
}
return $this->attachCredentialsCache($http, $credentials, $tokenCallback);
}
public function attachCredentialsCache(ClientInterface $http, FetchAuthTokenCache $credentials, callable $tokenCallback = null)
{
// if we end up needing to make an HTTP request to retrieve credentials, we
// can use our existing one, but we need to throw exceptions so the error
// bubbles up.
$authHttp = $this->createAuthHttp($http);
$authHttpHandler = HttpHandlerFactory::build($authHttp);
$middleware = new AuthTokenMiddleware($credentials, $authHttpHandler, $tokenCallback);
$config = $http->getConfig();
$config['handler']->remove('google_auth');
$config['handler']->push($middleware, 'google_auth');
$config['auth'] = 'google_auth';
$http = new Client($config);
return $http;
}
public function attachToken(ClientInterface $http, array $token, array $scopes)
{
$tokenFunc = function ($scopes) use($token) {
return $token['access_token'];
};
$middleware = new ScopedAccessTokenMiddleware($tokenFunc, $scopes, $this->cacheConfig, $this->cache);
$config = $http->getConfig();
$config['handler']->remove('google_auth');
$config['handler']->push($middleware, 'google_auth');
$config['auth'] = 'scoped';
$http = new Client($config);
return $http;
}
public function attachKey(ClientInterface $http, $key)
{
$middleware = new SimpleMiddleware(['key' => $key]);
$config = $http->getConfig();
$config['handler']->remove('google_auth');
$config['handler']->push($middleware, 'google_auth');
$config['auth'] = 'simple';
$http = new Client($config);
return $http;
}
private function createAuthHttp(ClientInterface $http)
{
return new Client(['http_errors' => \true] + $http->getConfig());
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\AuthHandler;
/**
* This supports Guzzle 7
*/
class Guzzle7AuthHandler extends Guzzle6AuthHandler
{
}

View File

@@ -0,0 +1,103 @@
<?php
namespace VendorDuplicator\Google;
/**
* Extension to the regular Google\Model that automatically
* exposes the items array for iteration, so you can just
* iterate over the object rather than a reference inside.
*/
class Collection extends Model implements \Iterator, \Countable
{
protected $collection_key = 'items';
/** @return void */
#[\ReturnTypeWillChange]
public function rewind()
{
if (isset($this->{$this->collection_key}) && \is_array($this->{$this->collection_key})) {
\reset($this->{$this->collection_key});
}
}
/** @return mixed */
#[\ReturnTypeWillChange]
public function current()
{
$this->coerceType($this->key());
if (\is_array($this->{$this->collection_key})) {
return \current($this->{$this->collection_key});
}
}
/** @return mixed */
#[\ReturnTypeWillChange]
public function key()
{
if (isset($this->{$this->collection_key}) && \is_array($this->{$this->collection_key})) {
return \key($this->{$this->collection_key});
}
}
/** @return mixed */
#[\ReturnTypeWillChange]
public function next()
{
return \next($this->{$this->collection_key});
}
/** @return bool */
#[\ReturnTypeWillChange]
public function valid()
{
$key = $this->key();
return $key !== null && $key !== \false;
}
/** @return int */
#[\ReturnTypeWillChange]
public function count()
{
if (!isset($this->{$this->collection_key})) {
return 0;
}
return \count($this->{$this->collection_key});
}
/** @return bool */
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
if (!\is_numeric($offset)) {
return parent::offsetExists($offset);
}
return isset($this->{$this->collection_key}[$offset]);
}
/** @return mixed */
public function offsetGet($offset)
{
if (!\is_numeric($offset)) {
return parent::offsetGet($offset);
}
$this->coerceType($offset);
return $this->{$this->collection_key}[$offset];
}
/** @return void */
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (!\is_numeric($offset)) {
parent::offsetSet($offset, $value);
}
$this->{$this->collection_key}[$offset] = $value;
}
/** @return void */
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
if (!\is_numeric($offset)) {
parent::offsetUnset($offset);
}
unset($this->{$this->collection_key}[$offset]);
}
private function coerceType($offset)
{
$keyType = $this->keyType($this->collection_key);
if ($keyType && !\is_object($this->{$this->collection_key}[$offset])) {
$this->{$this->collection_key}[$offset] = new $keyType($this->{$this->collection_key}[$offset]);
}
}
}

View File

@@ -0,0 +1,23 @@
<?php
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google;
use Exception as BaseException;
class Exception extends BaseException
{
}

View File

@@ -0,0 +1,190 @@
<?php
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Http;
use VendorDuplicator\Google\Client;
use VendorDuplicator\Google\Service\Exception as GoogleServiceException;
use VendorDuplicator\GuzzleHttp\Psr7;
use VendorDuplicator\GuzzleHttp\Psr7\Request;
use VendorDuplicator\GuzzleHttp\Psr7\Response;
use VendorDuplicator\Psr\Http\Message\RequestInterface;
use VendorDuplicator\Psr\Http\Message\ResponseInterface;
/**
* Class to handle batched requests to the Google API service.
*
* Note that calls to `Google\Http\Batch::execute()` do not clear the queued
* requests. To start a new batch, be sure to create a new instance of this
* class.
*/
class Batch
{
const BATCH_PATH = 'batch';
private static $CONNECTION_ESTABLISHED_HEADERS = ["HTTP/1.0 200 Connection established\r\n\r\n", "HTTP/1.1 200 Connection established\r\n\r\n"];
/** @var string Multipart Boundary. */
private $boundary;
/** @var array service requests to be executed. */
private $requests = [];
/** @var Client */
private $client;
private $rootUrl;
private $batchPath;
public function __construct(Client $client, $boundary = \false, $rootUrl = null, $batchPath = null)
{
$this->client = $client;
$this->boundary = $boundary ?: \mt_rand();
$this->rootUrl = \rtrim($rootUrl ?: $this->client->getConfig('base_path'), '/');
$this->batchPath = $batchPath ?: self::BATCH_PATH;
}
public function add(RequestInterface $request, $key = \false)
{
if (\false == $key) {
$key = \mt_rand();
}
$this->requests[$key] = $request;
}
public function execute()
{
$body = '';
$classes = [];
$batchHttpTemplate = <<<EOF
--%s
Content-Type: application/http
Content-Transfer-Encoding: binary
MIME-Version: 1.0
Content-ID: %s
%s
%s%s
EOF;
/** @var RequestInterface $request */
foreach ($this->requests as $key => $request) {
$firstLine = \sprintf('%s %s HTTP/%s', $request->getMethod(), $request->getRequestTarget(), $request->getProtocolVersion());
$content = (string) $request->getBody();
$headers = '';
foreach ($request->getHeaders() as $name => $values) {
$headers .= \sprintf("%s:%s\r\n", $name, \implode(', ', $values));
}
$body .= \sprintf($batchHttpTemplate, $this->boundary, $key, $firstLine, $headers, $content ? "\n" . $content : '');
$classes['response-' . $key] = $request->getHeaderLine('X-Php-Expected-Class');
}
$body .= "--{$this->boundary}--";
$body = \trim($body);
$url = $this->rootUrl . '/' . $this->batchPath;
$headers = ['Content-Type' => \sprintf('multipart/mixed; boundary=%s', $this->boundary), 'Content-Length' => (string) \strlen($body)];
$request = new Request('POST', $url, $headers, $body);
$response = $this->client->execute($request);
return $this->parseResponse($response, $classes);
}
public function parseResponse(ResponseInterface $response, $classes = [])
{
$contentType = $response->getHeaderLine('content-type');
$contentType = \explode(';', $contentType);
$boundary = \false;
foreach ($contentType as $part) {
$part = \explode('=', $part, 2);
if (isset($part[0]) && 'boundary' == \trim($part[0])) {
$boundary = $part[1];
}
}
$body = (string) $response->getBody();
if (!empty($body)) {
$body = \str_replace("--{$boundary}--", "--{$boundary}", $body);
$parts = \explode("--{$boundary}", $body);
$responses = [];
$requests = \array_values($this->requests);
foreach ($parts as $i => $part) {
$part = \trim($part);
if (!empty($part)) {
list($rawHeaders, $part) = \explode("\r\n\r\n", $part, 2);
$headers = $this->parseRawHeaders($rawHeaders);
$status = \substr($part, 0, \strpos($part, "\n"));
$status = \explode(" ", $status);
$status = $status[1];
list($partHeaders, $partBody) = $this->parseHttpResponse($part, 0);
$response = new Response((int) $status, $partHeaders, Psr7\Utils::streamFor($partBody));
// Need content id.
$key = $headers['content-id'];
try {
$response = REST::decodeHttpResponse($response, $requests[$i - 1]);
} catch (GoogleServiceException $e) {
// Store the exception as the response, so successful responses
// can be processed.
$response = $e;
}
$responses[$key] = $response;
}
}
return $responses;
}
return null;
}
private function parseRawHeaders($rawHeaders)
{
$headers = [];
$responseHeaderLines = \explode("\r\n", $rawHeaders);
foreach ($responseHeaderLines as $headerLine) {
if ($headerLine && \strpos($headerLine, ':') !== \false) {
list($header, $value) = \explode(': ', $headerLine, 2);
$header = \strtolower($header);
if (isset($headers[$header])) {
$headers[$header] = \array_merge((array) $headers[$header], (array) $value);
} else {
$headers[$header] = $value;
}
}
}
return $headers;
}
/**
* Used by the IO lib and also the batch processing.
*
* @param string $respData
* @param int $headerSize
* @return array
*/
private function parseHttpResponse($respData, $headerSize)
{
// check proxy header
foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
if (\stripos($respData, $established_header) !== \false) {
// existed, remove it
$respData = \str_ireplace($established_header, '', $respData);
// Subtract the proxy header size unless the cURL bug prior to 7.30.0
// is present which prevented the proxy header size from being taken into
// account.
// @TODO look into this
// if (!$this->needsQuirk()) {
// $headerSize -= strlen($established_header);
// }
break;
}
}
if ($headerSize) {
$responseBody = \substr($respData, $headerSize);
$responseHeaders = \substr($respData, 0, $headerSize);
} else {
$responseSegments = \explode("\r\n\r\n", $respData, 2);
$responseHeaders = $responseSegments[0];
$responseBody = isset($responseSegments[1]) ? $responseSegments[1] : null;
}
$responseHeaders = $this->parseRawHeaders($responseHeaders);
return [$responseHeaders, $responseBody];
}
}

View File

@@ -0,0 +1,273 @@
<?php
/**
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Http;
use VendorDuplicator\Google\Client;
use VendorDuplicator\Google\Exception as GoogleException;
use VendorDuplicator\GuzzleHttp\Psr7;
use VendorDuplicator\GuzzleHttp\Psr7\Request;
use VendorDuplicator\GuzzleHttp\Psr7\Uri;
use VendorDuplicator\Psr\Http\Message\RequestInterface;
/**
* Manage large file uploads, which may be media but can be any type
* of sizable data.
*/
class MediaFileUpload
{
const UPLOAD_MEDIA_TYPE = 'media';
const UPLOAD_MULTIPART_TYPE = 'multipart';
const UPLOAD_RESUMABLE_TYPE = 'resumable';
/** @var string $mimeType */
private $mimeType;
/** @var string $data */
private $data;
/** @var bool $resumable */
private $resumable;
/** @var int $chunkSize */
private $chunkSize;
/** @var int $size */
private $size;
/** @var string $resumeUri */
private $resumeUri;
/** @var int $progress */
private $progress;
/** @var Client */
private $client;
/** @var RequestInterface */
private $request;
/** @var string */
private $boundary;
// @phpstan-ignore-line
/**
* Result code from last HTTP call
* @var int
*/
private $httpResultCode;
/**
* @param Client $client
* @param RequestInterface $request
* @param string $mimeType
* @param string $data The bytes you want to upload.
* @param bool $resumable
* @param int $chunkSize File will be uploaded in chunks of this many bytes.
* only used if resumable=True
*/
public function __construct(Client $client, RequestInterface $request, $mimeType, $data, $resumable = \false, $chunkSize = 0)
{
$this->client = $client;
$this->request = $request;
$this->mimeType = $mimeType;
$this->data = $data;
$this->resumable = $resumable;
$this->chunkSize = $chunkSize;
$this->progress = 0;
$this->process();
}
/**
* Set the size of the file that is being uploaded.
* @param int $size - int file size in bytes
*/
public function setFileSize($size)
{
$this->size = $size;
}
/**
* Return the progress on the upload
* @return int progress in bytes uploaded.
*/
public function getProgress()
{
return $this->progress;
}
/**
* Send the next part of the file to upload.
* @param string|bool $chunk Optional. The next set of bytes to send. If false will
* use $data passed at construct time.
*/
public function nextChunk($chunk = \false)
{
$resumeUri = $this->getResumeUri();
if (\false == $chunk) {
$chunk = \substr($this->data, $this->progress, $this->chunkSize);
}
$lastBytePos = $this->progress + \strlen($chunk) - 1;
$headers = ['content-range' => "bytes {$this->progress}-{$lastBytePos}/{$this->size}", 'content-length' => (string) \strlen($chunk), 'expect' => ''];
$request = new Request('PUT', $resumeUri, $headers, Psr7\Utils::streamFor($chunk));
return $this->makePutRequest($request);
}
/**
* Return the HTTP result code from the last call made.
* @return int code
*/
public function getHttpResultCode()
{
return $this->httpResultCode;
}
/**
* Sends a PUT-Request to google drive and parses the response,
* setting the appropiate variables from the response()
*
* @param RequestInterface $request the Request which will be send
*
* @return false|mixed false when the upload is unfinished or the decoded http response
*
*/
private function makePutRequest(RequestInterface $request)
{
$response = $this->client->execute($request);
$this->httpResultCode = $response->getStatusCode();
if (308 == $this->httpResultCode) {
// Track the amount uploaded.
$range = $response->getHeaderLine('range');
if ($range) {
$range_array = \explode('-', $range);
$this->progress = (int) $range_array[1] + 1;
}
// Allow for changing upload URLs.
$location = $response->getHeaderLine('location');
if ($location) {
$this->resumeUri = $location;
}
// No problems, but upload not complete.
return \false;
}
return REST::decodeHttpResponse($response, $this->request);
}
/**
* Resume a previously unfinished upload
* @param string $resumeUri the resume-URI of the unfinished, resumable upload.
*/
public function resume($resumeUri)
{
$this->resumeUri = $resumeUri;
$headers = ['content-range' => "bytes */{$this->size}", 'content-length' => '0'];
$httpRequest = new Request('PUT', $this->resumeUri, $headers);
return $this->makePutRequest($httpRequest);
}
/**
* @return RequestInterface
* @visible for testing
*/
private function process()
{
$this->transformToUploadUrl();
$request = $this->request;
$postBody = '';
$contentType = \false;
$meta = \json_decode((string) $request->getBody(), \true);
$uploadType = $this->getUploadType($meta);
$request = $request->withUri(Uri::withQueryValue($request->getUri(), 'uploadType', $uploadType));
$mimeType = $this->mimeType ?: $request->getHeaderLine('content-type');
if (self::UPLOAD_RESUMABLE_TYPE == $uploadType) {
$contentType = $mimeType;
$postBody = \is_string($meta) ? $meta : \json_encode($meta);
} elseif (self::UPLOAD_MEDIA_TYPE == $uploadType) {
$contentType = $mimeType;
$postBody = $this->data;
} elseif (self::UPLOAD_MULTIPART_TYPE == $uploadType) {
// This is a multipart/related upload.
$boundary = $this->boundary ?: \mt_rand();
$boundary = \str_replace('"', '', $boundary);
$contentType = 'multipart/related; boundary=' . $boundary;
$related = "--{$boundary}\r\n";
$related .= "Content-Type: application/json; charset=UTF-8\r\n";
$related .= "\r\n" . \json_encode($meta) . "\r\n";
$related .= "--{$boundary}\r\n";
$related .= "Content-Type: {$mimeType}\r\n";
$related .= "Content-Transfer-Encoding: base64\r\n";
$related .= "\r\n" . \base64_encode($this->data) . "\r\n";
$related .= "--{$boundary}--";
$postBody = $related;
}
$request = $request->withBody(Psr7\Utils::streamFor($postBody));
if ($contentType) {
$request = $request->withHeader('content-type', $contentType);
}
return $this->request = $request;
}
/**
* Valid upload types:
* - resumable (UPLOAD_RESUMABLE_TYPE)
* - media (UPLOAD_MEDIA_TYPE)
* - multipart (UPLOAD_MULTIPART_TYPE)
* @param string|false $meta
* @return string
* @visible for testing
*/
public function getUploadType($meta)
{
if ($this->resumable) {
return self::UPLOAD_RESUMABLE_TYPE;
}
if (\false == $meta && $this->data) {
return self::UPLOAD_MEDIA_TYPE;
}
return self::UPLOAD_MULTIPART_TYPE;
}
public function getResumeUri()
{
if (null === $this->resumeUri) {
$this->resumeUri = $this->fetchResumeUri();
}
return $this->resumeUri;
}
private function fetchResumeUri()
{
$body = $this->request->getBody();
$headers = ['content-type' => 'application/json; charset=UTF-8', 'content-length' => $body->getSize(), 'x-upload-content-type' => $this->mimeType, 'x-upload-content-length' => $this->size, 'expect' => ''];
foreach ($headers as $key => $value) {
$this->request = $this->request->withHeader($key, $value);
}
$response = $this->client->execute($this->request, \false);
$location = $response->getHeaderLine('location');
$code = $response->getStatusCode();
if (200 == $code && \true == $location) {
return $location;
}
$message = $code;
$body = \json_decode((string) $this->request->getBody(), \true);
if (isset($body['error']['errors'])) {
$message .= ': ';
foreach ($body['error']['errors'] as $error) {
$message .= "{$error['domain']}, {$error['message']};";
}
$message = \rtrim($message, ';');
}
$error = "Failed to start the resumable upload (HTTP {$message})";
$this->client->getLogger()->error($error);
throw new GoogleException($error);
}
private function transformToUploadUrl()
{
$parts = \parse_url((string) $this->request->getUri());
if (!isset($parts['path'])) {
$parts['path'] = '';
}
$parts['path'] = '/upload' . $parts['path'];
$uri = Uri::fromParts($parts);
$this->request = $this->request->withUri($uri);
}
public function setChunkSize($chunkSize)
{
$this->chunkSize = $chunkSize;
}
public function getRequest()
{
return $this->request;
}
}

View File

@@ -0,0 +1,153 @@
<?php
/*
* Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Http;
use VendorDuplicator\Google\Auth\HttpHandler\HttpHandlerFactory;
use VendorDuplicator\Google\Service\Exception as GoogleServiceException;
use VendorDuplicator\Google\Task\Runner;
use VendorDuplicator\GuzzleHttp\ClientInterface;
use VendorDuplicator\GuzzleHttp\Exception\RequestException;
use VendorDuplicator\GuzzleHttp\Psr7\Response;
use VendorDuplicator\Psr\Http\Message\RequestInterface;
use VendorDuplicator\Psr\Http\Message\ResponseInterface;
/**
* This class implements the RESTful transport of apiServiceRequest()'s
*/
class REST
{
/**
* Executes a Psr\Http\Message\RequestInterface and (if applicable) automatically retries
* when errors occur.
*
* @template T
* @param ClientInterface $client
* @param RequestInterface $request
* @param class-string<T>|false|null $expectedClass
* @param array $config
* @param array $retryMap
* @return mixed|T|null
* @throws \VendorDuplicator\Google\Service\Exception on server side error (ie: not authenticated,
* invalid or malformed post body, invalid url)
*/
public static function execute(ClientInterface $client, RequestInterface $request, $expectedClass = null, $config = [], $retryMap = null)
{
$runner = new Runner($config, \sprintf('%s %s', $request->getMethod(), (string) $request->getUri()), [__CLASS__, 'doExecute'], [$client, $request, $expectedClass]);
if (null !== $retryMap) {
$runner->setRetryMap($retryMap);
}
return $runner->run();
}
/**
* Executes a Psr\Http\Message\RequestInterface
*
* @template T
* @param ClientInterface $client
* @param RequestInterface $request
* @param class-string<T>|false|null $expectedClass
* @return mixed|T|null
* @throws \VendorDuplicator\Google\Service\Exception on server side error (ie: not authenticated,
* invalid or malformed post body, invalid url)
*/
public static function doExecute(ClientInterface $client, RequestInterface $request, $expectedClass = null)
{
try {
$httpHandler = HttpHandlerFactory::build($client);
$response = $httpHandler($request);
} catch (RequestException $e) {
// if Guzzle throws an exception, catch it and handle the response
if (!$e->hasResponse()) {
throw $e;
}
$response = $e->getResponse();
// specific checking for Guzzle 5: convert to PSR7 response
if (\interface_exists('VendorDuplicator\\GuzzleHttp\\Message\\ResponseInterface') && $response instanceof \VendorDuplicator\GuzzleHttp\Message\ResponseInterface) {
$response = new Response($response->getStatusCode(), $response->getHeaders() ?: [], $response->getBody(), $response->getProtocolVersion(), $response->getReasonPhrase());
}
}
return self::decodeHttpResponse($response, $request, $expectedClass);
}
/**
* Decode an HTTP Response.
* @static
*
* @template T
* @param RequestInterface $response The http response to be decoded.
* @param ResponseInterface $response
* @param class-string<T>|false|null $expectedClass
* @return mixed|T|null
* @throws \VendorDuplicator\Google\Service\Exception
*/
public static function decodeHttpResponse(ResponseInterface $response, RequestInterface $request = null, $expectedClass = null)
{
$code = $response->getStatusCode();
// retry strategy
if (\intVal($code) >= 400) {
// if we errored out, it should be safe to grab the response body
$body = (string) $response->getBody();
// Check if we received errors, and add those to the Exception for convenience
throw new GoogleServiceException($body, $code, null, self::getResponseErrors($body));
}
// Ensure we only pull the entire body into memory if the request is not
// of media type
$body = self::decodeBody($response, $request);
if ($expectedClass = self::determineExpectedClass($expectedClass, $request)) {
$json = \json_decode($body, \true);
return new $expectedClass($json);
}
return $response;
}
private static function decodeBody(ResponseInterface $response, RequestInterface $request = null)
{
if (self::isAltMedia($request)) {
// don't decode the body, it's probably a really long string
return '';
}
return (string) $response->getBody();
}
private static function determineExpectedClass($expectedClass, RequestInterface $request = null)
{
// "false" is used to explicitly prevent an expected class from being returned
if (\false === $expectedClass) {
return null;
}
// if we don't have a request, we just use what's passed in
if (null === $request) {
return $expectedClass;
}
// return what we have in the request header if one was not supplied
return $expectedClass ?: $request->getHeaderLine('X-Php-Expected-Class');
}
private static function getResponseErrors($body)
{
$json = \json_decode($body, \true);
if (isset($json['error']['errors'])) {
return $json['error']['errors'];
}
return null;
}
private static function isAltMedia(RequestInterface $request = null)
{
if ($request && ($qs = $request->getUri()->getQuery())) {
\parse_str($qs, $query);
if (isset($query['alt']) && $query['alt'] == 'media') {
return \true;
}
}
return \false;
}
}

View File

@@ -0,0 +1,301 @@
<?php
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google;
use VendorDuplicator\Google\Exception as GoogleException;
use ReflectionObject;
use ReflectionProperty;
use stdClass;
/**
* This class defines attributes, valid values, and usage which is generated
* from a given json schema.
* http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5
*
*/
#[\AllowDynamicProperties]
class Model implements \ArrayAccess
{
/**
* If you need to specify a NULL JSON value, use Google\Model::NULL_VALUE
* instead - it will be replaced when converting to JSON with a real null.
*/
const NULL_VALUE = "{}gapi-php-null";
protected $internal_gapi_mappings = [];
protected $modelData = [];
protected $processed = [];
/**
* Polymorphic - accepts a variable number of arguments dependent
* on the type of the model subclass.
*/
public final function __construct()
{
if (\func_num_args() == 1 && \is_array(\func_get_arg(0))) {
// Initialize the model with the array's contents.
$array = \func_get_arg(0);
$this->mapTypes($array);
}
$this->gapiInit();
}
/**
* Getter that handles passthrough access to the data array, and lazy object creation.
* @param string $key Property name.
* @return mixed The value if any, or null.
*/
public function __get($key)
{
$keyType = $this->keyType($key);
$keyDataType = $this->dataType($key);
if ($keyType && !isset($this->processed[$key])) {
if (isset($this->modelData[$key])) {
$val = $this->modelData[$key];
} elseif ($keyDataType == 'array' || $keyDataType == 'map') {
$val = [];
} else {
$val = null;
}
if ($this->isAssociativeArray($val)) {
if ($keyDataType && 'map' == $keyDataType) {
foreach ($val as $arrayKey => $arrayItem) {
$this->modelData[$key][$arrayKey] = new $keyType($arrayItem);
}
} else {
$this->modelData[$key] = new $keyType($val);
}
} elseif (\is_array($val)) {
$arrayObject = [];
foreach ($val as $arrayIndex => $arrayItem) {
$arrayObject[$arrayIndex] = new $keyType($arrayItem);
}
$this->modelData[$key] = $arrayObject;
}
$this->processed[$key] = \true;
}
return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
}
/**
* Initialize this object's properties from an array.
*
* @param array $array Used to seed this object's properties.
* @return void
*/
protected function mapTypes($array)
{
// Hard initialise simple types, lazy load more complex ones.
foreach ($array as $key => $val) {
if ($keyType = $this->keyType($key)) {
$dataType = $this->dataType($key);
if ($dataType == 'array' || $dataType == 'map') {
$this->{$key} = [];
foreach ($val as $itemKey => $itemVal) {
if ($itemVal instanceof $keyType) {
$this->{$key}[$itemKey] = $itemVal;
} else {
$this->{$key}[$itemKey] = new $keyType($itemVal);
}
}
} elseif ($val instanceof $keyType) {
$this->{$key} = $val;
} else {
$this->{$key} = new $keyType($val);
}
unset($array[$key]);
} elseif (\property_exists($this, $key)) {
$this->{$key} = $val;
unset($array[$key]);
} elseif (\property_exists($this, $camelKey = $this->camelCase($key))) {
// This checks if property exists as camelCase, leaving it in array as snake_case
// in case of backwards compatibility issues.
$this->{$camelKey} = $val;
}
}
$this->modelData = $array;
}
/**
* Blank initialiser to be used in subclasses to do post-construction initialisation - this
* avoids the need for subclasses to have to implement the variadics handling in their
* constructors.
*/
protected function gapiInit()
{
return;
}
/**
* Create a simplified object suitable for straightforward
* conversion to JSON. This is relatively expensive
* due to the usage of reflection, but shouldn't be called
* a whole lot, and is the most straightforward way to filter.
*/
public function toSimpleObject()
{
$object = new stdClass();
// Process all other data.
foreach ($this->modelData as $key => $val) {
$result = $this->getSimpleValue($val);
if ($result !== null) {
$object->{$key} = $this->nullPlaceholderCheck($result);
}
}
// Process all public properties.
$reflect = new ReflectionObject($this);
$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
foreach ($props as $member) {
$name = $member->getName();
$result = $this->getSimpleValue($this->{$name});
if ($result !== null) {
$name = $this->getMappedName($name);
$object->{$name} = $this->nullPlaceholderCheck($result);
}
}
return $object;
}
/**
* Handle different types of values, primarily
* other objects and map and array data types.
*/
private function getSimpleValue($value)
{
if ($value instanceof Model) {
return $value->toSimpleObject();
} elseif (\is_array($value)) {
$return = [];
foreach ($value as $key => $a_value) {
$a_value = $this->getSimpleValue($a_value);
if ($a_value !== null) {
$key = $this->getMappedName($key);
$return[$key] = $this->nullPlaceholderCheck($a_value);
}
}
return $return;
}
return $value;
}
/**
* Check whether the value is the null placeholder and return true null.
*/
private function nullPlaceholderCheck($value)
{
if ($value === self::NULL_VALUE) {
return null;
}
return $value;
}
/**
* If there is an internal name mapping, use that.
*/
private function getMappedName($key)
{
if (isset($this->internal_gapi_mappings, $this->internal_gapi_mappings[$key])) {
$key = $this->internal_gapi_mappings[$key];
}
return $key;
}
/**
* Returns true only if the array is associative.
* @param array $array
* @return bool True if the array is associative.
*/
protected function isAssociativeArray($array)
{
if (!\is_array($array)) {
return \false;
}
$keys = \array_keys($array);
foreach ($keys as $key) {
if (\is_string($key)) {
return \true;
}
}
return \false;
}
/**
* Verify if $obj is an array.
* @throws \VendorDuplicator\Google\Exception Thrown if $obj isn't an array.
* @param array $obj Items that should be validated.
* @param string $method Method expecting an array as an argument.
*/
public function assertIsArray($obj, $method)
{
if ($obj && !\is_array($obj)) {
throw new GoogleException("Incorrect parameter type passed to {$method}(). Expected an array.");
}
}
/** @return bool */
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->{$offset}) || isset($this->modelData[$offset]);
}
/** @return mixed */
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return isset($this->{$offset}) ? $this->{$offset} : $this->__get($offset);
}
/** @return void */
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (\property_exists($this, $offset)) {
$this->{$offset} = $value;
} else {
$this->modelData[$offset] = $value;
$this->processed[$offset] = \true;
}
}
/** @return void */
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->modelData[$offset]);
}
protected function keyType($key)
{
$keyType = $key . "Type";
// ensure keyType is a valid class
if (\property_exists($this, $keyType) && $this->{$keyType} !== null && \class_exists($this->{$keyType})) {
return $this->{$keyType};
}
}
protected function dataType($key)
{
$dataType = $key . "DataType";
if (\property_exists($this, $dataType)) {
return $this->{$dataType};
}
}
public function __isset($key)
{
return isset($this->modelData[$key]);
}
public function __unset($key)
{
unset($this->modelData[$key]);
}
/**
* Convert a string to camelCase
* @param string $value
* @return string
*/
private function camelCase($value)
{
$value = \ucwords(\str_replace(['-', '_'], ' ', $value));
$value = \str_replace(' ', '', $value);
$value[0] = \strtolower($value[0]);
return $value;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/*
* Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google;
use VendorDuplicator\Google\Http\Batch;
use TypeError;
class Service
{
public $batchPath;
public $rootUrl;
public $version;
public $servicePath;
public $serviceName;
public $availableScopes;
public $resource;
private $client;
public function __construct($clientOrConfig = [])
{
if ($clientOrConfig instanceof Client) {
$this->client = $clientOrConfig;
} elseif (\is_array($clientOrConfig)) {
$this->client = new Client($clientOrConfig ?: []);
} else {
$errorMessage = 'constructor must be array or instance of Google\\Client';
if (\class_exists('TypeError')) {
throw new TypeError($errorMessage);
}
\trigger_error($errorMessage, \E_USER_ERROR);
}
}
/**
* Return the associated Google\Client class.
* @return \VendorDuplicator\Google\Client
*/
public function getClient()
{
return $this->client;
}
/**
* Create a new HTTP Batch handler for this service
*
* @return Batch
*/
public function createBatch()
{
return new Batch($this->client, \false, $this->rootUrl, $this->batchPath);
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Service;
use VendorDuplicator\Google\Exception as GoogleException;
class Exception extends GoogleException
{
/**
* Optional list of errors returned in a JSON body of an HTTP error response.
*/
protected $errors = [];
/**
* Override default constructor to add the ability to set $errors and a retry
* map.
*
* @param string $message
* @param int $code
* @param Exception|null $previous
* @param array<array<string,string>>|null $errors List of errors returned in an HTTP
* response or null. Defaults to [].
*/
public function __construct($message, $code = 0, Exception $previous = null, $errors = [])
{
if (\version_compare(\PHP_VERSION, '5.3.0') >= 0) {
parent::__construct($message, $code, $previous);
} else {
parent::__construct($message, $code);
}
$this->errors = $errors;
}
/**
* An example of the possible errors returned.
*
* [
* {
* "domain": "global",
* "reason": "authError",
* "message": "Invalid Credentials",
* "locationType": "header",
* "location": "Authorization",
* }
* ]
*
* @return array<array<string,string>>|null List of errors returned in an HTTP response or null.
*/
public function getErrors()
{
return $this->errors;
}
}

View File

@@ -0,0 +1,214 @@
<?php
/**
* Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Service;
use VendorDuplicator\Google\Exception as GoogleException;
use VendorDuplicator\Google\Http\MediaFileUpload;
use VendorDuplicator\Google\Model;
use VendorDuplicator\Google\Utils\UriTemplate;
use VendorDuplicator\GuzzleHttp\Psr7\Request;
/**
* Implements the actual methods/resources of the discovered Google API using magic function
* calling overloading (__call()), which on call will see if the method name (plus.activities.list)
* is available in this service, and if so construct an apiHttpRequest representing it.
*
*/
class Resource
{
// Valid query parameters that work, but don't appear in discovery.
private $stackParameters = ['alt' => ['type' => 'string', 'location' => 'query'], 'fields' => ['type' => 'string', 'location' => 'query'], 'trace' => ['type' => 'string', 'location' => 'query'], 'userIp' => ['type' => 'string', 'location' => 'query'], 'quotaUser' => ['type' => 'string', 'location' => 'query'], 'data' => ['type' => 'string', 'location' => 'body'], 'mimeType' => ['type' => 'string', 'location' => 'header'], 'uploadType' => ['type' => 'string', 'location' => 'query'], 'mediaUpload' => ['type' => 'complex', 'location' => 'query'], 'prettyPrint' => ['type' => 'string', 'location' => 'query']];
/** @var string $rootUrl */
private $rootUrl;
/** @var \VendorDuplicator\Google\Client $client */
private $client;
/** @var string $serviceName */
private $serviceName;
/** @var string $servicePath */
private $servicePath;
/** @var string $resourceName */
private $resourceName;
/** @var array $methods */
private $methods;
public function __construct($service, $serviceName, $resourceName, $resource)
{
$this->rootUrl = $service->rootUrl;
$this->client = $service->getClient();
$this->servicePath = $service->servicePath;
$this->serviceName = $serviceName;
$this->resourceName = $resourceName;
$this->methods = \is_array($resource) && isset($resource['methods']) ? $resource['methods'] : [$resourceName => $resource];
}
/**
* TODO: This function needs simplifying.
*
* @template T
* @param string $name
* @param array $arguments
* @param class-string<T> $expectedClass - optional, the expected class name
* @return mixed|T|ResponseInterface|RequestInterface
* @throws \VendorDuplicator\Google\Exception
*/
public function call($name, $arguments, $expectedClass = null)
{
if (!isset($this->methods[$name])) {
$this->client->getLogger()->error('Service method unknown', ['service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name]);
throw new GoogleException("Unknown function: " . "{$this->serviceName}->{$this->resourceName}->{$name}()");
}
$method = $this->methods[$name];
$parameters = $arguments[0];
// postBody is a special case since it's not defined in the discovery
// document as parameter, but we abuse the param entry for storing it.
$postBody = null;
if (isset($parameters['postBody'])) {
if ($parameters['postBody'] instanceof Model) {
// In the cases the post body is an existing object, we want
// to use the smart method to create a simple object for
// for JSONification.
$parameters['postBody'] = $parameters['postBody']->toSimpleObject();
} elseif (\is_object($parameters['postBody'])) {
// If the post body is another kind of object, we will try and
// wrangle it into a sensible format.
$parameters['postBody'] = $this->convertToArrayAndStripNulls($parameters['postBody']);
}
$postBody = (array) $parameters['postBody'];
unset($parameters['postBody']);
}
// TODO: optParams here probably should have been
// handled already - this may well be redundant code.
if (isset($parameters['optParams'])) {
$optParams = $parameters['optParams'];
unset($parameters['optParams']);
$parameters = \array_merge($parameters, $optParams);
}
if (!isset($method['parameters'])) {
$method['parameters'] = [];
}
$method['parameters'] = \array_merge($this->stackParameters, $method['parameters']);
foreach ($parameters as $key => $val) {
if ($key != 'postBody' && !isset($method['parameters'][$key])) {
$this->client->getLogger()->error('Service parameter unknown', ['service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name, 'parameter' => $key]);
throw new GoogleException("({$name}) unknown parameter: '{$key}'");
}
}
foreach ($method['parameters'] as $paramName => $paramSpec) {
if (isset($paramSpec['required']) && $paramSpec['required'] && !isset($parameters[$paramName])) {
$this->client->getLogger()->error('Service parameter missing', ['service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name, 'parameter' => $paramName]);
throw new GoogleException("({$name}) missing required param: '{$paramName}'");
}
if (isset($parameters[$paramName])) {
$value = $parameters[$paramName];
$parameters[$paramName] = $paramSpec;
$parameters[$paramName]['value'] = $value;
unset($parameters[$paramName]['required']);
} else {
// Ensure we don't pass nulls.
unset($parameters[$paramName]);
}
}
$this->client->getLogger()->info('Service Call', ['service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name, 'arguments' => $parameters]);
// build the service uri
$url = $this->createRequestUri($method['path'], $parameters);
// NOTE: because we're creating the request by hand,
// and because the service has a rootUrl property
// the "base_uri" of the Http Client is not accounted for
$request = new Request($method['httpMethod'], $url, $postBody ? ['content-type' => 'application/json'] : [], $postBody ? \json_encode($postBody) : '');
// support uploads
if (isset($parameters['data'])) {
$mimeType = isset($parameters['mimeType']) ? $parameters['mimeType']['value'] : 'application/octet-stream';
$data = $parameters['data']['value'];
$upload = new MediaFileUpload($this->client, $request, $mimeType, $data);
// pull down the modified request
$request = $upload->getRequest();
}
// if this is a media type, we will return the raw response
// rather than using an expected class
if (isset($parameters['alt']) && $parameters['alt']['value'] == 'media') {
$expectedClass = null;
}
// if the client is marked for deferring, rather than
// execute the request, return the response
if ($this->client->shouldDefer()) {
// @TODO find a better way to do this
$request = $request->withHeader('X-Php-Expected-Class', $expectedClass);
return $request;
}
return $this->client->execute($request, $expectedClass);
}
protected function convertToArrayAndStripNulls($o)
{
$o = (array) $o;
foreach ($o as $k => $v) {
if ($v === null) {
unset($o[$k]);
} elseif (\is_object($v) || \is_array($v)) {
$o[$k] = $this->convertToArrayAndStripNulls($o[$k]);
}
}
return $o;
}
/**
* Parse/expand request parameters and create a fully qualified
* request uri.
* @static
* @param string $restPath
* @param array $params
* @return string $requestUrl
*/
public function createRequestUri($restPath, $params)
{
// Override the default servicePath address if the $restPath use a /
if ('/' == \substr($restPath, 0, 1)) {
$requestUrl = \substr($restPath, 1);
} else {
$requestUrl = $this->servicePath . $restPath;
}
// code for leading slash
if ($this->rootUrl) {
if ('/' !== \substr($this->rootUrl, -1) && '/' !== \substr($requestUrl, 0, 1)) {
$requestUrl = '/' . $requestUrl;
}
$requestUrl = $this->rootUrl . $requestUrl;
}
$uriTemplateVars = [];
$queryVars = [];
foreach ($params as $paramName => $paramSpec) {
if ($paramSpec['type'] == 'boolean') {
$paramSpec['value'] = $paramSpec['value'] ? 'true' : 'false';
}
if ($paramSpec['location'] == 'path') {
$uriTemplateVars[$paramName] = $paramSpec['value'];
} elseif ($paramSpec['location'] == 'query') {
if (\is_array($paramSpec['value'])) {
foreach ($paramSpec['value'] as $value) {
$queryVars[] = $paramName . '=' . \rawurlencode(\rawurldecode($value));
}
} else {
$queryVars[] = $paramName . '=' . \rawurlencode(\rawurldecode($paramSpec['value']));
}
}
}
if (\count($uriTemplateVars)) {
$uriTemplateParser = new UriTemplate();
$requestUrl = $uriTemplateParser->parse($requestUrl, $uriTemplateVars);
}
if (\count($queryVars)) {
$requestUrl .= '?' . \implode('&', $queryVars);
}
return $requestUrl;
}
}

View File

@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace VendorDuplicator\Google\Task;
use VendorDuplicator\Composer\Script\Event;
use InvalidArgumentException;
use VendorDuplicator\Symfony\Component\Filesystem\Filesystem;
use VendorDuplicator\Symfony\Component\Finder\Finder;
class Composer
{
/**
* @param Event $event Composer event passed in for any script method
* @param Filesystem $filesystem Optional. Used for testing.
*/
public static function cleanup(Event $event, Filesystem $filesystem = null)
{
$composer = $event->getComposer();
$extra = $composer->getPackage()->getExtra();
$servicesToKeep = isset($extra['google/apiclient-services']) ? $extra['google/apiclient-services'] : [];
if ($servicesToKeep) {
$vendorDir = $composer->getConfig()->get('vendor-dir');
$serviceDir = \sprintf('%s/google/apiclient-services/src/Google/Service', $vendorDir);
if (!\is_dir($serviceDir)) {
// path for google/apiclient-services >= 0.200.0
$serviceDir = \sprintf('%s/google/apiclient-services/src', $vendorDir);
}
self::verifyServicesToKeep($serviceDir, $servicesToKeep);
$finder = self::getServicesToRemove($serviceDir, $servicesToKeep);
$filesystem = $filesystem ?: new Filesystem();
if (0 !== ($count = \count($finder))) {
$event->getIO()->write(\sprintf('Removing %s google services', $count));
foreach ($finder as $file) {
$realpath = $file->getRealPath();
$filesystem->remove($realpath);
$filesystem->remove($realpath . '.php');
}
}
}
}
/**
* @throws InvalidArgumentException when the service doesn't exist
*/
private static function verifyServicesToKeep($serviceDir, array $servicesToKeep)
{
$finder = (new Finder())->directories()->depth('== 0');
foreach ($servicesToKeep as $service) {
if (!\preg_match('/^[a-zA-Z0-9]*$/', $service)) {
throw new InvalidArgumentException(\sprintf('Invalid Google service name "%s"', $service));
}
try {
$finder->in($serviceDir . '/' . $service);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(\sprintf('VendorDuplicator\\Google service "%s" does not exist or was removed previously', $service));
}
}
}
private static function getServicesToRemove($serviceDir, array $servicesToKeep)
{
// find all files in the current directory
return (new Finder())->directories()->depth('== 0')->in($serviceDir)->exclude($servicesToKeep);
}
}

View File

@@ -0,0 +1,23 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Task;
use VendorDuplicator\Google\Exception as GoogleException;
class Exception extends GoogleException
{
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Task;
/**
* Interface for checking how many times a given task can be retried following
* a failure.
*/
interface Retryable
{
}

View File

@@ -0,0 +1,235 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Task;
use VendorDuplicator\Google\Service\Exception as GoogleServiceException;
use VendorDuplicator\Google\Task\Exception as GoogleTaskException;
/**
* A task runner with exponential backoff support.
*
* @see https://developers.google.com/drive/web/handle-errors#implementing_exponential_backoff
*/
class Runner
{
const TASK_RETRY_NEVER = 0;
const TASK_RETRY_ONCE = 1;
const TASK_RETRY_ALWAYS = -1;
/**
* @var integer $maxDelay The max time (in seconds) to wait before a retry.
*/
private $maxDelay = 60;
/**
* @var integer $delay The previous delay from which the next is calculated.
*/
private $delay = 1;
/**
* @var integer $factor The base number for the exponential back off.
*/
private $factor = 2;
/**
* @var float $jitter A random number between -$jitter and $jitter will be
* added to $factor on each iteration to allow for a better distribution of
* retries.
*/
private $jitter = 0.5;
/**
* @var integer $attempts The number of attempts that have been tried so far.
*/
private $attempts = 0;
/**
* @var integer $maxAttempts The max number of attempts allowed.
*/
private $maxAttempts = 1;
/**
* @var callable $action The task to run and possibly retry.
*/
private $action;
/**
* @var array $arguments The task arguments.
*/
private $arguments;
/**
* @var array $retryMap Map of errors with retry counts.
*/
protected $retryMap = [
'500' => self::TASK_RETRY_ALWAYS,
'503' => self::TASK_RETRY_ALWAYS,
'rateLimitExceeded' => self::TASK_RETRY_ALWAYS,
'userRateLimitExceeded' => self::TASK_RETRY_ALWAYS,
6 => self::TASK_RETRY_ALWAYS,
// CURLE_COULDNT_RESOLVE_HOST
7 => self::TASK_RETRY_ALWAYS,
// CURLE_COULDNT_CONNECT
28 => self::TASK_RETRY_ALWAYS,
// CURLE_OPERATION_TIMEOUTED
35 => self::TASK_RETRY_ALWAYS,
// CURLE_SSL_CONNECT_ERROR
52 => self::TASK_RETRY_ALWAYS,
// CURLE_GOT_NOTHING
'lighthouseError' => self::TASK_RETRY_NEVER,
];
/**
* Creates a new task runner with exponential backoff support.
*
* @param array $config The task runner config
* @param string $name The name of the current task (used for logging)
* @param callable $action The task to run and possibly retry
* @param array $arguments The task arguments
* @throws \VendorDuplicator\Google\Task\Exception when misconfigured
*/
// @phpstan-ignore-next-line
public function __construct($config, $name, $action, array $arguments = [])
{
if (isset($config['initial_delay'])) {
if ($config['initial_delay'] < 0) {
throw new GoogleTaskException('Task configuration `initial_delay` must not be negative.');
}
$this->delay = $config['initial_delay'];
}
if (isset($config['max_delay'])) {
if ($config['max_delay'] <= 0) {
throw new GoogleTaskException('Task configuration `max_delay` must be greater than 0.');
}
$this->maxDelay = $config['max_delay'];
}
if (isset($config['factor'])) {
if ($config['factor'] <= 0) {
throw new GoogleTaskException('Task configuration `factor` must be greater than 0.');
}
$this->factor = $config['factor'];
}
if (isset($config['jitter'])) {
if ($config['jitter'] <= 0) {
throw new GoogleTaskException('Task configuration `jitter` must be greater than 0.');
}
$this->jitter = $config['jitter'];
}
if (isset($config['retries'])) {
if ($config['retries'] < 0) {
throw new GoogleTaskException('Task configuration `retries` must not be negative.');
}
$this->maxAttempts += $config['retries'];
}
if (!\is_callable($action)) {
throw new GoogleTaskException('Task argument `$action` must be a valid callable.');
}
$this->action = $action;
$this->arguments = $arguments;
}
/**
* Checks if a retry can be attempted.
*
* @return boolean
*/
public function canAttempt()
{
return $this->attempts < $this->maxAttempts;
}
/**
* Runs the task and (if applicable) automatically retries when errors occur.
*
* @return mixed
* @throws \VendorDuplicator\Google\Service\Exception on failure when no retries are available.
*/
public function run()
{
while ($this->attempt()) {
try {
return \call_user_func_array($this->action, $this->arguments);
} catch (GoogleServiceException $exception) {
$allowedRetries = $this->allowedRetries($exception->getCode(), $exception->getErrors());
if (!$this->canAttempt() || !$allowedRetries) {
throw $exception;
}
if ($allowedRetries > 0) {
$this->maxAttempts = \min($this->maxAttempts, $this->attempts + $allowedRetries);
}
}
}
}
/**
* Runs a task once, if possible. This is useful for bypassing the `run()`
* loop.
*
* NOTE: If this is not the first attempt, this function will sleep in
* accordance to the backoff configurations before running the task.
*
* @return boolean
*/
public function attempt()
{
if (!$this->canAttempt()) {
return \false;
}
if ($this->attempts > 0) {
$this->backOff();
}
$this->attempts++;
return \true;
}
/**
* Sleeps in accordance to the backoff configurations.
*/
private function backOff()
{
$delay = $this->getDelay();
\usleep((int) ($delay * 1000000));
}
/**
* Gets the delay (in seconds) for the current backoff period.
*
* @return int
*/
private function getDelay()
{
$jitter = $this->getJitter();
$factor = $this->attempts > 1 ? $this->factor + $jitter : 1 + \abs($jitter);
return $this->delay = \min($this->maxDelay, $this->delay * $factor);
}
/**
* Gets the current jitter (random number between -$this->jitter and
* $this->jitter).
*
* @return float
*/
private function getJitter()
{
return $this->jitter * 2 * \mt_rand() / \mt_getrandmax() - $this->jitter;
}
/**
* Gets the number of times the associated task can be retried.
*
* NOTE: -1 is returned if the task can be retried indefinitely
*
* @return integer
*/
public function allowedRetries($code, $errors = [])
{
if (isset($this->retryMap[$code])) {
return $this->retryMap[$code];
}
if (!empty($errors) && isset($errors[0]['reason'], $this->retryMap[$errors[0]['reason']])) {
return $this->retryMap[$errors[0]['reason']];
}
return 0;
}
public function setRetryMap($retryMap)
{
$this->retryMap = $retryMap;
}
}

View File

@@ -0,0 +1,264 @@
<?php
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace VendorDuplicator\Google\Utils;
/**
* Implementation of levels 1-3 of the URI Template spec.
* @see http://tools.ietf.org/html/rfc6570
*/
class UriTemplate
{
const TYPE_MAP = "1";
const TYPE_LIST = "2";
const TYPE_SCALAR = "4";
/**
* @var array $operators
* These are valid at the start of a template block to
* modify the way in which the variables inside are
* processed.
*/
private $operators = ["+" => "reserved", "/" => "segments", "." => "dotprefix", "#" => "fragment", ";" => "semicolon", "?" => "form", "&" => "continuation"];
/**
* @var array<string>
* These are the characters which should not be URL encoded in reserved
* strings.
*/
private $reserved = ["=", ",", "!", "@", "|", ":", "/", "?", "#", "[", "]", '$', "&", "'", "(", ")", "*", "+", ";"];
private $reservedEncoded = ["%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F", "%23", "%5B", "%5D", "%24", "%26", "%27", "%28", "%29", "%2A", "%2B", "%3B"];
public function parse($string, array $parameters)
{
return $this->resolveNextSection($string, $parameters);
}
/**
* This function finds the first matching {...} block and
* executes the replacement. It then calls itself to find
* subsequent blocks, if any.
*/
private function resolveNextSection($string, $parameters)
{
$start = \strpos($string, "{");
if ($start === \false) {
return $string;
}
$end = \strpos($string, "}");
if ($end === \false) {
return $string;
}
$string = $this->replace($string, $start, $end, $parameters);
return $this->resolveNextSection($string, $parameters);
}
private function replace($string, $start, $end, $parameters)
{
// We know a data block will have {} round it, so we can strip that.
$data = \substr($string, $start + 1, $end - $start - 1);
// If the first character is one of the reserved operators, it effects
// the processing of the stream.
if (isset($this->operators[$data[0]])) {
$op = $this->operators[$data[0]];
$data = \substr($data, 1);
$prefix = "";
$prefix_on_missing = \false;
switch ($op) {
case "reserved":
// Reserved means certain characters should not be URL encoded
$data = $this->replaceVars($data, $parameters, ",", null, \true);
break;
case "fragment":
// Comma separated with fragment prefix. Bare values only.
$prefix = "#";
$prefix_on_missing = \true;
$data = $this->replaceVars($data, $parameters, ",", null, \true);
break;
case "segments":
// Slash separated data. Bare values only.
$prefix = "/";
$data = $this->replaceVars($data, $parameters, "/");
break;
case "dotprefix":
// Dot separated data. Bare values only.
$prefix = ".";
$prefix_on_missing = \true;
$data = $this->replaceVars($data, $parameters, ".");
break;
case "semicolon":
// Semicolon prefixed and separated. Uses the key name
$prefix = ";";
$data = $this->replaceVars($data, $parameters, ";", "=", \false, \true, \false);
break;
case "form":
// Standard URL format. Uses the key name
$prefix = "?";
$data = $this->replaceVars($data, $parameters, "&", "=");
break;
case "continuation":
// Standard URL, but with leading ampersand. Uses key name.
$prefix = "&";
$data = $this->replaceVars($data, $parameters, "&", "=");
break;
}
// Add the initial prefix character if data is valid.
if ($data || $data !== \false && $prefix_on_missing) {
$data = $prefix . $data;
}
} else {
// If no operator we replace with the defaults.
$data = $this->replaceVars($data, $parameters);
}
// This is chops out the {...} and replaces with the new section.
return \substr($string, 0, $start) . $data . \substr($string, $end + 1);
}
private function replaceVars($section, $parameters, $sep = ",", $combine = null, $reserved = \false, $tag_empty = \false, $combine_on_empty = \true)
{
if (\strpos($section, ",") === \false) {
// If we only have a single value, we can immediately process.
return $this->combine($section, $parameters, $sep, $combine, $reserved, $tag_empty, $combine_on_empty);
} else {
// If we have multiple values, we need to split and loop over them.
// Each is treated individually, then glued together with the
// separator character.
$vars = \explode(",", $section);
return $this->combineList(
$vars,
$sep,
$parameters,
$combine,
$reserved,
\false,
// Never emit empty strings in multi-param replacements
$combine_on_empty
);
}
}
public function combine($key, $parameters, $sep, $combine, $reserved, $tag_empty, $combine_on_empty)
{
$length = \false;
$explode = \false;
$skip_final_combine = \false;
$value = \false;
// Check for length restriction.
if (\strpos($key, ":") !== \false) {
list($key, $length) = \explode(":", $key);
}
// Check for explode parameter.
if ($key[\strlen($key) - 1] == "*") {
$explode = \true;
$key = \substr($key, 0, -1);
$skip_final_combine = \true;
}
// Define the list separator.
$list_sep = $explode ? $sep : ",";
if (isset($parameters[$key])) {
$data_type = $this->getDataType($parameters[$key]);
switch ($data_type) {
case self::TYPE_SCALAR:
$value = $this->getValue($parameters[$key], $length);
break;
case self::TYPE_LIST:
$values = [];
foreach ($parameters[$key] as $pkey => $pvalue) {
$pvalue = $this->getValue($pvalue, $length);
if ($combine && $explode) {
$values[$pkey] = $key . $combine . $pvalue;
} else {
$values[$pkey] = $pvalue;
}
}
$value = \implode($list_sep, $values);
if ($value == '') {
return '';
}
break;
case self::TYPE_MAP:
$values = [];
foreach ($parameters[$key] as $pkey => $pvalue) {
$pvalue = $this->getValue($pvalue, $length);
if ($explode) {
$pkey = $this->getValue($pkey, $length);
$values[] = $pkey . "=" . $pvalue;
// Explode triggers = combine.
} else {
$values[] = $pkey;
$values[] = $pvalue;
}
}
$value = \implode($list_sep, $values);
if ($value == '') {
return \false;
}
break;
}
} elseif ($tag_empty) {
// If we are just indicating empty values with their key name, return that.
return $key;
} else {
// Otherwise we can skip this variable due to not being defined.
return \false;
}
if ($reserved) {
$value = \str_replace($this->reservedEncoded, $this->reserved, $value);
}
// If we do not need to include the key name, we just return the raw
// value.
if (!$combine || $skip_final_combine) {
return $value;
}
// Else we combine the key name: foo=bar, if value is not the empty string.
return $key . ($value != '' || $combine_on_empty ? $combine . $value : '');
}
/**
* Return the type of a passed in value
*/
private function getDataType($data)
{
if (\is_array($data)) {
\reset($data);
if (\key($data) !== 0) {
return self::TYPE_MAP;
}
return self::TYPE_LIST;
}
return self::TYPE_SCALAR;
}
/**
* Utility function that merges multiple combine calls
* for multi-key templates.
*/
private function combineList($vars, $sep, $parameters, $combine, $reserved, $tag_empty, $combine_on_empty)
{
$ret = [];
foreach ($vars as $var) {
$response = $this->combine($var, $parameters, $sep, $combine, $reserved, $tag_empty, $combine_on_empty);
if ($response === \false) {
continue;
}
$ret[] = $response;
}
return \implode($sep, $ret);
}
/**
* Utility function to encode and trim values
*/
private function getValue($value, $length)
{
if ($length) {
$value = \substr($value, 0, $length);
}
$value = \rawurlencode($value);
return $value;
}
}

View File

@@ -0,0 +1,88 @@
<?php
namespace VendorDuplicator;
if (\class_exists('VendorDuplicator\\Google_Client', \false)) {
// Prevent error with preloading in PHP 7.4
// @see https://github.com/googleapis/google-api-php-client/issues/1976
return;
}
$classMap = ['VendorDuplicator\\Google\\Client' => 'VendorDuplicator\\Google_Client', 'VendorDuplicator\\Google\\Service' => 'VendorDuplicator\\Google_Service', 'VendorDuplicator\\Google\\AccessToken\\Revoke' => 'VendorDuplicator\\Google_AccessToken_Revoke', 'VendorDuplicator\\Google\\AccessToken\\Verify' => 'VendorDuplicator\\Google_AccessToken_Verify', 'VendorDuplicator\\Google\\Model' => 'VendorDuplicator\\Google_Model', 'VendorDuplicator\\Google\\Utils\\UriTemplate' => 'VendorDuplicator\\Google_Utils_UriTemplate', 'VendorDuplicator\\Google\\AuthHandler\\Guzzle6AuthHandler' => 'VendorDuplicator\\Google_AuthHandler_Guzzle6AuthHandler', 'VendorDuplicator\\Google\\AuthHandler\\Guzzle7AuthHandler' => 'VendorDuplicator\\Google_AuthHandler_Guzzle7AuthHandler', 'VendorDuplicator\\Google\\AuthHandler\\Guzzle5AuthHandler' => 'VendorDuplicator\\Google_AuthHandler_Guzzle5AuthHandler', 'VendorDuplicator\\Google\\AuthHandler\\AuthHandlerFactory' => 'VendorDuplicator\\Google_AuthHandler_AuthHandlerFactory', 'VendorDuplicator\\Google\\Http\\Batch' => 'VendorDuplicator\\Google_Http_Batch', 'VendorDuplicator\\Google\\Http\\MediaFileUpload' => 'VendorDuplicator\\Google_Http_MediaFileUpload', 'VendorDuplicator\\Google\\Http\\REST' => 'VendorDuplicator\\Google_Http_REST', 'VendorDuplicator\\Google\\Task\\Retryable' => 'VendorDuplicator\\Google_Task_Retryable', 'VendorDuplicator\\Google\\Task\\Exception' => 'VendorDuplicator\\Google_Task_Exception', 'VendorDuplicator\\Google\\Task\\Runner' => 'VendorDuplicator\\Google_Task_Runner', 'VendorDuplicator\\Google\\Collection' => 'VendorDuplicator\\Google_Collection', 'VendorDuplicator\\Google\\Service\\Exception' => 'VendorDuplicator\\Google_Service_Exception', 'VendorDuplicator\\Google\\Service\\Resource' => 'VendorDuplicator\\Google_Service_Resource', 'VendorDuplicator\\Google\\Exception' => 'VendorDuplicator\\Google_Exception'];
foreach ($classMap as $class => $alias) {
\class_alias($class, $alias);
}
/**
* This class needs to be defined explicitly as scripts must be recognized by
* the autoloader.
*/
class Google_Task_Composer extends \VendorDuplicator\Google\Task\Composer
{
}
/**
* This class needs to be defined explicitly as scripts must be recognized by
* the autoloader.
*/
\class_alias('VendorDuplicator\\Google_Task_Composer', 'VendorDuplicator\\Google_Task_Composer', \false);
/** @phpstan-ignore-next-line */
if (\false) {
class Google_AccessToken_Revoke extends \VendorDuplicator\Google\AccessToken\Revoke
{
}
class Google_AccessToken_Verify extends \VendorDuplicator\Google\AccessToken\Verify
{
}
class Google_AuthHandler_AuthHandlerFactory extends \VendorDuplicator\Google\AuthHandler\AuthHandlerFactory
{
}
class Google_AuthHandler_Guzzle5AuthHandler extends \VendorDuplicator\Google\AuthHandler\Guzzle5AuthHandler
{
}
class Google_AuthHandler_Guzzle6AuthHandler extends \VendorDuplicator\Google\AuthHandler\Guzzle6AuthHandler
{
}
class Google_AuthHandler_Guzzle7AuthHandler extends \VendorDuplicator\Google\AuthHandler\Guzzle7AuthHandler
{
}
class Google_Client extends \VendorDuplicator\Google\Client
{
}
class Google_Collection extends \VendorDuplicator\Google\Collection
{
}
class Google_Exception extends \VendorDuplicator\Google\Exception
{
}
class Google_Http_Batch extends \VendorDuplicator\Google\Http\Batch
{
}
class Google_Http_MediaFileUpload extends \VendorDuplicator\Google\Http\MediaFileUpload
{
}
class Google_Http_REST extends \VendorDuplicator\Google\Http\REST
{
}
class Google_Model extends \VendorDuplicator\Google\Model
{
}
class Google_Service extends \VendorDuplicator\Google\Service
{
}
class Google_Service_Exception extends \VendorDuplicator\Google\Service\Exception
{
}
class Google_Service_Resource extends \VendorDuplicator\Google\Service\Resource
{
}
class Google_Task_Exception extends \VendorDuplicator\Google\Task\Exception
{
}
interface Google_Task_Retryable extends \VendorDuplicator\Google\Task\Retryable
{
}
class Google_Task_Runner extends \VendorDuplicator\Google\Task\Runner
{
}
class Google_Utils_UriTemplate extends \VendorDuplicator\Google\Utils\UriTemplate
{
}
}

View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2015 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,35 @@
<?php
namespace VendorDuplicator;
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function oauth2client_php_autoload($className)
{
$classPath = \explode('_', $className);
if ($classPath[0] != 'VendorDuplicator\\Google') {
return;
}
if (\count($classPath) > 3) {
// Maximum class file path depth in this project is 3.
$classPath = \array_slice($classPath, 0, 3);
}
$filePath = \dirname(__FILE__) . '/src/' . \implode('/', $classPath) . '.php';
if (\file_exists($filePath)) {
require_once $filePath;
}
}
\spl_autoload_register('VendorDuplicator\\oauth2client_php_autoload');

View File

@@ -0,0 +1,6 @@
{
"extends": [
"config:base",
":preserveSemverRanges"
]
}

Some files were not shown because too many files have changed in this diff Show More