Exemplo n.º 1
0
        /// <summary>
        /// Creates a copy of the specified file.
        /// Documentation https://developers.google.com/drive/v2/reference/files/copy
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file to copy.</param>
        /// <param name="body">A valid drive v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>FileResponse</returns>
        public static File Copy(driveService service, string fileId, File body, FilesCopyOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Building the initial request.
                var request = service.Files.Copy(body, fileId);

                // Applying optional parameters to the request.
                request = (FilesResource.CopyRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Files.Copy failed.", ex);
            }
        }
        /// <summary>
        /// Subscribe to changes for a user.
        /// Documentation https://developers.google.com/drive/v2/reference/changes/watch
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="body">A valid drive v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>ChannelResponse</returns>
        public static Channel Watch(driveService service, Channel body, ChangesWatchOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Building the initial request.
                var request = service.Changes.Watch(body);

                // Applying optional parameters to the request.
                request = (ChangesResource.WatchRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Changes.Watch failed.", ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a specific parent reference.
        /// Documentation https://developers.google.com/drive/v2/reference/parents/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="parentId">The ID of the parent.</param>
        /// <returns>ParentReferenceResponse</returns>
        public static ParentReference Get(driveService service, string fileId, string parentId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }
                if (parentId == null)
                {
                    throw new ArgumentNullException(parentId);
                }

                // Make the request.
                return(service.Parents.Get(fileId, parentId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Parents.Get failed.", ex);
            }
        }
        /// <summary>
        /// Inserts a permission for a file.
        /// Documentation https://developers.google.com/drive/v2/reference/permissions/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID for the file.</param>
        /// <param name="body">A valid drive v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>PermissionResponse</returns>
        public static Permission Insert(driveService service, string fileId, Permission body, PermissionsInsertOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Building the initial request.
                var request = service.Permissions.Insert(body, fileId);

                // Applying optional parameters to the request.
                request = (PermissionsResource.InsertRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Permissions.Insert failed.", ex);
            }
        }
        /// <summary>
        /// Updates an existing reply.
        /// Documentation https://developers.google.com/drive/v2/reference/replies/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="commentId">The ID of the comment.</param>
        /// <param name="replyId">The ID of the reply.</param>
        /// <param name="body">A valid drive v2 body.</param>
        /// <returns>CommentReplyResponse</returns>
        public static CommentReply Update(driveService service, string fileId, string commentId, string replyId, CommentReply body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }
                if (commentId == null)
                {
                    throw new ArgumentNullException(commentId);
                }
                if (replyId == null)
                {
                    throw new ArgumentNullException(replyId);
                }

                // Make the request.
                return(service.Replies.Update(body, fileId, commentId, replyId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Replies.Update failed.", ex);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new comment on a file.
        /// Documentation https://developers.google.com/drive/v3/reference/comments/create
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="body">A valid drive v3 body.</param>
        /// <returns>CommentResponse</returns>
        public static Comment Create(driveService service, string fileId, Comment body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Make the request.
                return(service.Comments.Create(body, fileId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Comments.Create failed.", ex);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Lists a file's comments.
        /// Documentation https://developers.google.com/drive/v3/reference/comments/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>CommentListResponse</returns>
        public static CommentList List(driveService service, string fileId, CommentsListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Building the initial request.
                var request = service.Comments.List(fileId);

                // Applying optional parameters to the request.
                request = (CommentsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Comments.List failed.", ex);
            }
        }
        /// <summary>
        /// Gets a specific child reference.
        /// Documentation https://developers.google.com/drive/v2/reference/children/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="folderId">The ID of the folder.</param>
        /// <param name="childId">The ID of the child.</param>
        /// <returns>ChildReferenceResponse</returns>
        public static ChildReference Get(driveService service, string folderId, string childId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (folderId == null)
                {
                    throw new ArgumentNullException(folderId);
                }
                if (childId == null)
                {
                    throw new ArgumentNullException(childId);
                }

                // Make the request.
                return(service.Children.Get(folderId, childId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Children.Get failed.", ex);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets a specific revision.
        /// Documentation https://developers.google.com/drive/v2/reference/revisions/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="revisionId">The ID of the revision.</param>
        /// <returns>RevisionResponse</returns>
        public static Revision Get(driveService service, string fileId, string revisionId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }
                if (revisionId == null)
                {
                    throw new ArgumentNullException(revisionId);
                }

                // Make the request.
                return(service.Revisions.Get(fileId, revisionId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Revisions.Get failed.", ex);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Exports a Google Doc to the requested MIME type and returns the exported content.
        /// Documentation https://developers.google.com/drive/v2/reference/files/export
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="mimeType">The MIME type of the format requested for this export.</param>
        public static void Export(driveService service, string fileId, string mimeType)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }
                if (mimeType == null)
                {
                    throw new ArgumentNullException(mimeType);
                }

                // Make the request.
                return(service.Files.Export(fileId, mimeType).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Files.Export failed.", ex);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Deletes a comment.
        /// Documentation https://developers.google.com/drive/v3/reference/comments/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="commentId">The ID of the comment.</param>
        public static void Delete(driveService service, string fileId, string commentId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }
                if (commentId == null)
                {
                    throw new ArgumentNullException(commentId);
                }

                // Make the request.
                return(service.Comments.Delete(fileId, commentId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Comments.Delete failed.", ex);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the starting pageToken for listing future changes.
        /// Documentation https://developers.google.com/drive/v3/reference/changes/getStartPageToken
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <returns>StartPageTokenResponse</returns>
        public static StartPageToken GetStartPageToken(driveService service)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.Changes.GetStartPageToken().Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Changes.GetStartPageToken failed.", ex);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Permanently deletes all of the user's trashed files.
        /// Documentation https://developers.google.com/drive/v2/reference/files/emptyTrash
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        public static void EmptyTrash(driveService service)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.Files.EmptyTrash().Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Files.EmptyTrash failed.", ex);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets information about the user, the user's Drive, and system capabilities.
        /// Documentation https://developers.google.com/drive/v3/reference/about/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <returns>AboutResponse</returns>
        public static About Get(driveService service)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.About.Get().Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request About.Get failed.", ex);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Stop watching resources through this channel
        /// Documentation https://developers.google.com/drive/v2/reference/channels/stop
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="body">A valid drive v2 body.</param>
        public static void Stop(driveService service, Channel body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Make the request.
                return(service.Channels.Stop(body).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Channels.Stop failed.", ex);
            }
        }
        /// <summary>
        /// Returns the permission ID for an email address.
        /// Documentation https://developers.google.com/drive/v2/reference/permissions/getIdForEmail
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="email">The email address for which to return a permission ID</param>
        /// <returns>PermissionIdResponse</returns>
        public static PermissionId GetIdForEmail(driveService service, string email)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (email == null)
                {
                    throw new ArgumentNullException(email);
                }

                // Make the request.
                return(service.Permissions.GetIdForEmail(email).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Permissions.GetIdForEmail failed.", ex);
            }
        }
        /// <summary>
        /// Lists a file's permissions.
        /// Documentation https://developers.google.com/drive/v2/reference/permissions/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID for the file.</param>
        /// <returns>PermissionListResponse</returns>
        public static PermissionList List(driveService service, string fileId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Make the request.
                return(service.Permissions.List(fileId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Permissions.List failed.", ex);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Gets a specific app.
        /// Documentation https://developers.google.com/drive/v2/reference/apps/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="appId">The ID of the app.</param>
        /// <returns>AppResponse</returns>
        public static App Get(driveService service, string appId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (appId == null)
                {
                    throw new ArgumentNullException(appId);
                }

                // Make the request.
                return(service.Apps.Get(appId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Apps.Get failed.", ex);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Restores a file from the trash.
        /// Documentation https://developers.google.com/drive/v2/reference/files/untrash
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file to untrash.</param>
        /// <returns>FileResponse</returns>
        public static File Untrash(driveService service, string fileId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }

                // Make the request.
                return(service.Files.Untrash(fileId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Files.Untrash failed.", ex);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Gets a reply by ID.
        /// Documentation https://developers.google.com/drive/v3/reference/replies/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="fileId">The ID of the file.</param>
        /// <param name="commentId">The ID of the comment.</param>
        /// <param name="replyId">The ID of the reply.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>ReplyResponse</returns>
        public static Reply Get(driveService service, string fileId, string commentId, string replyId, RepliesGetOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (fileId == null)
                {
                    throw new ArgumentNullException(fileId);
                }
                if (commentId == null)
                {
                    throw new ArgumentNullException(commentId);
                }
                if (replyId == null)
                {
                    throw new ArgumentNullException(replyId);
                }

                // Building the initial request.
                var request = service.Replies.Get(fileId, commentId, replyId);

                // Applying optional parameters to the request.
                request = (RepliesResource.GetRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Replies.Get failed.", ex);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Gets the information about the current user along with Drive API settings
        /// Documentation https://developers.google.com/drive/v2/reference/about/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>AboutResponse</returns>
        public static About Get(driveService service, AboutGetOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Building the initial request.
                var request = service.About.Get();

                // Applying optional parameters to the request.
                request = (AboutResource.GetRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request About.Get failed.", ex);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Generates a set of file IDs which can be provided in insert requests.
        /// Documentation https://developers.google.com/drive/v2/reference/files/generateIds
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated drive service.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>GeneratedIdsResponse</returns>
        public static GeneratedIds GenerateIds(driveService service, FilesGenerateIdsOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Building the initial request.
                var request = service.Files.GenerateIds();

                // Applying optional parameters to the request.
                request = (FilesResource.GenerateIdsRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Files.GenerateIds failed.", ex);
            }
        }