OLD | NEW |
(Empty) | |
| 1 library googleapis.appsactivity.v1; |
| 2 |
| 3 import "dart:core" as core; |
| 4 import "dart:collection" as collection; |
| 5 import "dart:async" as async; |
| 6 import "dart:convert" as convert; |
| 7 |
| 8 import "package:crypto/crypto.dart" as crypto; |
| 9 import 'package:http/http.dart' as http; |
| 10 import '../src/common_internal.dart' as common_internal; |
| 11 import '../common/common.dart' as common; |
| 12 |
| 13 export '../common/common.dart' show ApiRequestError; |
| 14 export '../common/common.dart' show DetailedApiRequestError; |
| 15 |
| 16 /** Provides a historical view of activity. */ |
| 17 class AppsactivityApi { |
| 18 /** View historical activity for Google services */ |
| 19 static const ActivityScope = "https://www.googleapis.com/auth/activity"; |
| 20 |
| 21 /** View and manage the files and documents in your Google Drive */ |
| 22 static const DriveScope = "https://www.googleapis.com/auth/drive"; |
| 23 |
| 24 /** View metadata for files and documents in your Google Drive */ |
| 25 static const DriveMetadataReadonlyScope = "https://www.googleapis.com/auth/dri
ve.metadata.readonly"; |
| 26 |
| 27 /** View the files and documents in your Google Drive */ |
| 28 static const DriveReadonlyScope = "https://www.googleapis.com/auth/drive.reado
nly"; |
| 29 |
| 30 |
| 31 final common_internal.ApiRequester _requester; |
| 32 |
| 33 ActivitiesResourceApi get activities => new ActivitiesResourceApi(_requester); |
| 34 |
| 35 AppsactivityApi(http.Client client) : |
| 36 _requester = new common_internal.ApiRequester(client, "https://www.googlea
pis.com/", "/appsactivity/v1/"); |
| 37 } |
| 38 |
| 39 |
| 40 /** Not documented yet. */ |
| 41 class ActivitiesResourceApi { |
| 42 final common_internal.ApiRequester _requester; |
| 43 |
| 44 ActivitiesResourceApi(common_internal.ApiRequester client) : |
| 45 _requester = client; |
| 46 |
| 47 /** |
| 48 * Returns a list of activities visible to the current logged in user. Visible |
| 49 * activities are determined by the visiblity settings of the object that was |
| 50 * acted on, e.g. Drive files a user can see. An activity is a record of past |
| 51 * events. Multiple events may be merged if they are similar. A request is |
| 52 * scoped to activities from a given Google service using the source |
| 53 * parameter. |
| 54 * |
| 55 * Request parameters: |
| 56 * |
| 57 * [drive_ancestorId] - Identifies the Drive folder containing the items for |
| 58 * which to return activities. |
| 59 * |
| 60 * [drive_fileId] - Identifies the Drive item to return activities for. |
| 61 * |
| 62 * [groupingStrategy] - Indicates the strategy to use when grouping |
| 63 * singleEvents items in the associated combinedEvent object. |
| 64 * Possible string values are: |
| 65 * - "driveUi" |
| 66 * - "none" |
| 67 * |
| 68 * [pageSize] - The maximum number of events to return on a page. The response |
| 69 * includes a continuation token if there are more events. |
| 70 * |
| 71 * [pageToken] - A token to retrieve a specific page of results. |
| 72 * |
| 73 * [source] - The Google service from which to return activities. Possible |
| 74 * values of source are: |
| 75 * - drive.google.com |
| 76 * |
| 77 * [userId] - Indicates the user to return activity for. Use the special value |
| 78 * me to indicate the currently authenticated user. |
| 79 * |
| 80 * Completes with a [ListActivitiesResponse]. |
| 81 * |
| 82 * Completes with a [common.ApiRequestError] if the API endpoint returned an |
| 83 * error. |
| 84 * |
| 85 * If the used [http.Client] completes with an error when making a REST call, |
| 86 * this method will complete with the same error. |
| 87 */ |
| 88 async.Future<ListActivitiesResponse> list({core.String drive_ancestorId, core.
String drive_fileId, core.String groupingStrategy, core.int pageSize, core.Strin
g pageToken, core.String source, core.String userId}) { |
| 89 var _url = null; |
| 90 var _queryParams = new core.Map(); |
| 91 var _uploadMedia = null; |
| 92 var _uploadOptions = null; |
| 93 var _downloadOptions = common.DownloadOptions.Metadata; |
| 94 var _body = null; |
| 95 |
| 96 if (drive_ancestorId != null) { |
| 97 _queryParams["drive.ancestorId"] = [drive_ancestorId]; |
| 98 } |
| 99 if (drive_fileId != null) { |
| 100 _queryParams["drive.fileId"] = [drive_fileId]; |
| 101 } |
| 102 if (groupingStrategy != null) { |
| 103 _queryParams["groupingStrategy"] = [groupingStrategy]; |
| 104 } |
| 105 if (pageSize != null) { |
| 106 _queryParams["pageSize"] = ["${pageSize}"]; |
| 107 } |
| 108 if (pageToken != null) { |
| 109 _queryParams["pageToken"] = [pageToken]; |
| 110 } |
| 111 if (source != null) { |
| 112 _queryParams["source"] = [source]; |
| 113 } |
| 114 if (userId != null) { |
| 115 _queryParams["userId"] = [userId]; |
| 116 } |
| 117 |
| 118 |
| 119 _url = 'activities'; |
| 120 |
| 121 var _response = _requester.request(_url, |
| 122 "GET", |
| 123 body: _body, |
| 124 queryParams: _queryParams, |
| 125 uploadOptions: _uploadOptions, |
| 126 uploadMedia: _uploadMedia, |
| 127 downloadOptions: _downloadOptions); |
| 128 return _response.then((data) => new ListActivitiesResponse.fromJson(data)); |
| 129 } |
| 130 |
| 131 } |
| 132 |
| 133 |
| 134 |
| 135 /** |
| 136 * An Activity resource is a combined view of multiple events. An activity has a |
| 137 * list of individual events and a combined view of the common fields among all |
| 138 * events. |
| 139 */ |
| 140 class Activity { |
| 141 /** |
| 142 * The fields common to all of the singleEvents that make up the Activity. |
| 143 */ |
| 144 Event combinedEvent; |
| 145 |
| 146 /** A list of all the Events that make up the Activity. */ |
| 147 core.List<Event> singleEvents; |
| 148 |
| 149 |
| 150 Activity(); |
| 151 |
| 152 Activity.fromJson(core.Map _json) { |
| 153 if (_json.containsKey("combinedEvent")) { |
| 154 combinedEvent = new Event.fromJson(_json["combinedEvent"]); |
| 155 } |
| 156 if (_json.containsKey("singleEvents")) { |
| 157 singleEvents = _json["singleEvents"].map((value) => new Event.fromJson(val
ue)).toList(); |
| 158 } |
| 159 } |
| 160 |
| 161 core.Map toJson() { |
| 162 var _json = new core.Map(); |
| 163 if (combinedEvent != null) { |
| 164 _json["combinedEvent"] = (combinedEvent).toJson(); |
| 165 } |
| 166 if (singleEvents != null) { |
| 167 _json["singleEvents"] = singleEvents.map((value) => (value).toJson()).toLi
st(); |
| 168 } |
| 169 return _json; |
| 170 } |
| 171 } |
| 172 |
| 173 |
| 174 /** Represents the changes associated with an action taken by a user. */ |
| 175 class Event { |
| 176 /** |
| 177 * Additional event types. Some events may have multiple types when multiple |
| 178 * actions are part of a single event. For example, creating a document, |
| 179 * renaming it, and sharing it may be part of a single file-creation event. |
| 180 */ |
| 181 core.List<core.String> additionalEventTypes; |
| 182 |
| 183 /** |
| 184 * The time at which the event occurred formatted as Unix time in |
| 185 * milliseconds. |
| 186 */ |
| 187 core.String eventTimeMillis; |
| 188 |
| 189 /** Whether this event is caused by a user being deleted. */ |
| 190 core.bool fromUserDeletion; |
| 191 |
| 192 /** |
| 193 * Extra information for move type events, such as changes in an object's |
| 194 * parents. |
| 195 */ |
| 196 Move move; |
| 197 |
| 198 /** |
| 199 * Extra information for permissionChange type events, such as the user or |
| 200 * group the new permission applies to. |
| 201 */ |
| 202 core.List<PermissionChange> permissionChanges; |
| 203 |
| 204 /** |
| 205 * The main type of event that occurred. |
| 206 * Possible string values are: |
| 207 * - "comment" |
| 208 * - "create" |
| 209 * - "edit" |
| 210 * - "emptyTrash" |
| 211 * - "move" |
| 212 * - "permissionChange" |
| 213 * - "rename" |
| 214 * - "trash" |
| 215 * - "unknown" |
| 216 * - "untrash" |
| 217 * - "upload" |
| 218 */ |
| 219 core.String primaryEventType; |
| 220 |
| 221 /** |
| 222 * Extra information for rename type events, such as the old and new names. |
| 223 */ |
| 224 Rename rename; |
| 225 |
| 226 /** Information specific to the Target object modified by the event. */ |
| 227 Target target; |
| 228 |
| 229 /** Represents the user responsible for the event. */ |
| 230 User user; |
| 231 |
| 232 |
| 233 Event(); |
| 234 |
| 235 Event.fromJson(core.Map _json) { |
| 236 if (_json.containsKey("additionalEventTypes")) { |
| 237 additionalEventTypes = _json["additionalEventTypes"]; |
| 238 } |
| 239 if (_json.containsKey("eventTimeMillis")) { |
| 240 eventTimeMillis = _json["eventTimeMillis"]; |
| 241 } |
| 242 if (_json.containsKey("fromUserDeletion")) { |
| 243 fromUserDeletion = _json["fromUserDeletion"]; |
| 244 } |
| 245 if (_json.containsKey("move")) { |
| 246 move = new Move.fromJson(_json["move"]); |
| 247 } |
| 248 if (_json.containsKey("permissionChanges")) { |
| 249 permissionChanges = _json["permissionChanges"].map((value) => new Permissi
onChange.fromJson(value)).toList(); |
| 250 } |
| 251 if (_json.containsKey("primaryEventType")) { |
| 252 primaryEventType = _json["primaryEventType"]; |
| 253 } |
| 254 if (_json.containsKey("rename")) { |
| 255 rename = new Rename.fromJson(_json["rename"]); |
| 256 } |
| 257 if (_json.containsKey("target")) { |
| 258 target = new Target.fromJson(_json["target"]); |
| 259 } |
| 260 if (_json.containsKey("user")) { |
| 261 user = new User.fromJson(_json["user"]); |
| 262 } |
| 263 } |
| 264 |
| 265 core.Map toJson() { |
| 266 var _json = new core.Map(); |
| 267 if (additionalEventTypes != null) { |
| 268 _json["additionalEventTypes"] = additionalEventTypes; |
| 269 } |
| 270 if (eventTimeMillis != null) { |
| 271 _json["eventTimeMillis"] = eventTimeMillis; |
| 272 } |
| 273 if (fromUserDeletion != null) { |
| 274 _json["fromUserDeletion"] = fromUserDeletion; |
| 275 } |
| 276 if (move != null) { |
| 277 _json["move"] = (move).toJson(); |
| 278 } |
| 279 if (permissionChanges != null) { |
| 280 _json["permissionChanges"] = permissionChanges.map((value) => (value).toJs
on()).toList(); |
| 281 } |
| 282 if (primaryEventType != null) { |
| 283 _json["primaryEventType"] = primaryEventType; |
| 284 } |
| 285 if (rename != null) { |
| 286 _json["rename"] = (rename).toJson(); |
| 287 } |
| 288 if (target != null) { |
| 289 _json["target"] = (target).toJson(); |
| 290 } |
| 291 if (user != null) { |
| 292 _json["user"] = (user).toJson(); |
| 293 } |
| 294 return _json; |
| 295 } |
| 296 } |
| 297 |
| 298 |
| 299 /** |
| 300 * The response from the list request. Contains a list of activities and a token |
| 301 * to retrieve the next page of results. |
| 302 */ |
| 303 class ListActivitiesResponse { |
| 304 /** List of activities. */ |
| 305 core.List<Activity> activities; |
| 306 |
| 307 /** Token for the next page of results. */ |
| 308 core.String nextPageToken; |
| 309 |
| 310 |
| 311 ListActivitiesResponse(); |
| 312 |
| 313 ListActivitiesResponse.fromJson(core.Map _json) { |
| 314 if (_json.containsKey("activities")) { |
| 315 activities = _json["activities"].map((value) => new Activity.fromJson(valu
e)).toList(); |
| 316 } |
| 317 if (_json.containsKey("nextPageToken")) { |
| 318 nextPageToken = _json["nextPageToken"]; |
| 319 } |
| 320 } |
| 321 |
| 322 core.Map toJson() { |
| 323 var _json = new core.Map(); |
| 324 if (activities != null) { |
| 325 _json["activities"] = activities.map((value) => (value).toJson()).toList()
; |
| 326 } |
| 327 if (nextPageToken != null) { |
| 328 _json["nextPageToken"] = nextPageToken; |
| 329 } |
| 330 return _json; |
| 331 } |
| 332 } |
| 333 |
| 334 |
| 335 /** |
| 336 * Contains information about changes in an object's parents as a result of a |
| 337 * move type event. |
| 338 */ |
| 339 class Move { |
| 340 /** The added parent(s). */ |
| 341 core.List<Parent> addedParents; |
| 342 |
| 343 /** The removed parent(s). */ |
| 344 core.List<Parent> removedParents; |
| 345 |
| 346 |
| 347 Move(); |
| 348 |
| 349 Move.fromJson(core.Map _json) { |
| 350 if (_json.containsKey("addedParents")) { |
| 351 addedParents = _json["addedParents"].map((value) => new Parent.fromJson(va
lue)).toList(); |
| 352 } |
| 353 if (_json.containsKey("removedParents")) { |
| 354 removedParents = _json["removedParents"].map((value) => new Parent.fromJso
n(value)).toList(); |
| 355 } |
| 356 } |
| 357 |
| 358 core.Map toJson() { |
| 359 var _json = new core.Map(); |
| 360 if (addedParents != null) { |
| 361 _json["addedParents"] = addedParents.map((value) => (value).toJson()).toLi
st(); |
| 362 } |
| 363 if (removedParents != null) { |
| 364 _json["removedParents"] = removedParents.map((value) => (value).toJson()).
toList(); |
| 365 } |
| 366 return _json; |
| 367 } |
| 368 } |
| 369 |
| 370 |
| 371 /** |
| 372 * Contains information about a parent object. For example, a folder in Drive is |
| 373 * a parent for all files within it. |
| 374 */ |
| 375 class Parent { |
| 376 /** The parent's ID. */ |
| 377 core.String id; |
| 378 |
| 379 /** Whether this is the root folder. */ |
| 380 core.bool isRoot; |
| 381 |
| 382 /** The parent's title. */ |
| 383 core.String title; |
| 384 |
| 385 |
| 386 Parent(); |
| 387 |
| 388 Parent.fromJson(core.Map _json) { |
| 389 if (_json.containsKey("id")) { |
| 390 id = _json["id"]; |
| 391 } |
| 392 if (_json.containsKey("isRoot")) { |
| 393 isRoot = _json["isRoot"]; |
| 394 } |
| 395 if (_json.containsKey("title")) { |
| 396 title = _json["title"]; |
| 397 } |
| 398 } |
| 399 |
| 400 core.Map toJson() { |
| 401 var _json = new core.Map(); |
| 402 if (id != null) { |
| 403 _json["id"] = id; |
| 404 } |
| 405 if (isRoot != null) { |
| 406 _json["isRoot"] = isRoot; |
| 407 } |
| 408 if (title != null) { |
| 409 _json["title"] = title; |
| 410 } |
| 411 return _json; |
| 412 } |
| 413 } |
| 414 |
| 415 |
| 416 /** |
| 417 * Contains information about the permissions and type of access allowed with |
| 418 * regards to a Google Drive object. This is a subset of the fields contained in |
| 419 * a corresponding Drive Permissions object. |
| 420 */ |
| 421 class Permission { |
| 422 /** The name of the user or group the permission applies to. */ |
| 423 core.String name; |
| 424 |
| 425 /** |
| 426 * The ID for this permission. Corresponds to the Drive API's permission ID |
| 427 * returned as part of the Drive Permissions resource. |
| 428 */ |
| 429 core.String permissionId; |
| 430 |
| 431 /** |
| 432 * Indicates the Google Drive permissions role. The role determines a user's |
| 433 * ability to read, write, or comment on the file. |
| 434 * Possible string values are: |
| 435 * - "commenter" |
| 436 * - "owner" |
| 437 * - "reader" |
| 438 * - "writer" |
| 439 */ |
| 440 core.String role; |
| 441 |
| 442 /** |
| 443 * Indicates how widely permissions are granted. |
| 444 * Possible string values are: |
| 445 * - "anyone" |
| 446 * - "domain" |
| 447 * - "group" |
| 448 * - "user" |
| 449 */ |
| 450 core.String type; |
| 451 |
| 452 /** The user's information if the type is USER. */ |
| 453 User user; |
| 454 |
| 455 /** Whether the permission requires a link to the file. */ |
| 456 core.bool withLink; |
| 457 |
| 458 |
| 459 Permission(); |
| 460 |
| 461 Permission.fromJson(core.Map _json) { |
| 462 if (_json.containsKey("name")) { |
| 463 name = _json["name"]; |
| 464 } |
| 465 if (_json.containsKey("permissionId")) { |
| 466 permissionId = _json["permissionId"]; |
| 467 } |
| 468 if (_json.containsKey("role")) { |
| 469 role = _json["role"]; |
| 470 } |
| 471 if (_json.containsKey("type")) { |
| 472 type = _json["type"]; |
| 473 } |
| 474 if (_json.containsKey("user")) { |
| 475 user = new User.fromJson(_json["user"]); |
| 476 } |
| 477 if (_json.containsKey("withLink")) { |
| 478 withLink = _json["withLink"]; |
| 479 } |
| 480 } |
| 481 |
| 482 core.Map toJson() { |
| 483 var _json = new core.Map(); |
| 484 if (name != null) { |
| 485 _json["name"] = name; |
| 486 } |
| 487 if (permissionId != null) { |
| 488 _json["permissionId"] = permissionId; |
| 489 } |
| 490 if (role != null) { |
| 491 _json["role"] = role; |
| 492 } |
| 493 if (type != null) { |
| 494 _json["type"] = type; |
| 495 } |
| 496 if (user != null) { |
| 497 _json["user"] = (user).toJson(); |
| 498 } |
| 499 if (withLink != null) { |
| 500 _json["withLink"] = withLink; |
| 501 } |
| 502 return _json; |
| 503 } |
| 504 } |
| 505 |
| 506 |
| 507 /** |
| 508 * Contains information about a Drive object's permissions that changed as a |
| 509 * result of a permissionChange type event. |
| 510 */ |
| 511 class PermissionChange { |
| 512 /** Lists all Permission objects added. */ |
| 513 core.List<Permission> addedPermissions; |
| 514 |
| 515 /** Lists all Permission objects removed. */ |
| 516 core.List<Permission> removedPermissions; |
| 517 |
| 518 |
| 519 PermissionChange(); |
| 520 |
| 521 PermissionChange.fromJson(core.Map _json) { |
| 522 if (_json.containsKey("addedPermissions")) { |
| 523 addedPermissions = _json["addedPermissions"].map((value) => new Permission
.fromJson(value)).toList(); |
| 524 } |
| 525 if (_json.containsKey("removedPermissions")) { |
| 526 removedPermissions = _json["removedPermissions"].map((value) => new Permis
sion.fromJson(value)).toList(); |
| 527 } |
| 528 } |
| 529 |
| 530 core.Map toJson() { |
| 531 var _json = new core.Map(); |
| 532 if (addedPermissions != null) { |
| 533 _json["addedPermissions"] = addedPermissions.map((value) => (value).toJson
()).toList(); |
| 534 } |
| 535 if (removedPermissions != null) { |
| 536 _json["removedPermissions"] = removedPermissions.map((value) => (value).to
Json()).toList(); |
| 537 } |
| 538 return _json; |
| 539 } |
| 540 } |
| 541 |
| 542 |
| 543 /** Photo information for a user. */ |
| 544 class Photo { |
| 545 /** The URL of the photo. */ |
| 546 core.String url; |
| 547 |
| 548 |
| 549 Photo(); |
| 550 |
| 551 Photo.fromJson(core.Map _json) { |
| 552 if (_json.containsKey("url")) { |
| 553 url = _json["url"]; |
| 554 } |
| 555 } |
| 556 |
| 557 core.Map toJson() { |
| 558 var _json = new core.Map(); |
| 559 if (url != null) { |
| 560 _json["url"] = url; |
| 561 } |
| 562 return _json; |
| 563 } |
| 564 } |
| 565 |
| 566 |
| 567 /** Contains information about a renametype event. */ |
| 568 class Rename { |
| 569 /** The new title. */ |
| 570 core.String newTitle; |
| 571 |
| 572 /** The old title. */ |
| 573 core.String oldTitle; |
| 574 |
| 575 |
| 576 Rename(); |
| 577 |
| 578 Rename.fromJson(core.Map _json) { |
| 579 if (_json.containsKey("newTitle")) { |
| 580 newTitle = _json["newTitle"]; |
| 581 } |
| 582 if (_json.containsKey("oldTitle")) { |
| 583 oldTitle = _json["oldTitle"]; |
| 584 } |
| 585 } |
| 586 |
| 587 core.Map toJson() { |
| 588 var _json = new core.Map(); |
| 589 if (newTitle != null) { |
| 590 _json["newTitle"] = newTitle; |
| 591 } |
| 592 if (oldTitle != null) { |
| 593 _json["oldTitle"] = oldTitle; |
| 594 } |
| 595 return _json; |
| 596 } |
| 597 } |
| 598 |
| 599 |
| 600 /** Information about the object modified by the event. */ |
| 601 class Target { |
| 602 /** |
| 603 * The ID of the target. For example, in Google Drive, this is the file or |
| 604 * folder ID. |
| 605 */ |
| 606 core.String id; |
| 607 |
| 608 /** The MIME type of the target. */ |
| 609 core.String mimeType; |
| 610 |
| 611 /** |
| 612 * The name of the target. For example, in Google Drive, this is the title of |
| 613 * the file. |
| 614 */ |
| 615 core.String name; |
| 616 |
| 617 |
| 618 Target(); |
| 619 |
| 620 Target.fromJson(core.Map _json) { |
| 621 if (_json.containsKey("id")) { |
| 622 id = _json["id"]; |
| 623 } |
| 624 if (_json.containsKey("mimeType")) { |
| 625 mimeType = _json["mimeType"]; |
| 626 } |
| 627 if (_json.containsKey("name")) { |
| 628 name = _json["name"]; |
| 629 } |
| 630 } |
| 631 |
| 632 core.Map toJson() { |
| 633 var _json = new core.Map(); |
| 634 if (id != null) { |
| 635 _json["id"] = id; |
| 636 } |
| 637 if (mimeType != null) { |
| 638 _json["mimeType"] = mimeType; |
| 639 } |
| 640 if (name != null) { |
| 641 _json["name"] = name; |
| 642 } |
| 643 return _json; |
| 644 } |
| 645 } |
| 646 |
| 647 |
| 648 /** A representation of a user. */ |
| 649 class User { |
| 650 /** The displayable name of the user. */ |
| 651 core.String name; |
| 652 |
| 653 /** The profile photo of the user. */ |
| 654 Photo photo; |
| 655 |
| 656 |
| 657 User(); |
| 658 |
| 659 User.fromJson(core.Map _json) { |
| 660 if (_json.containsKey("name")) { |
| 661 name = _json["name"]; |
| 662 } |
| 663 if (_json.containsKey("photo")) { |
| 664 photo = new Photo.fromJson(_json["photo"]); |
| 665 } |
| 666 } |
| 667 |
| 668 core.Map toJson() { |
| 669 var _json = new core.Map(); |
| 670 if (name != null) { |
| 671 _json["name"] = name; |
| 672 } |
| 673 if (photo != null) { |
| 674 _json["photo"] = (photo).toJson(); |
| 675 } |
| 676 return _json; |
| 677 } |
| 678 } |
| 679 |
| 680 |
OLD | NEW |