How can I get the ID of a shared folder when I know it's name, without using useDomainAdminAccess=true?
When impersonating a non-admin user with a service account, I can list all available shared folders with https://www.googleapis.com/drive/v3/drives. But strangely I'm not allowed to use the query string name = 'folderName'.
One solution would be to retrieve the list all folders and pick the entry with the desired name from the returned list. But that is a waste of resources.
I also cannot search for the root folder of the shared drive (using https://www.googleapis.com/drive/v3/files), because all root folders of shared drives have the fixed name "Drive".
Answer:
Unfortunately, this is simply not possible.
More Information:
As you have already noted, Most query terms require useDomainAdminAccess=true. This is pointed out in the Search for shared drives documentation, along with links to query terms and operators. From this page you can see that the only Shared drive-specific query terms are the following:
Query term
Valid Operators
Usage
Required useDomainAdminAccess setting
createdTime
<=, <, =, !=, >, >=
Date when the shared drive was created. Use RFC 3339 format, default timezone is UTC, e.g., 2012-06-04T12:00:00-08:00.
true
hidden
=, !=
Specifies whether or not the shared drive is hidden. Can be either true or false.
false
memberCount
<=, <, =, !=, >, >=
Number of users and groups that are members of the shared drive. Takes a numerical value.
true
name
contains, =, !=
Name of the shared drive. Surround with single quotes '. Escape single quotes in queries with ', such as 'Valentine\'s Day'.
true
organizerCount
<=, <, =, !=, >, >=
Number of users and groups that are organizers of the shared drive. Takes a numerical value.
true
Where only the parameter hidden is able to be used without the useDomainAdminAccess set to be true.
The only workaround here is as you have suggested - make a Drives:list query and filter locally for the Drive ID based on the name of the Drive.
Related
When using the Google Drive API v3, can one search for a file by its name using wildcards or regular expressions? The docs don't mention anything.
I am trying to match a set of files whose names have the format
backup_YYYY-MM-DD-XXXX_NameOfWebsite_xxxxxxxxxx.zip
And am wondering what's the best way to construct a pattern that might match it. Of course, I could follow the docs and just do something like:
q="name contains 'backup' and name contains 'NameOfWebsite'"
But if I need to match a different pattern, or something with more than 2 distinctive strings in its filename ("backup_" and "NameOfWebsite"), you can quickly see what a pain would be to construct a query in that way:
q="name contains 'string1' and name contains 'string2' and name contains...
Answer:
You can't use a wildcard in the middle of a file name when making a Drive.list request with a q parameter.
More Information:
The name field only takes three operators - =, != and contains:
The = operator is regular equivalence and with this you can not use a wildcard.
name = 'backup*' will return no results.
The != operator is not equivalence, not relevant here but does the opposite of =
The contains operator. You can use wildcards with this, but with restrictions:
name contains 'backup*' will return all files with filenames starting with the string backup.
name contains '*NameOfWebsite' will return all files with filenames that have a word starting with the string NameOfWebsite. The file name backup0194364-NameOfWebsite.zip will not be returned, because there is no space before the string.
Therefore, the only way for this to work is if you do it the way you have already started to realise; string chaining:
name contains 'backup' and name contains 'NameOfWebsite' and name contains ...
References:
Files: list | Google Drive API | Google Developers
Search for files | Google Drive API | Google Developers
Can we sort google drive files to show the newest or last modified ones on the top ?? I only can see the list and grid option for showing files in iframe. If not , any advice or alternative solution for this issue that my client is facing it ?
Here is the documentation you needed to list files from the drive.
This method accepts the q parameter, which is a search query combining
one or more search terms. For more information, see the Search for
Files and Team Drives guide.
And you can actually sort it by using the parameter orderBy.
A comma-separated list of sort keys. Valid keys are 'createdTime',
'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural',
'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and
'viewedByMeTime'. Each key sorts ascending by default, but may be
reversed with the 'desc' modifier. Example usage:
?orderBy=folder,modifiedTime desc,name. Please note that there is a
current limitation for users with approximately one million files in
which the requested sort order is ignored.
You can also test by Try it now.
To comply to regulations, I'm trying to download the purchase invoice documents (as PDF files) from some of my divisions to save them on-disk for archiving purposes.
I use Invantive Query Tool to do this. I like to know which table to use and how to export these attachments only regarding purchase invoice documents.
You can indeed do this by using the export options in Invantive Query Tool or Invantive Data Hub.
What you need is a query that hooks up the document information of type 20 (purchase invoices) with the actual attachment files. You can find a list of types and their description in the DocumentTypes view. You can find the document attachment files in the DocumentAttachmentFiles table.
When you have retrieved that, you can export the documents from that query to disk using a local export documents statement.
The full query is here:
use 123456
select /*+ join_set(dae, document, 10000) */ attachmentfromurl
, dct.division || '/' || dae.id || '-' || filename
filepath
from exactonlinerest..documents dct
join DocumentAttachmentFiles dae
on dae.division = dct.division
and dae.document = dct.id
where dct.Type = 20
order
by dct.division
, dae.id
local export documents in attachmentfromurl to "c:\temp\docs" filename column Filepath
Make sure to set the ID of the division right in the use statement (this is the technical ID, not the 'division number', which can contain duplicates). You can find that in the top menu bar under Partitions. Or simply use use all to get the documents from all divisions (this might take a while).
Also set the file path right where it says c:\temp\docs now. Then hit F5 in the Query Tool to execute, or run the script from Data Hub.
I need an efficient way to store IP address.
The query I would like to do is if IP is in the table (or in range).
I need to store ranges like,
192.168.0.1 - 192.168.1.255
And also individual IPs.
Since there are many records I think it will be a waste to store them one by one. But I would go for that if that would be the best.
Django does have GenericIPAddressField field, but it does not store ranges.
So what is my best solution?
You have two options, both involve the use of two columns.
Option one, store start IP end IP
class IPmodel(models.Model):
start_ip = models.GenericIPAddressField()
end_ip = models.GenericIPAddressField()
Option 2, store the IP and a network mask
class IPmodel(models.Model):
start_ip = models.GenericIPAddressField()
mask = models.IntegerField()
If you were to use option 1, your code might look like
IPmodel.objects.create(start_ip='192.168.1.0',end_ip='192.168.1.255')
IPmodel.objects.filter(end_ip__gt='192.168.1.10').filter(start_ip__lt='192.168.1.10')
If you used option 2, you would need to use F functions and the standard network address calculations to do your filtering.
SSIS newbie question:
I have found different usages of a user variable and hence the confusion.
I have defined a user variable customerName.
In some places, (e.g. Script Task Editor's ReadOnlyVariables, it being referred as User::customerName since there is no option to select customerName.
Then in Script Task (Edit script), I see that its being referred as
string custName = Dts.Variables["customerName"].Value.ToString();
and not as
string custName = Dts.Variables["User::customerName"].Value.String();
Where and how does this work? Is there any rule?
Either syntax should be acceptable in a script task. To further complicate matters, you could also reference it as string custName = Dts.Variables[0].Value.ToString();
The User bit refers to the namespace of an SSIS Variable. By default, you can access Variables in the System and User namespace but nothing prevents you from creating variables in a different spaace.
You're also going to run into #[User::customerName] syntax.