How to set automatic deletion of folder with Box REST api V2? - box-api

I want to set automatic delete date for a folder in Box through REST api. I don't see any option for it now? Is it possible through Box v2 api?

What is the particular use case? If it's to prevent a user from having access to a folder, perhaps setting an unshare date may work for you? I don't believe you can do the same for the deletion of a folder.
Is creating a service with a timer job that executes the delete folder request out of the question?

Related

Drive API update

We got the Drive API update changes last week.
The email content:
Very appreciate if you can help to confirm the following two questions:
We have tried the resourceKey, but it didn't work, is there a specific time for it to take effect?
URL type fields such as exportLinks, webContentLink, and webViewLink
will include the resourceKey.
Currently, we are just using the webViewLink, do we still need to update our code for accessing files to include the appropriate resource keys?
Beginning Monday, September 13, 2021, Google will begin enforcing a security update to Google Drive. Users like you who own or manage impacted files will be notified about the affected files beginning Monday, July 26, 2021.
This security update adds a resource key that makes sharing links from Google Drive files more secure. When file links are updated, users may receive new file access requests. Those who do not have accessed to the files before the update will have to use URLs containing resource keys to access the files.
To avoid broken links, users should update Google Drive links on their websites and shared resources before September 13.
Update Impacts Developers
Affected items are those that have a Drive File API permission with type=domain or type=anyone where withLink=true (v2) or allowFileDiscovery=false (v3).
In addition to the item ID, applications may need a resource key to access files. Use Google’s Developer resource to learn more about how this update will impact your projects.
access
You can also check that the resourceKey security update is already activated in your domain by going to Google Admin.
The effects should have kicked in today, the 13th. So far I'm NOT getting the resourceKey when I call for a file list. Yes, the resourceKey is part of the field list I send. Testing this in https://developers.google.com/drive/api/v3/reference/files/get using * for field list and a file ID that SHOULD be returning a resourceKey there is nothing returned for resourceKey. We are getting 403 errors on certain operation in our code - only place where a direct URL to the Google drive is used.
Essentially we do NOT have the resourceKey supplied to us so there is no way to add it to the URL!
When I checked my test GDrive before the weekend in order to turn this security update ON, the console indicated that it was already turned on, which I had certainly not done!

How to not detect opening of files and folders in google drive changes api

I am building an expressjs application using the google drive api that notifies the user whenever there is a file change in their google drive through webhooks. However, i am also receiving webhooks when i open/view a folder or a file, which is completely unnecessary. Is it possible to only receive webhooks whenever a new file is created or deleted in the drive? And if so, how do i do it?
There is no direct way unfortunately.
You will likely have to make another request once your app has been notified of a change. Its possible you may have to persist some data to compare with depending on what you need to do exactly. The watch endpoint, as you have seen, will notify you of almost every change, including views. So you'll need to find a way to filter these out.
If you are trying to get create/deleted times only then I would suggest taking the file id from the change notification and making a request to get the file metadata and seeing if the file was created in the last 5 minutes (or less) for example. You can speed this up by only getting the createdTime field for instance.
For deleted, you can either get the type of change directly from the change notification, but this will only notify you if you have deleted it permanently i.e. not in the trash. Trash events look just the same as the others. If you need trash notifications, it is going to be more complicated. There is a trashed attribute, but not a timestamp for it. If you need this then you will probably have to keep a snapshot of which files are trashed and then every time you get a request, check to see if the file that changed is now trashed.
There is an active feature request for this
Support event type filtering for Changes watch channel
Go and give it a ☆ to let Google know that you want this feature!

Import custom field options from one Infusionsoft app to another

