Skip to content

Commit 928606d

Browse files
author
adrianwells
authoredJan 16, 2019
Merge pull request itglue#47 from ecspresso/patch-2
Fix for itglue#46. @ecspresso, this looks good and performed basic testing so merging this PR.
2 parents b59b1d5 + ee15680 commit 928606d

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed
 

‎ITGlueAPI/ITGlueAPI.psd1

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ RootModule = '.\ITGlueAPI.psm1'
1717
# -- MAJOR version when you make incompatible API changes,
1818
# -- MINOR version when you add functionality in a backwards-compatible manner, and
1919
# -- PATCH version when you make backwards-compatible bug fixes.
20-
ModuleVersion = '2.0.3'
20+
21+
ModuleVersion = '2.0.4'
2122

2223
# ID used to uniquely identify this module
2324
#GUID = ''
@@ -225,4 +226,4 @@ HelpInfoURI = 'https://github.com/itglue/powershellwrapper/wiki'
225226
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
226227
# DefaultCommandPrefix = ''
227228

228-
}
229+
}

‎ITGlueAPI/Resources/Passwords.ps1

+21-23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function New-ITGluePasswords {
1010

1111
$resource_uri = '/passwords/'
1212

13-
if ($flexible_asset_type_id) {
13+
if ($organization_id) {
1414
$resource_uri = ('/organizations/{0}/relationships/passwords' -f $organization_id)
1515
}
1616

@@ -131,7 +131,7 @@ function Get-ITGluePasswords {
131131
try {
132132
$ITGlue_Headers.Add('x-api-key', (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'N/A', $ITGlue_API_Key).GetNetworkCredential().Password)
133133
$rest_output = Invoke-RestMethod -method 'GET' -uri ($ITGlue_Base_URI + $resource_uri) -headers $ITGlue_Headers `
134-
-ErrorAction Stop -ErrorVariable $web_error
134+
-body $body -ErrorAction Stop -ErrorVariable $web_error
135135
} catch {
136136
Write-Error $_
137137
} finally {
@@ -146,17 +146,17 @@ function Get-ITGluePasswords {
146146
function Set-ITGluePasswords {
147147
[CmdletBinding(DefaultParameterSetName = 'update')]
148148
Param (
149-
[CmdletBinding(DefaultParameterSetName = 'update')]
149+
[Parameter(ParameterSetName = 'update')]
150150
[Nullable[Int64]]$organization_id = $null,
151151

152-
[CmdletBinding(DefaultParameterSetName = 'update')]
152+
[Parameter(ParameterSetName = 'update')]
153153
[Nullable[Int64]]$id = $null,
154154

155-
[CmdletBinding(DefaultParameterSetName = 'update')]
155+
[Parameter(ParameterSetName = 'update')]
156156
[Boolean]$show_password = $false, # Passwords API defaults to $false
157157

158-
[CmdletBinding(DefaultParameterSetName = 'update')]
159-
[CmdletBinding(DefaultParameterSetName = 'bulk_update')]
158+
[Parameter(ParameterSetName = 'update')]
159+
[Parameter(ParameterSetName = 'bulk_update')]
160160
[Parameter(Mandatory = $true)]
161161
$data
162162
)
@@ -195,30 +195,28 @@ function Set-ITGluePasswords {
195195
function Remove-ITGluePasswords {
196196
[CmdletBinding(DefaultParameterSetName = 'destroy')]
197197
Param (
198-
[CmdletBinding(DefaultParameterSetName = 'destroy')]
198+
[Parameter(ParameterSetName = 'destroy')]
199199
[Nullable[Int64]]$id = $null,
200200

201-
[CmdletBinding(DefaultParameterSetName = 'bulk_destroy')]
201+
[Parameter(ParameterSetName = 'bulk_destroy')]
202202
[Nullable[Int64]]$filter_id = $null,
203203

204-
[CmdletBinding(DefaultParameterSetName = 'bulk_destroy')]
204+
[Parameter(ParameterSetName = 'bulk_destroy')]
205205
[String]$filter_name = '',
206206

207-
[CmdletBinding(DefaultParameterSetName = 'bulk_destroy')]
207+
[Parameter(ParameterSetName = 'bulk_destroy')]
208208
[Nullable[Int64]]$filter_organization_id = $null,
209209

210-
[CmdletBinding(DefaultParameterSetName = 'bulk_destroy')]
210+
[Parameter(ParameterSetName = 'bulk_destroy')]
211211
[Nullable[Int64]]$filter_password_category_id = $null,
212212

213-
[CmdletBinding(DefaultParameterSetName = 'bulk_destroy')]
213+
[Parameter(ParameterSetName = 'bulk_destroy')]
214214
[String]$filter_url = '',
215215

216-
[CmdletBinding(DefaultParameterSetName = 'bulk_destroy')]
216+
[Parameter(ParameterSetName = 'bulk_destroy')]
217217
[String]$filter_cached_resource_name = '',
218218

219-
[CmdletBinding(DefaultParameterSetName = 'update')]
220-
[CmdletBinding(DefaultParameterSetName = 'bulk_destroy')]
221-
[Parameter(Mandatory = $true)]
219+
[Parameter(ParameterSetName = 'bulk_destroy', Mandatory = $true)]
222220
$data
223221
)
224222

@@ -245,15 +243,15 @@ function Remove-ITGluePasswords {
245243
if ($filter_cached_resource_name) {
246244
$body += @{'filter[cached_resource_name]' = $filter_cached_resource_name}
247245
}
248-
}
249246

250-
$body += @{'data' = $data}
247+
$body += @{'data' = $data}
251248

252-
$body = ConvertTo-Json -InputObject $body -Depth $ITGlue_JSON_Conversion_Depth
249+
$body = ConvertTo-Json -InputObject $body -Depth $ITGlue_JSON_Conversion_Depth
250+
}
253251

254252
try {
255253
$ITGlue_Headers.Add('x-api-key', (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'N/A', $ITGlue_API_Key).GetNetworkCredential().Password)
256-
$rest_output = Invoke-RestMethod -method 'PATCH' -uri ($ITGlue_Base_URI + $resource_uri) -headers $ITGlue_Headers `
254+
$rest_output = Invoke-RestMethod -method 'DELETE' -uri ($ITGlue_Base_URI + $resource_uri) -headers $ITGlue_Headers `
257255
-body $body -ErrorAction Stop -ErrorVariable $web_error
258256
} catch {
259257
Write-Error $_
@@ -262,6 +260,6 @@ function Remove-ITGluePasswords {
262260
}
263261

264262
$data = @{}
265-
$data = $rest_output
263+
$data = $rest_output
266264
return $data
267-
}
265+
}

0 commit comments

Comments
 (0)
Please sign in to comment.