Beispiel #1
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);
            }
        }
        /// <summary>
        /// Generates a set of file IDs which can be provided in create requests.
        /// Documentation https://developers.google.com/drive/v3/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 async Task <GeneratedIds> GenerateId(FilesGenerateIdsOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (_service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Building the initial request.
                var request = _service.Files.GenerateIds();
                request.Count = 1;
                // Applying optional parameters to the request.
                request = (FilesResource.GenerateIdsRequest)GoogleDriveFunctionsHelper.ApplyOptionalParms(request, optional);

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