I am trying to find a way to update a custom field automatically within multiple Partner Infusionsoft apps when I manually update the field with new options within our main Infusionsoft app.
The idea is to avoid manually logging into every Partner Infusionsoft app that we manage, individually, to update the custom field options so that they match our main app custom field options when it is updated. The custom field is constantly being updated with new options that need to be mirrored within all of our partner apps.
The process would not need to be entirely automatic. We could manage using a trigger to update the rest of the apps whenever we have manually updated the custom field in our main app.
Can anyone please steer me in the right direction or tell me if this isn't even possible?
Yes this is possible with the API. Unfortunately there isn't a REST webhook for when a custom field is modified, so it would require a constant poll against what you would consider the master application. Constantly check the custom field and see if it's values changed. This is the rest documentation for that:
https://developer.infusionsoft.com/docs/rest/#!/Contact/retrieveContactModelUsingGET
That will include all the possible options for the field.
Unfortunately you can't modify a custom field in the newer REST API so you will have to use xmlrpc. The rest API only let's you create according to the documentation.
Here are the docs for the endpoint you would use with xmlrpc to update all the other apps to match the master application.
https://developer.infusionsoft.com/docs/xml-rpc/#data
https://developer.infusionsoft.com/docs/table-schema/
DataFormField is the custom field information. You would use the data endpoint to modify the values.
Be careful when you are polling the master application to not go over usage limits and apply best practices.

Transfer ownership for ALL files in user's google drive - using google-api-java-client and the Drive SDK

We have a google corporate account and need to transfer ALL of a user's google drive files to another account in certain instances. We want to do what is described at the following link for "all files" but programatically via the latest Drive API http://support.google.com/a/bin/answer.py?hl=en&answer=1247799
We are currently using the following API version(s) below, coupled with domain wide authority delegation as described at https://developers.google.com/drive/delegation and are able to see a user's files, iterate over them etc.
google-api-services-drive 1.14.2-beta
google-api-client 1.14.1-beta
My question is this: it appears that the only way to change permissions is by fileId by fileId etc. Instead of having to traverse and iterate over an entire set of user's files, if we just want to transfer ALL of a user's files to another particular user: is there a way in the API to do this (ownership transfer for ALL files) rather than individual requests file/by file?
Also when transferring ownershisp, must the transferee be in the same #domain or can it be another #domain we manage? I read somewhere that you can only transfer to owners in the same domain. Does this still hold true? For instance we manage #myCompany.com and have our corporate account registered under that, however that shell account has several sub-domains within it. We would like to transfer files from users in the sub-domains to a central user in the #myCompany domain.
You need to change permissions file by file, there is no updateAll type of functionality at the moment.
You cant transfer the ownership to another domain's user. Ownership can only be transferred to another user in the same domain as the current owner.
This answer doesn't directly answer your question, but it could be helpful for both you and future visitors.
As of now, you can mass transfer files to new users with Google's new Admin console. It doesn't let you filter for specific folders, but it does allow you to transfer all of one user's Drive files to a second user.
I know you were trying to create something which uses the API to iterate through folders and files, and you probably have a very specific use-case in mind. However, in the case where you have employees leaving, or you need to transfer everything, using the following method is fast and simple.
Open the Google Admin console
Go to Google Apps > Drive
Click on "Transfer ownership"
Fill out both user fields and submit
This process will even email both users once the process is completed.
You can do this with a single call to the Data Transfer API
Exactly what is needed but only with API!
Open the Google Admin console
Go to Google Apps > Drive
Click on "Transfer ownership"
Fill out both user fields and submit
This process will even email both users once the process is completed.
If this is not possible via API calls, then there is no point deleting a user using API.

Is there an API that tells me whether a folder is synced or not?

I'm trying to write a scirpt to sync Box folders programmatically, and I need to know first whether the folder is synced or not.
When getting a folder's information, you can request the sync_state parameter, which is not returned by default. Possible values for sync_state are synced, not_synced, and partially_synced. Files inherit the sync state of their parent folder.
Folder info: GET https://api.box.com/folders/12345?fields=sync_state
These parameters are listed in the Box V2 API documentation:
http://developers.box.com/docs/#folders-folder-object