SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
234 stars 68 forks source link

Additional Reports Since Last Edited #359 #360

Open gsa-hub opened 2 years ago

FISHMANPET commented 2 years ago

This looks good to me. Just to be clear, you pulled from this list right? I see the REST API has more options but they're not in that list.

I did play around with the .Net just a bit:

PS C:\Users\bajurny\Documents\GitHub\PSGSuite-upstream> [Google.Apis.Admin.Reports.reports_v1.ActivitiesResource+ListRequest+ApplicationNameEnum].GetEnumNames()       
AccessTransparency
Admin
Calendar
Chat
Drive
Gcp
Gplus
Groups
GroupsEnterprise
Jamboard
Login
Meet
Mobile
Rules
Saml
Token
UserAccounts
ContextAwareAccess
Chrome
DataStudio
Keep

So first, it looks like the 4 missing values from the API reference are supported by the library, ContextAwareAccess, Chrome, DataStudio, and Keep.

Second, since I figured out how to get all the possible values out of the enumeration, I think it might be possible use that to validate dynamically (either putting [Google.Apis.Admin.Reports.reports_v1.ActivitiesResource+ListRequest+ApplicationNameEnum].GetEnumNames() as the ValidateSet or using ValidateScript. I might play with that a bit, but you're welcome to as well if you're still interested.

FISHMANPET commented 2 years ago

Well, setting the param like this seems to work:

[parameter(Mandatory = $false,Position = 1)]
[ArgumentCompleter(
    {
        param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
        $possibleValues = [Google.Apis.Admin.Reports.reports_v1.ActivitiesResource+ListRequest+ApplicationNameEnum].GetEnumNames()
        $possibleValues | Where-Object {$_ -like "$WordToComplete*"}
    }
)]
[ValidateScript({[Google.Apis.Admin.Reports.reports_v1.ActivitiesResource+ListRequest+ApplicationNameEnum].GetEnumnames()})]
[String]
$ApplicationName = "Admin",

It looks like those 4 missing values are only there in the version of the library that's used in PSCore, the net45 library doesn't have them. I'd say you're fine to leave the help text as is, and update the parameter as above, and then if the library changes, it will still be supported without needing to manually add the new values to the parameter list.

I know someday @scrthq would like to drop support for anything below PS 5.1 which would take care of the library inconsistency, but that's a future thing.