From fd2f5c51c70e5be3d2671d5c6facc86df2727f68 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Wed, 14 Jul 2021 11:09:12 +0300 Subject: [PATCH] Allow to set http request method --- SnipeitPS/Public/New-SnipeitModel.ps1 | 2 -- SnipeitPS/Public/Set-SnipeitAccessory.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitCategory.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitCompany.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitComponent.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitConsumable.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitCustomField.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitDepartment.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitLicense.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitLocation.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitModel.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitStatus.ps1 | 8 +++++++- SnipeitPS/Public/Set-SnipeitUser.ps1 | 6 ++++++ 14 files changed, 90 insertions(+), 14 deletions(-) diff --git a/SnipeitPS/Public/New-SnipeitModel.ps1 b/SnipeitPS/Public/New-SnipeitModel.ps1 index cc6b8f0..c15616e 100644 --- a/SnipeitPS/Public/New-SnipeitModel.ps1 +++ b/SnipeitPS/Public/New-SnipeitModel.ps1 @@ -23,8 +23,6 @@ .PARAMETER image Asset model Image filename and path - - .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command diff --git a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 index 66032dc..cbb55d2 100644 --- a/SnipeitPS/Public/Set-SnipeitAccessory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitAccessory.ps1 @@ -50,6 +50,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfoeItInfo command @@ -101,6 +104,9 @@ function Set-SnipeitAccessory() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -123,7 +129,7 @@ function Set-SnipeitAccessory() { foreach($accessory_id in $id){ $Parameters = @{ Uri = "$url/api/v1/accessories/$accessory_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCategory.ps1 b/SnipeitPS/Public/Set-SnipeitCategory.ps1 index 33edafd..f10b21e 100644 --- a/SnipeitPS/Public/Set-SnipeitCategory.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCategory.ps1 @@ -26,6 +26,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -65,6 +68,9 @@ function Set-SnipeitCategory() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -83,7 +89,7 @@ function Set-SnipeitCategory() foreach($category_id in $id){ $Parameters = @{ Uri = "$url/api/v1/categories/$category_id" - Method = 'Put' + Method = $RequestType Body = $values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCompany.ps1 b/SnipeitPS/Public/Set-SnipeitCompany.ps1 index ee12e3c..923e76d 100644 --- a/SnipeitPS/Public/Set-SnipeitCompany.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCompany.ps1 @@ -17,6 +17,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -48,6 +51,9 @@ function Set-SnipeitCompany() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -63,7 +69,7 @@ function Set-SnipeitCompany() foreach($company_id in $id){ $Parameters = @{ Uri = "$url/api/v1/companies/$company_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitComponent.ps1 b/SnipeitPS/Public/Set-SnipeitComponent.ps1 index e622a33..2834df9 100644 --- a/SnipeitPS/Public/Set-SnipeitComponent.ps1 +++ b/SnipeitPS/Public/Set-SnipeitComponent.ps1 @@ -38,6 +38,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -84,6 +87,9 @@ function Set-SnipeitComponent() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -104,7 +110,7 @@ function Set-SnipeitComponent() foreach($component_id in $id){ $Parameters = @{ Uri = "$url/api/v1/components/$component_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 index 319ebf6..4aa28ab 100644 --- a/SnipeitPS/Public/Set-SnipeitConsumable.ps1 +++ b/SnipeitPS/Public/Set-SnipeitConsumable.ps1 @@ -53,6 +53,9 @@ Image file name and path for item .PARAMETER image_delete Remove current image +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -123,6 +126,9 @@ function Set-SnipeitConsumable() [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -143,7 +149,7 @@ function Set-SnipeitConsumable() foreach($consumable_id in $id ){ $Parameters = @{ Uri = "$url/api/v1/consumables/$consumable_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 index d2dc817..d958d37 100644 --- a/SnipeitPS/Public/Set-SnipeitCustomField.ps1 +++ b/SnipeitPS/Public/Set-SnipeitCustomField.ps1 @@ -29,6 +29,9 @@ .PARAMETER help_text Any additional text you wish to display under the new form field to make it clearer what the gauges should be. + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Put you could use Patch if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -69,6 +72,9 @@ function Set-SnipeitCustomField() [string]$custom_format, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Put", + [parameter(mandatory = $true)] [string]$url, @@ -88,7 +94,7 @@ function Set-SnipeitCustomField() foreach($field_id in $id) { $Parameters = @{ Uri = "$url/api/v1/fields/$field_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 index 81bd7e0..09d4632 100644 --- a/SnipeitPS/Public/Set-SnipeitDepartment.ps1 +++ b/SnipeitPS/Public/Set-SnipeitDepartment.ps1 @@ -26,6 +26,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -62,6 +65,9 @@ function Set-SnipeitDepartment() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -78,7 +84,7 @@ function Set-SnipeitDepartment() { foreach ($department_id in $id) { $Parameters = @{ Uri = "$url/api/v1/departments/$department_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLicense.ps1 b/SnipeitPS/Public/Set-SnipeitLicense.ps1 index c853441..184aa57 100644 --- a/SnipeitPS/Public/Set-SnipeitLicense.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicense.ps1 @@ -59,6 +59,9 @@ .PARAMETER termination_date Termination date for license. + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -121,6 +124,9 @@ function Set-SnipeitLicense() { [datetime]$termination_date, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -151,7 +157,7 @@ function Set-SnipeitLicense() { foreach($license_id in $id){ $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id" - Method = 'PUT' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 index 838c652..5ef3880 100644 --- a/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLicenseSeat.ps1 @@ -16,6 +16,9 @@ .PARAMETER note Notes about checkout + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -58,6 +61,9 @@ function Set-SnipeitLicenseSeat() [string]$note, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -73,7 +79,7 @@ function Set-SnipeitLicenseSeat() foreach($license_id in $id) { $Parameters = @{ Uri = "$url/api/v1/licenses/$license_id/seats/$seat_id" - Method = 'Patch' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitLocation.ps1 b/SnipeitPS/Public/Set-SnipeitLocation.ps1 index 8021ab9..b1c3770 100644 --- a/SnipeitPS/Public/Set-SnipeitLocation.ps1 +++ b/SnipeitPS/Public/Set-SnipeitLocation.ps1 @@ -50,6 +50,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -99,6 +102,9 @@ function Set-SnipeitLocation() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -116,7 +122,7 @@ function Set-SnipeitLocation() { foreach ($location_id in $id) { $Parameters = @{ Uri = "$url/api/v1/locations/$location_id" - Method = 'PUT' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitModel.ps1 b/SnipeitPS/Public/Set-SnipeitModel.ps1 index 4d99df6..695368f 100644 --- a/SnipeitPS/Public/Set-SnipeitModel.ps1 +++ b/SnipeitPS/Public/Set-SnipeitModel.ps1 @@ -29,6 +29,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -68,6 +71,9 @@ function Set-SnipeitModel() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -85,7 +91,7 @@ function Set-SnipeitModel() { foreach ($model_id in $id) { $Parameters = @{ Uri = "$url/api/v1/models/$model_id" - Method = 'put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitStatus.ps1 b/SnipeitPS/Public/Set-SnipeitStatus.ps1 index fe9867f..4c11b8a 100644 --- a/SnipeitPS/Public/Set-SnipeitStatus.ps1 +++ b/SnipeitPS/Public/Set-SnipeitStatus.ps1 @@ -15,6 +15,9 @@ Hex code showing what color the status label should be on the pie chart in the d .PARAMETER default_label 1 or 0 - determine whether it should be bubbled up to the top of the list of available statuses +.PARAMETER RequestType +Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -53,6 +56,9 @@ function Set-SnipeitStatus() [bool]$default_label, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url, @@ -68,7 +74,7 @@ function Set-SnipeitStatus() foreach($status_id in $id) { $Parameters = @{ Uri = "$url/api/v1/statuslabels/$status_id" - Method = 'Put' + Method = $RequestType Body = $Values Token = $apiKey } diff --git a/SnipeitPS/Public/Set-SnipeitUser.ps1 b/SnipeitPS/Public/Set-SnipeitUser.ps1 index 17e9662..8654f61 100644 --- a/SnipeitPS/Public/Set-SnipeitUser.ps1 +++ b/SnipeitPS/Public/Set-SnipeitUser.ps1 @@ -59,6 +59,9 @@ .PARAMETER image_delete Remove current image + .PARAMETER RequestType + Http request type to send Snipe IT system. Defaults to Patch you could use Put if needed. + .PARAMETER url URL of Snipeit system, can be set using Set-SnipeitInfo command @@ -118,6 +121,9 @@ function Set-SnipeitUser() { [switch]$image_delete=$false, + [ValidateSet("Put","Patch")] + [string]$RequestType = "Patch", + [parameter(mandatory = $true)] [string]$url,