Google Spreadsheet API v4, is it possible to get revision content? - google-sheets-api

I'm reading through the v4 API and can't satisfy my own question. I want to build an app that gathers a single spreadsheet's previous revision(s). (Specifically, I want to be able to get the entire content of a previous revision.) Is this possible in the v4 API? If it is can I get entire revision snapshots, or does the API only return difference information?

I cannot find any instruction in the Sheets API that can get the revision content of it's file. So the only way to get the revision file is by manually checking it in the Spreadsheet file itself under File -> See revison history. Or by using the Manage Revisions of Google Drive.
Google Drive keeps track of all changes made to a file by
automatically creating a "revision history." This allows users to see
who made edits and to revert to earlier versions of the same file.
Here are the steps that you need to do in order to get the revision file.
Get the File ID of the Spreadsheet that you want to get its revision.
By using the Revisions: list, you can get here the list of all revision that you do for that file.
Now, by using the Revisions: get, you can now get the specific revision of the file.
For more information, check this SO question.

Related

Is there a SpreadsheetApp.flush() option for the Google Sheets API?

I have a spreadsheet that I send data to it, I generate a 1-minute sleep (import time → time.sleep(60)) in the code to make sure that the calculations have all been done and then I copy the result of these calculations to another page of that same spreadsheet.
In Google Apps Script there is the SpreadsheetApp.flush() option to make sure that everything in the spreadsheet is perfect to continue the code.
But what about when we use the Google Sheets API, is there a way to do this instead of putting a sleep with a random value like I do?
I was curious about that too, so I reviewed the documentation, and it seems that there is no flush() method for Sheets API.
However, I found a workaround that might help so you can make sure that you are working on the latest version of the sheet. I took inspiration from the Writecontrol parameter in Google Docs API.
"Determines the revision of the document to write to and how the
request should behave if that revision is not the current revision of
the document."
So what I was thinking is to use the Drive API Revisions by using the Revisions: list method and get the latest version of the Sheet. After that, use Revision: get to retrieve the latest version of the sheet to work on it.
You can also submit a missing feature, Google might add this method to the Sheets API later on.
Reference:
Flush() method.
Writecontrol Google Docs API.
Changes and revisions overview.
Revisions: list.
Revisions: get.

Headers are not picking up from the Google sheet in Google big query

I am trying to upload a google sheet to my dataset in the google bigquery. Below are the settings
Uploading configuration snap
I have made the "Header rows to skip" = 1 and =0 as well
Result doesn't pick the header on the top. It shows "string_field_0"
Here is the file with just one header column and 3 values https://docs.google.com/spreadsheets/d/1mnYBiDe-eOauhVa5QbM-BRelW2iwlhQD9lPMR50A9Lk/edit?usp=sharing
What am I doing wrong?
I was getting the same error. Then I realized that I got it because all the columns are in string format. After adding a field in integer format the issue was resolved.
It is important to follow the steps from the official documentation.
We need to take care of:
Retrieving the Google Drive URI by getting shareable link.
Enabling Google Drive access, because accessing data hosted within Google Drive requires an additional OAuth scope. We can use following command to authenticate with Google Drive:
gcloud auth login --enable-gdrive-access
Check if we are granted with required permissions and scopes. Finally, we can create a table.
Keep in mind that for JSON or CSV files, you can check the Auto-detect option to enable schema auto-detect. Schema auto-detection in the web UI is not currently supported for Google Sheets (though it is available using the bq command-line tool and the API).
I hope you find the above pieces of information useful.

How to create a searchable central repository of code documentation using DocFx

I'm looking to create a central repository for all of our published API documentation using DocFx. I have documentation auto-generated via my build (using TFS) and published through my release (using Octopus) just fine for multiple individual sites. However, I'm wanting to pull it altogether in one location. The thinking is that through a parent site you could filter content in any of the individual sites without having to drill down into them. Do you have a recommendation on how to do this?
Also, within this same documentation repository I want to provide the capability to search by all of the meta data (project-level documentation) across the hundreds of projects in our portfolio. This will give our BA, DEV and QA teams easier access to what all our systems do. I like the "filtering" capability built into DocFx, but I'm wanting full-text search across all of the meta data. Do you have a recommendation for this functionality as well?
To change the location of the docfx output, edit the docfx.json file and specify the dest value. By default it is "dest": "_site". For more formatting guidance, reference: https://dotnet.github.io/docfx/tutorial/docfx.exe_user_manual.html.
Regarding full-text search, that is possible by simply ensuring the ExtractSearchIndex post-processor is invoked (in order to generate an index.json file of keywords) and that the global _enableSearch value is set to true in the docfx.json file. A snippet from that file would look like:
"postProcessors": [ "ExtractSearchIndex" ],
"globalMetadata": {
"_enableSearch": "true"
}
For your first question:
I think what you expect is like the .NET API Browser. The source code behind this page is not open to public, so you need create this page by yourself, through collecting xrefmap.yml from multiple sites, and extract the needed data into this page.
For your second question:
DocFX uses Luna to scan all the output files and generate an index file called index.json for later search use. In your case, you should want to limit the search scope only in the metadata you defined. This is also not supported by DocFX by default. You can also use Luna in your central place to search these meta. You can create your specific index.json for each project first, and the cental place to collect them for the search page.

Can I search/get file by using File ID in Dropbox V2 API?

I'm using Dropbox V2 APIs (C#) to get files/folders from Dropbox account. I am able to fetch particular file/folder by using its specific path. I wanted to know whether there is any way I can fetch file/folder by using ID?
This depends on exactly which operation(s) you're referring to. For example, downloading files and getting metadata for files or folders support specifying file IDs:
https://www.dropbox.com/developers/documentation/http/documentation#files-download
https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata
You would specify the path as a string like "id:a4ayc_80_OEAAAAAAAAAYa".
Searching and listing folders currently do not support this though:
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
https://www.dropbox.com/developers/documentation/http/documentation#files-search
The same applies to the corresponding methods in the SDKs.
Edit: list_folder and search now do support file IDs.

Dropbox Webhooks API

I want to fetch the events related to my dropbox like I can see here , means I want to get when a particular file is added, changed, moved, deleted or renamed and by which user.
I have looked into the Webhooks docs. The webhook docs states the the response it sends to the callback url contails the userids, with which I can update the directory listing based on the webhook response for the user by calling the /delta.
But with it I cannot tell if there is an operation made for a file like a particular file has been renamed or deleted as since if I rename a file fro abc to xyz. If I get a response then I will look for the changes related to the file xyz which I will not find in my existing database so logically I will be making the events as deleted abc and added xyz, where as the reality is renamed abc to xyz.
It will be really grateful if you can help me regarding this.
There's no real way to detect a rename (versus a delete and an add) via the Dropbox API. You can use heuristics (like whether the new file has the same contents as the old file and was created around the same time as the old file was deleted), but those are just going to be guesses with varying levels of accuracy.
Also, there's currently no way via the API to see which user modified a file in a shared folder.
UPDATE: The Core API now includes (in beta) the ability to see who last modified a file in a shared folder. See https://www.dropbox.com/developers/blog/101/new-in-beta-shared-folder-metadata.
A file rename is reported as DeletedMetadata followed by a FileMetadata for the file.
What is annoying is that DeletedMetadata do not contain the file .id attribute, only .name and .path, while FileMetadata include all attributes (.id same as before any deletions/renames, updated .name and .path).
So you should have a local mapping connecting names/paths and IDs in order to know which file got deleted (when only DeletedMetadata is received) or renamed (when both DeletedMetadata and FileMetadata are received).