Skip to content

Commit

Permalink
!deploy v2.18.0 - Add Fields param for #87, add new functions from #108
Browse files Browse the repository at this point in the history
…, add Sync-GSUserCache for #87

## 2.18.0

* [Issue #87](#87)
  * Added: `Get-GSCourseParticipant` and `Get-GSClassroomUserProfile` now have the `Fields` parameter
  * Added: `Sync-GSUserCache` to create a hashtable of users for quick lookups throughout scripts
* [Issue #53](#53) via [PR #108](#108) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
  * Added: `Get-GSContactList`
  * Added: `Remove-GSContact`
* Other additions via [PR #108](#108) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
  * Added: `Remove-GSCalendarEvent`
  * Added: `New-GSGmailLabel`
  * Added: `Remove-GSGmailLabel`
  • Loading branch information
scrthq committed Nov 6, 2018
2 parents b625bc0 + 3441f77 commit 2cb8c3a
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 90 deletions.
136 changes: 72 additions & 64 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,76 @@
# Changelog

* [2.17.3](#2173)
* [2.17.2](#2172)
* [2.17.1](#2171)
* [2.17.0](#2170)
* [2.16.1](#2161)
* [2.16.0](#2160)
* [2.15.4](#2154)
* [2.15.3](#2153)
* [2.15.2](#2152)
* [2.15.1](#2151)
* [2.15.0](#2150)
* [2.14.1](#2141)
* [2.14.0](#2140)
* [2.13.2](#2132)
* [2.13.1](#2131)
* [2.13.0](#2130)
* [2.12.1](#2121)
* [2.12.0](#2120)
* [2.11.0](#2110)
* [2.10.2](#2102)
* [2.10.1](#2101)
* [2.10.0](#2100)
* [2.9.0](#290)
* [2.8.1](#281)
* [2.8.0](#280)
* [2.7.2](#272)
* [2.7.1](#271)
* [2.7.0](#270)
* [2.6.3](#263)
* [2.6.2](#262)
* [2.6.1](#261)
* [2.6.0](#260)
* [2.5.4](#254)
* [2.5.3](#253)
* [2.5.2](#252)
* [2.5.1](#251)
* [2.5.0](#250)
* [2.4.0](#240)
* [2.3.0](#230)
* [2.2.1](#221)
* [2.2.0](#220)
* [2.1.5](#215)
* [2.1.3 / 2.1.4](#213--214)
* [2.1.2](#212)
* [2.1.1](#211)
* [2.1.0](#210)
* [2.0.3](#203)
* [2.0.2](#202)
* [2.0.1](#201)
* [2.0.0](#200)
* [New Functionality](#new-functionality)
* [Breaking Changes in 2.0.0](#breaking-changes-in-200)
* [Gmail Delegation Management Removed](#gmail-delegation-management-removed)
* [Functions Removed](#functions-removed)
* [Functions Aliased](#functions-aliased)

#### 2.17.3

* Added Get-GSContactList
* Added Remove-GSContact
* Added Remove-GSCalendarEvent
* Added New-GSGmailLabel
* Added Remmove-GSGmailLabel
* [Changelog](#changelog)
* [2.18.0](#2180)
* [2.17.2](#2172)
* [2.17.1](#2171)
* [2.17.0](#2170)
* [2.16.1](#2161)
* [2.16.0](#2160)
* [2.15.4](#2154)
* [2.15.3](#2153)
* [2.15.2](#2152)
* [2.15.1](#2151)
* [2.15.0](#2150)
* [2.14.1](#2141)
* [2.14.0](#2140)
* [2.13.2](#2132)
* [2.13.1](#2131)
* [2.13.0](#2130)
* [2.12.1](#2121)
* [2.12.0](#2120)
* [2.11.0](#2110)
* [2.10.2](#2102)
* [2.10.1](#2101)
* [2.10.0](#2100)
* [2.9.0](#290)
* [2.8.1](#281)
* [2.8.0](#280)
* [2.7.2](#272)
* [2.7.1](#271)
* [2.7.0](#270)
* [2.6.3](#263)
* [2.6.2](#262)
* [2.6.1](#261)
* [2.6.0](#260)
* [2.5.4](#254)
* [2.5.3](#253)
* [2.5.2](#252)
* [2.5.1](#251)
* [2.5.0](#250)
* [2.4.0](#240)
* [2.3.0](#230)
* [2.2.1](#221)
* [2.2.0](#220)
* [2.1.5](#215)
* [2.1.3 / 2.1.4](#213--214)
* [2.1.2](#212)
* [2.1.1](#211)
* [2.1.0](#210)
* [2.0.3](#203)
* [2.0.2](#202)
* [2.0.1](#201)
* [2.0.0](#200)
* [New Functionality](#new-functionality)
* [Breaking Changes in 2.0.0](#breaking-changes-in-200)
* [Gmail Delegation Management Removed](#gmail-delegation-management-removed)
* [Functions Removed](#functions-removed)
* [Functions Aliased](#functions-aliased)

***

## 2.18.0

* [Issue #87](https://github.com/scrthq/PSGSuite/issues/87)
* Added: `Get-GSCourseParticipant` and `Get-GSClassroomUserProfile` now have the `Fields` parameter
* Added: `Sync-GSUserCache` to create a hashtable of users for quick lookups throughout scripts
* [Issue #53](https://github.com/scrthq/PSGSuite/issues/53) via [PR #108](https://github.com/scrthq/PSGSuite/pull/108) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
* Added: `Get-GSContactList`
* Added: `Remove-GSContact`
* Other additions via [PR #108](https://github.com/scrthq/PSGSuite/pull/108) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
* Added: `Remove-GSCalendarEvent`
* Added: `New-GSGmailLabel`
* Added: `Remove-GSGmailLabel`

## 2.17.2

Expand All @@ -71,7 +79,7 @@

## 2.17.1

- Validated deployment via Azure Pipelines
* Validated deployment via Azure Pipelines

## 2.17.0

Expand Down
2 changes: 1 addition & 1 deletion PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGSuite.psm1'

# Version number of this module.
ModuleVersion = '2.17.3'
ModuleVersion = '2.18.0'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
10 changes: 8 additions & 2 deletions PSGSuite/Public/Classroom/Get-GSClassroomUserProfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ function Get-GSClassroomUserProfile {
* the email address of the user
* the string literal "me", indicating the requesting user
.PARAMETER Fields
The specific fields to fetch
.EXAMPLE
Get-GSClassroomUserProfile -UserId aristotle@athens.edu
#>
Expand All @@ -23,7 +26,10 @@ function Get-GSClassroomUserProfile {
[Alias('Id','PrimaryEmail','Mail','UserKey')]
[ValidateNotNullOrEmpty()]
[String[]]
$UserId
$UserId,
[parameter(Mandatory = $false)]
[String[]]
$Fields = '*'
)
Begin {
$serviceParams = @{
Expand All @@ -45,7 +51,7 @@ function Get-GSClassroomUserProfile {
}
Write-Verbose "Getting Classroom User Profile for '$part'"
$request = $service.UserProfiles.Get($part)
$request.Fields = "*"
$request.Fields = "$($Fields -join ",")"
$request.Execute()
}
catch {
Expand Down
14 changes: 10 additions & 4 deletions PSGSuite/Public/Classroom/Get-GSCourseParticipant.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ function Get-GSCourseParticipant {
.PARAMETER User
The user to authenticate the request as
.PARAMETER Fields
The specific fields to fetch
.EXAMPLE
Get-GSCourseParticipant -Teacher aristotle@athens.edu
#>
Expand All @@ -58,7 +61,10 @@ function Get-GSCourseParticipant {
$Student,
[parameter(Mandatory = $false)]
[String]
$User = $Script:PSGSuite.AdminEmail
$User = $Script:PSGSuite.AdminEmail,
[parameter(Mandatory = $false)]
[String[]]
$Fields = '*'
)
Begin {
if ($User -ceq 'me') {
Expand Down Expand Up @@ -89,7 +95,7 @@ function Get-GSCourseParticipant {
}
Write-Verbose "Getting Student '$part' for Course '$CourseId'"
$request = $service.Courses.Students.Get($CourseId,$part)
$request.Fields = "*"
$request.Fields = "$($Fields -join ",")"
$request.Execute()
}
catch {
Expand All @@ -116,7 +122,7 @@ function Get-GSCourseParticipant {
}
Write-Verbose "Getting Teacher '$part' for Course '$CourseId'"
$request = $service.Courses.Teachers.Get($CourseId,$part)
$request.Fields = "*"
$request.Fields = "$($Fields -join ",")"
$request.Execute()
}
catch {
Expand All @@ -141,7 +147,7 @@ function Get-GSCourseParticipant {
$service.Courses.Students.List($CourseId)
}
}
$request.Fields = "*"
$request.Fields = "$($Fields -join ",")"
[int]$retrieved = 0
[int]$i = 1
do {
Expand Down
10 changes: 5 additions & 5 deletions PSGSuite/Public/Gmail/Remove-GSGmailLabel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ function Remove-GSGmailLabel {
.DESCRIPTION
Removes a Gmail label
.PARAMETER LabelId
The unique Id of the label to remove
.PARAMETER User
The primary email of the user to remove the label from
Defaults to the AdminEmail user
.PARAMETER LabelId
The unique Id of the label to remove
.EXAMPLE
Remove-GSGmailLabel -LabelId ANe1Bmj5l3089jd3k1eQbY90g9rXswjS03LVOw
Expand All @@ -25,12 +25,12 @@ function Remove-GSGmailLabel {
[parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)]
[Alias("Id")]
[string[]]
$LabelId
$LabelId,
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[Alias("PrimaryEmail", "UserKey", "Mail")]
[ValidateNotNullOrEmpty()]
[string]
$User = $Script:PSGSuite.AdminEmail,
$User = $Script:PSGSuite.AdminEmail
)
Begin {
if ($User -ceq 'me') {
Expand Down
76 changes: 76 additions & 0 deletions PSGSuite/Public/Users/Sync-GSUserCache.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
function Sync-GSUserCache {
<#
.SYNOPSIS
Syncs your GS Users to a hashtable contained in the global scoped variable $global:GSUserCache for fast lookups in scripts.
.DESCRIPTION
Syncs your GS Users to a hashtable contained in the global scoped variable $global:GSUserCache for fast lookups in scripts.
.PARAMETER Filter
The filter to use with Get-GSUser to populate your UserCache with.
Defaults to * (all users).
If you'd like to limit to just Active (not suspended) users, use the following filter:
"IsSuspended -eq '$false'"
.PARAMETER Keys
The user properties to use as keys in the Cache hash.
Available values are:
* PrimaryEmail
* Id
* Alias
Defaults to all 3.
.PARAMETER PassThru
If $true, returns the hashtable as output
.EXAMPLE
Sync-GSUserCache -Filter 'IsSuspended=False'
Fills the $global:GSUserCache hashtable with all active users using the default Keys.
#>
[CmdLetBinding()]
Param (
[parameter(Mandatory = $false, Position = 0)]
[String[]]
$Filter = @('*'),
[parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[ValidateSet('PrimaryEmail','Id','Alias')]
[String[]]
$Keys = @('PrimaryEmail','Id','Alias'),
[parameter(Mandatory = $false)]
[Switch]
$PassThru
)
Begin {
$global:GSUserCache = @{}
}
Process {
Write-Verbose "Syncing users to `$global:GSUserCache"
Get-GSUser -Filter $Filter | ForEach-Object {
if ($Keys -contains 'Id') {
$global:GSUserCache[$_.Id] = $_
}
if ($Keys -contains 'PrimaryEmail') {
$global:GSUserCache[$_.PrimaryEmail] = $_
}
if ($Keys -contains 'Alias') {
foreach ($email in $_.Emails.Address) {
if (-not ($global:GSUserCache.ContainsKey($email))) {
$global:GSUserCache[$email] = $_
}
}
}
}
}
End {
if ($PassThru) {
return $global:GSUserCache
}
}
}
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,18 @@ Update-GSSheetValue Export-GSSheet

### Most recent changes

#### 2.17.3
#### 2.18.0

* Added Get-GSContactList
* Added Remove-GSContact
* Added Remove-GSCalendarEvent
* Added New-GSGmailLabel
* Added Remmove-GSGmailLabel
* [Issue #87](https://github.com/scrthq/PSGSuite/issues/87)
* Added: `Get-GSCourseParticipant` and `Get-GSClassroomUserProfile` now have the `Fields` parameter
* Added: `Sync-GSUserCache` to create a hashtable of users for quick lookups throughout scripts
* [Issue #53](https://github.com/scrthq/PSGSuite/issues/53) via [PR #108](https://github.com/scrthq/PSGSuite/pull/108) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
* Added: `Get-GSContactList`
* Added: `Remove-GSContact`
* Other additions via [PR #108](https://github.com/scrthq/PSGSuite/pull/108) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_
* Added: `Remove-GSCalendarEvent`
* Added: `New-GSGmailLabel`
* Added: `Remove-GSGmailLabel`

#### 2.17.2

Expand All @@ -152,11 +157,11 @@ Update-GSSheetValue Export-GSSheet

#### 2.16.1

- Fixed: Module deployment segment in psake script deploying decompiled/broken module
* Fixed: Module deployment segment in psake script deploying decompiled/broken module

#### 2.16.0

- Updated: Build script to compile module into a single PSM1 file for cleanliness and loading speed improvements
* Updated: Build script to compile module into a single PSM1 file for cleanliness and loading speed improvements

#### 2.15.4

Expand Down
Loading

0 comments on commit 2cb8c3a

Please sign in to comment.