1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Microsoft Graph API Rest Interface. 19 * 20 * @package repository_onedrive 21 * @copyright 2017 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace repository_onedrive; 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 /** 29 * Microsoft Graph API Rest Interface. 30 * 31 * @copyright 2017 Damyon Wiese 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class rest extends \core\oauth2\rest { 35 36 /** 37 * Define the functions of the rest API. 38 * 39 * @return array Example: 40 * [ 'listFiles' => [ 'method' => 'get', 'endpoint' => 'http://...', 'args' => [ 'folder' => PARAM_STRING ] ] ] 41 */ 42 public function get_api_functions() { 43 return [ 44 'list' => [ 45 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/{parent}/children', 46 'method' => 'get', 47 'args' => [ 48 '$select' => PARAM_RAW, 49 '$expand' => PARAM_RAW, 50 'parent' => PARAM_RAW, 51 '$skip' => PARAM_INT, 52 '$skipToken' => PARAM_RAW, 53 '$count' => PARAM_INT 54 ], 55 'response' => 'json' 56 ], 57 'search' => [ 58 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/{parent}/search(q=\'{search}\')', 59 'method' => 'get', 60 'args' => [ 61 'search' => PARAM_NOTAGS, 62 '$select' => PARAM_RAW, 63 'parent' => PARAM_RAW, 64 '$skip' => PARAM_INT, 65 '$skipToken' => PARAM_RAW, 66 '$count' => PARAM_INT 67 ], 68 'response' => 'json' 69 ], 70 'get' => [ 71 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/items/{fileid}', 72 'method' => 'get', 73 'args' => [ 74 'fileid' => PARAM_RAW, 75 '$select' => PARAM_RAW, 76 '$expand' => PARAM_RAW 77 ], 78 'response' => 'json' 79 ], 80 'create_permission' => [ 81 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/items/{fileid}/invite', 82 'method' => 'post', 83 'args' => [ 84 'fileid' => PARAM_RAW 85 ], 86 'response' => 'json' 87 ], 88 'create_upload' => [ 89 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/items/{parentid}:/{filename}:/createUploadSession', 90 'method' => 'post', 91 'args' => [ 92 'parentid' => PARAM_RAW, 93 'filename' => PARAM_RAW 94 ], 95 'response' => 'json' 96 ], 97 'get_file_by_path' => [ 98 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/root:/{fullpath}', 99 'method' => 'get', 100 'args' => [ 101 'fullpath' => PARAM_RAW, 102 '$select' => PARAM_RAW 103 ], 104 'response' => 'json' 105 ], 106 'create_folder' => [ 107 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/items/{parentid}/children', 108 'method' => 'post', 109 'args' => [ 110 'parentid' => PARAM_RAW 111 ], 112 'response' => 'json' 113 ], 114 'create_link' => [ 115 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/items/{fileid}/createLink', 116 'method' => 'post', 117 'args' => [ 118 'fileid' => PARAM_RAW 119 ], 120 'response' => 'json' 121 ], 122 'delete_file_by_path' => [ 123 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/root:/{fullpath}', 124 'method' => 'delete', 125 'args' => [ 126 'fullpath' => PARAM_RAW, 127 ], 128 'response' => 'json' 129 ], 130 'delete_permission' => [ 131 'endpoint' => 'https://graph.microsoft.com/v1.0/me/drive/items/{fileid}/permissions/{permissionid}', 132 'method' => 'delete', 133 'args' => [ 134 'fileid' => PARAM_RAW, 135 'permissionid' => PARAM_RAW 136 ], 137 'response' => 'json' 138 ], 139 ]; 140 } 141 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body