Exemple #1
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);
            }
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        /// <summary>
        /// Updates a property, or adds it if it doesn't exist.
        /// Documentation https://developers.google.com/drive/v2/reference/properties/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="propertyKey">The key of the property.</param>
        /// <param name="body">A valid Drive v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>PropertyResponse</returns>
        public static Property Update(DriveService service, string fileId, string propertyKey, Property body, PropertiesUpdateOptionalParms 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);
                }
                if (propertyKey == null)
                {
                    throw new ArgumentNullException(propertyKey);
                }

                // Building the initial request.
                var request = service.Properties.Update(body, fileId, propertyKey);

                // Applying optional parameters to the request.
                request = (PropertiesResource.UpdateRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Properties.Update failed.", ex);
            }
        }
        /// <summary>
        /// Gets the starting pageToken for listing future changes.
        /// Documentation https://developers.google.com/drive/v2/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>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>StartPageTokenResponse</returns>
        public static StartPageToken GetStartPageToken(DriveService service, ChangesGetStartPageTokenOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

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

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

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Changes.GetStartPageToken failed.", ex);
            }
        }
Exemple #5
0
        /// <summary>
        /// Updates a permission using patch semantics.
        /// Documentation https://developers.google.com/drive/v2/reference/permissions/patch
        /// 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 or Team Drive.</param>
        /// <param name="permissionId">The ID for the permission.</param>
        /// <param name="body">A valid Drive v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>PermissionResponse</returns>
        public static Permission Patch(DriveService service, string fileId, string permissionId, Permission body, PermissionsPatchOptionalParms 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);
                }
                if (permissionId == null)
                {
                    throw new ArgumentNullException(permissionId);
                }

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

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

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Permissions.Patch failed.", ex);
            }
        }
        /// <summary>
        /// Gets a reply.
        /// Documentation https://developers.google.com/drive/v2/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>CommentReplyResponse</returns>
        public static CommentReply 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);
            }
        }