-
Notifications
You must be signed in to change notification settings - Fork 171
Add Additional Namespace & Catalog Request Support #284
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
base: master
Are you sure you want to change the base?
Conversation
Fixes error "Id must either be a SysId 32 character alphanumeric or Number with prefix and id." and retains ID from reference table for further lookup.
Additional fixes for reference table lookup where value is not in the 32 character format expected by SNOW.
Co-authored-by: Greg Brownstein <[email protected]>
Add Namespace parameter to support different API endpoints; defaults to 'now'
Versioned PSD with Minor increase for new functionality and backwards-compatible changes.
Awesome stuff, I'll review this week! |
Add New-ServiceNowCatalog declaration to FunctionsToExport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much, looks good, just some tweaks here and there :)
[Parameter(Mandatory, ParameterSetName = 'Name')] | ||
[string]$CatalogItemName, | ||
[Parameter(Mandatory, ParameterSetName = 'ID')] | ||
[string]$CatalogItemID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about we combine this into one CatalogItem
and check its format to know if its an ID or name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take care of updating this file when I perform the release. Can you please undo these changes?
if ($Namespace -ne 'now') { | ||
$hashOut.Uri = $($ServiceNowSession.BaseUri -split ('api'))[0] + 'api/' + $Namespace | ||
} else { | ||
$hashOut.Uri = $ServiceNowSession.BaseUri | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we're better served by changing the baseuri to end with /api and just append the namespace. this will involve changes here and invoke-service nowrestmethod.
elseif ( $Connection ) { | ||
} elseif ( $Connection ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try and keep formatting the same :)
[string] $FilterString, | ||
|
||
[parameter()] | ||
[string] $Namespace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default to 'now'?
ServiceNow session created by New-ServiceNowSession. Will default to script-level variable $ServiceNowSession. | ||
.EXAMPLE | ||
New-ServiceNowRecord -CatalogItemName "Standard Laptop" -Variables @{'acrobat' = 'true'; 'photoshop' = 'true'; ' Additional_software_requirements' = 'Testing Service catalog API' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New-ServiceNowRecord -CatalogItemName "Standard Laptop" -Variables @{'acrobat' = 'true'; 'photoshop' = 'true'; ' Additional_software_requirements' = 'Testing Service catalog API' } | |
New-ServiceNowCatalogItem -CatalogItem "Standard Laptop" -Variables @{'acrobat' = 'true'; 'photoshop' = 'true'; ' Additional_software_requirements' = 'Testing Service catalog API' } |
if ($namespace) { | ||
$params = Get-ServiceNowAuth -C $Connection -S $ServiceNowSession -N $namespace | ||
} else { | ||
$params = Get-ServiceNowAuth -C $Connection -S $ServiceNowSession | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($namespace) { | |
$params = Get-ServiceNowAuth -C $Connection -S $ServiceNowSession -N $namespace | |
} else { | |
$params = Get-ServiceNowAuth -C $Connection -S $ServiceNowSession | |
} | |
$params = Get-ServiceNowAuth -C $Connection -S $ServiceNowSession -N $namespace |
|
||
$AddItemCartResponse = Invoke-ServiceNowRestMethod @AddItemToCart | ||
|
||
if ($AddItemCartResponse.cart_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why might we not get a value for cart_id that we need this 'if'?
if ( $PassThru ) { | ||
$SubmitOrderResponse | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you are going to keep the check for cart_id, this needs to move inside the 'if' block otherwise $SubmitOrderResponse would be null
$SubmitOrderResponse = Invoke-ServiceNowRestMethod @SubmitOrder | ||
} | ||
if ( $PassThru ) { | ||
$SubmitOrderResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$SubmitOrderResponse | |
$SubmitOrderResponse | Select-Object @{'n'='number';'e'={$_.request_number}}, request_id |
consider updating the output to something like the above so it can be piped directly into the other functions, eg. Get-ServiceNowRecord
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to have a way to control when checkout occurs in case folks want to add multiple (different) items before submitting order
This PR adds a cmdlet for New-ServiceNowCatalogItem which uses the 'sn_sc' API namespace to add a catalog item request to a cart and then submits the cart as an order.
Extends Get-ServiceNowAuth and Invoke-ServiceNowRestMethod with a namespace parameter to support different Namespace endpoints; backwards compatibility is maintained by defaulting to the 'now' namespace if not specified.