Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Reports Since Last Edited #359 #360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gsa-hub
Copy link
Contributor

@gsa-hub gsa-hub commented Oct 31, 2021

No description provided.

@FISHMANPET FISHMANPET added this to the v2.37.0 milestone Mar 28, 2022
@FISHMANPET
Copy link
Collaborator

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
Copy link
Collaborator

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.

@@ -60,7 +68,7 @@ function Get-GSActivityReport {
[String]
$UserKey = 'all',
[parameter(Mandatory = $false,Position = 1)]
[ValidateSet("Admin","Calendar","Drive","Groups","GPlus","Login","Mobile","Rules","Token")]
[ValidateSet("AccessTransparency","Admin","Calendar","Chat","Drive","Gcp","Gplus","Groups","GroupsEnterprise","Jamboard","Login","Meet","Mobile","Rules","Saml","Token","UserAccounts")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this ValidateSet Dynamic with this code:

[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",

That will use the list from the enum to validate against, and also use it for argument completion (aka pressing Tab).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants