Skip to content

Commit

Permalink
added ChromeOSDevice support for #147
Browse files Browse the repository at this point in the history
  • Loading branch information
scrthq committed Feb 4, 2019
1 parent 7682c9d commit a30a78f
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 28 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

* [Changelog](#changelog)
* [2.22.4](#2224)
* [2.22.3](#2223)
* [2.22.2](#2222)
* [2.22.1](#2221)
Expand Down Expand Up @@ -72,6 +73,12 @@

***

## 2.22.4

* [Issue #147](https://github.com/scrthq/PSGSuite/issues/147)
* Added: `Get-GSChromeOSDevice` - Handles Get or List requests, depending on if you specify a ResourceId or not.
* Added: `Update-GSChromeOSDevice` - Handles Action, Move and/or Patch requests depending on the parameters passed.

## 2.22.3

* [Issue #144](https://github.com/scrthq/PSGSuite/issues/144)
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.23.0'
ModuleVersion = '2.22.4'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Move-GSChromeOSDevice {
Scope = 'https://www.googleapis.com/auth/admin.directory.device.chromeos'
ServiceType = 'Google.Apis.Admin.Directory.directory_v1.DirectoryService'
}
$service = New-GoogleService @serviceParams
$service = New-GoogleService @serviceParams -Verbose:$false
$customerId = if ($Script:PSGSuite.CustomerID) {
$Script:PSGSuite.CustomerID
}
Expand Down
29 changes: 21 additions & 8 deletions PSGSuite/Public/Security/Update-GSChromeOSDevice.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@ function Update-GSChromeOSDevice {
"reenable": Re-enable a disabled device when a misplaced device is found or a lost device is returned. You can also use this feature if you accidentally mark a Chrome device as disabled.
Note: The re-enable action can only be performed on devices marked as disabled.
.PARAMETER DeprovisionReason
Only used when the action is deprovision. With the deprovision action, this field is required.
Note: The deprovision reason is audited because it might have implications on licenses for perpetual subscription customers.
Acceptable values are:
* "different_model_replacement": Use if you're upgrading or replacing your device with a newer model of the same device.
* "retiring_device": Use if you're reselling, donating, or permanently removing the device from use.
* "same_model_replacement": Use if a hardware issue was encountered on a device and it is being replaced with the same model or a like-model replacement from a repair vendor / manufacturer.
.PARAMETER OrgUnitPath
Full path of the target organizational unit or its ID that you would like to move the device to.
.EXAMPLE
Update-GSChromeOSDevice -ResourceId 'AFiQxQ8Qgd-rouSmcd2UnuvhYV__WXdacTgJhPEA1QoQJrK1hYbKJXm-8JFlhZOjBF4aVbhleS2FVQk5lI069K2GULpteTlLVpKLJFSLSL' -Action approve
Update-GSChromeOSDevice -ResourceId 'AFiQxQ8Qgd-rouSmcd2UnuvhYV__WXdacTgJhPEA1QoQJrK1hYbKJXm-8JFlhZOjBF4aVbhleS2FVQk5lI069K2GULpteTlLVpKLJFSLSL' -Action deprovision -DeprovisionReason retiring_device
Approves the ChromeOS device with the specified Id
Deprovisions the retired ChromeOS device
#>
[OutputType('Google.Apis.Admin.Directory.directory_v1.Data.ChromeOSDevice')]
[cmdletbinding()]
Expand All @@ -33,15 +46,16 @@ function Update-GSChromeOSDevice {
[String[]]
$ResourceId,
[parameter(Mandatory = $false)]
[String]
$OrgUnitPath,
[parameter(Mandatory = $false)]
[ValidateSet('deprovision','disable','reenable')]
[String]
$Action,
[parameter(Mandatory = $false)]
[ValidateSet('different_model_replacement','retiring_device','same_model_replacement')]
[String]
$DeprovisionReason,
[parameter(Mandatory = $false)]
[String]
$DeprovisionReason
$OrgUnitPath

)
Begin {
Expand Down Expand Up @@ -111,9 +125,8 @@ function Update-GSChromeOSDevice {
foreach ($dev in $ResourceId) {
try {
Write-Verbose "Updating Chrome OS Device '$dev'"
$request = $service.Chromeosdevices. ($actionBody,$customerId,$dev)
$request = $service.Chromeosdevices.Patch($actionBody,$customerId,$dev)
$request.Execute()
Write-Verbose "Chrome OS Device was successfully updated"
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ Update-GSSheetValue Export-GSSheet

[Full CHANGELOG here](https://github.com/scrthq/PSGSuite/blob/master/CHANGELOG.md)

#### 2.22.3
#### 2.22.4

* [Issue #144](https://github.com/scrthq/PSGSuite/issues/144)
* Updated: `Start-GSDriveFileUpload` to not call `[System.Console]::CursorVisible` when `$Host` is PowerShell ISE
* [Issue #147](https://github.com/scrthq/PSGSuite/issues/147)
* Added: `Get-GSChromeOSDevice` - Handles Get or List requests, depending on if you specify a ResourceId or not.
* Added: `Update-GSChromeOSDevice` - Handles Action, Move and/or Patch requests depending on the parameters passed.
29 changes: 15 additions & 14 deletions Tests/3. Integration Tests/PSGSuite.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
$projectRoot = Resolve-Path "$PSScriptRoot\..\.."
$ModulePath = Resolve-Path "$projectRoot\BuildOutput\$($env:BHProjectName)"
$decompiledModulePath = Resolve-Path "$projectRoot\$($env:BHProjectName)"
if ($ENV:BUILD_BUILDURI -like 'vstfs:*') {
$projectRoot = Resolve-Path "$PSScriptRoot\..\.."
$ModulePath = Resolve-Path "$projectRoot\BuildOutput\$($env:BHProjectName)"
$decompiledModulePath = Resolve-Path "$projectRoot\$($env:BHProjectName)"

$Verbose = @{}
if ($ENV:BHBranchName -eq "development" -or $env:BHCommitMessage -match "!verbose") {
$Verbose.add("Verbose",$True)
}
$moduleRoot = Split-Path (Resolve-Path "$ModulePath\*\*.psd1")

Import-Module $ModulePath -Force -Verbose:$false
Import-PSGSuiteConfig -Json $env:PSGSuiteConfigJson -Temporary -Verbose
$Verbose = @{}
if ($ENV:BHBranchName -eq "development" -or $env:BHCommitMessage -match "!verbose") {
$Verbose.add("Verbose",$True)
}
$moduleRoot = Split-Path (Resolve-Path "$ModulePath\*\*.psd1")

$u = Get-GSUser
$u | Select-Object @{N="GivenName";E={$_.Name.GivenName}},OrgUnitPath,Kind
Import-Module $ModulePath -Force -Verbose:$false
Import-PSGSuiteConfig -Json $env:PSGSuiteConfigJson -Temporary -Verbose

Send-GmailMessage -From $u.PrimaryEmail -To $u.PrimaryEmail -Subject "Hello from Azure Pipelines + PS Version $($PSVersionTable.PSVersion.ToString())!" -Body "<pre>`n$((Get-ChildItem Env: | Where-Object {$_.Name -match '^(BUILD_|BH).*$'} | Format-Table -AutoSize | Out-String).Trim())`n</pre>" -BodyAsHtml -Verbose
$u = Get-GSUser
$u | Select-Object @{N="GivenName";E={$_.Name.GivenName}},OrgUnitPath,Kind

Send-GmailMessage -From $u.PrimaryEmail -To $u.PrimaryEmail -Subject "Hello from Azure Pipelines + PS Version $($PSVersionTable.PSVersion.ToString())!" -Body "<pre>`n$((Get-ChildItem Env: | Where-Object {$_.Name -match '^(BUILD_|BH).*$'} | Format-Table -AutoSize | Out-String).Trim())`n</pre>" -BodyAsHtml -Verbose
}
<#
Describe "Function contents" -Tag 'Module' {
Context "Get-GSUser should return a user" {
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ else {
$global:ForceDeploy = $false
}
Invoke-psake @psakeParams @verbose
if ($Task -contains 'Import' -and $psake.build_success) {
if (($Task -contains 'Import' -or $Task -contains 'Test') -and $psake.build_success) {
Import-Module ([System.IO.Path]::Combine($env:BHBuildOutput,$env:BHProjectName)) -Verbose:$false
}
exit ( [int]( -not $psake.build_success ) )
Expand Down

0 comments on commit a30a78f

Please sign in to comment.