From ad092550580f866639186417f358e93e6b1e22c4 Mon Sep 17 00:00:00 2001 From: robertmbaker Date: Mon, 9 Oct 2023 14:39:48 -0500 Subject: [PATCH 1/4] Update Get-JiraIssueCreateMetadata.ps1 https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html --- JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 b/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 index 54e9c82e..1fca2c14 100644 --- a/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 +++ b/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 @@ -22,7 +22,7 @@ function Get-JiraIssueCreateMetadata { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/2/issue/createmeta?projectIds={0}&issuetypeIds={1}&expand=projects.issuetypes.fields" + $resourceURi = "$server/rest/api/2/issue/createmeta/{0}/issuetypes/{1}" } process { From dd1426e2e6695b2560b2b55d6b8d389230a20d08 Mon Sep 17 00:00:00 2001 From: robertmbaker Date: Mon, 9 Oct 2023 14:41:09 -0500 Subject: [PATCH 2/4] Update ConvertTo-JiraCreateMetaField.ps1 https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html --- .../Private/ConvertTo-JiraCreateMetaField.ps1 | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/JiraPS/Private/ConvertTo-JiraCreateMetaField.ps1 b/JiraPS/Private/ConvertTo-JiraCreateMetaField.ps1 index 4db39833..444d4592 100644 --- a/JiraPS/Private/ConvertTo-JiraCreateMetaField.ps1 +++ b/JiraPS/Private/ConvertTo-JiraCreateMetaField.ps1 @@ -7,45 +7,41 @@ function ConvertTo-JiraCreateMetaField { ) process { - foreach ($i in $InputObject) { + foreach ($i in $InputObject.values) { Write-Debug "[$($MyInvocation.MyCommand.Name)] Converting `$InputObject to custom object" - $fields = $i.projects.issuetypes.fields - $fieldNames = (Get-Member -InputObject $fields -MemberType '*Property').Name - foreach ($f in $fieldNames) { - $item = $fields.$f - - $props = @{ - 'Id' = $f - 'Name' = $item.name - 'HasDefaultValue' = [System.Convert]::ToBoolean($item.hasDefaultValue) - 'Required' = [System.Convert]::ToBoolean($item.required) - 'Schema' = $item.schema - 'Operations' = $item.operations - } + $item = $i - if ($item.allowedValues) { - $props.AllowedValues = $item.allowedValues - } + $props = @{ + 'Id' = $item.fieldId + 'Name' = $item.name + 'HasDefaultValue' = [System.Convert]::ToBoolean($item.hasDefaultValue) + 'Required' = [System.Convert]::ToBoolean($item.required) + 'Schema' = $item.schema + 'Operations' = $item.operations + } - if ($item.autoCompleteUrl) { - $props.AutoCompleteUrl = $item.autoCompleteUrl - } + if ($item.allowedValues) { + $props.AllowedValues = $item.allowedValues + } - foreach ($extraProperty in (Get-Member -InputObject $item -MemberType NoteProperty).Name) { - if ($null -eq $props.$extraProperty) { - $props.$extraProperty = $item.$extraProperty - } - } + if ($item.autoCompleteUrl) { + $props.AutoCompleteUrl = $item.autoCompleteUrl + } - $result = New-Object -TypeName PSObject -Property $props - $result.PSObject.TypeNames.Insert(0, 'JiraPS.CreateMetaField') - $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { - Write-Output "$($this.Name)" + foreach ($extraProperty in (Get-Member -InputObject $item -MemberType NoteProperty).Name) { + if ($null -eq $props.$extraProperty) { + $props.$extraProperty = $item.$extraProperty } + } - Write-Output $result + $result = New-Object -TypeName PSObject -Property $props + $result.PSObject.TypeNames.Insert(0, 'JiraPS.CreateMetaField') + $result | Add-Member -MemberType ScriptMethod -Name "ToString" -Force -Value { + Write-Output "$($this.Name)" } + + Write-Output $result } } } From f4b745a9cdd361b58b825d823e7694c44e6019ba Mon Sep 17 00:00:00 2001 From: robertmbaker Date: Mon, 9 Oct 2023 14:42:35 -0500 Subject: [PATCH 3/4] Update Get-JiraIssueCreateMetadata.ps1 https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html --- JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 b/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 index 1fca2c14..8d8b42af 100644 --- a/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 +++ b/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 @@ -47,40 +47,16 @@ function Get-JiraIssueCreateMetadata { Method = "GET" Credential = $Credential } + Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter" $result = Invoke-JiraMethod @parameter if ($result) { - if (@($result.projects).Count -eq 0) { - $errorMessage = @{ - Category = "InvalidResult" - CategoryActivity = "Validating response" - Message = "No projects were found for the given project [$Project]. Use Get-JiraProject for more details." - } - Write-Error @errorMessage - } - elseif (@($result.projects).Count -gt 1) { - $errorMessage = @{ - Category = "InvalidResult" - CategoryActivity = "Validating response" - Message = "Multiple projects were found for the given project [$Project]. Refine the parameters to return only one project." - } - Write-Error @errorMessage - } - - if (@($result.projects.issuetypes) -eq 0) { - $errorMessage = @{ - Category = "InvalidResult" - CategoryActivity = "Validating response" - Message = "No issue types were found for the given issue type [$IssueType]. Use Get-JiraIssueType for more details." - } - Write-Error @errorMessage - } - elseif (@($result.projects.issuetypes).Count -gt 1) { + if (@($result.values).Count -eq 0) { $errorMessage = @{ Category = "InvalidResult" CategoryActivity = "Validating response" - Message = "Multiple issue types were found for the given issue type [$IssueType]. Refine the parameters to return only one issue type." + Message = "No values were found for the given project [$Project]. Use Get-JiraProject for more details." } Write-Error @errorMessage } From 7ccc3d3d76f1d7ef81f1e86826b2355fbf0fa9da Mon Sep 17 00:00:00 2001 From: robertmbaker Date: Mon, 9 Oct 2023 16:17:20 -0500 Subject: [PATCH 4/4] Update ConvertTo-JiraCreateMetaField.Unit.Tests.ps1 Altered test data to match what is returned by new createmeta call. --- ...nvertTo-JiraCreateMetaField.Unit.Tests.ps1 | 117 ++++++++---------- 1 file changed, 54 insertions(+), 63 deletions(-) diff --git a/Tests/Functions/ConvertTo-JiraCreateMetaField.Unit.Tests.ps1 b/Tests/Functions/ConvertTo-JiraCreateMetaField.Unit.Tests.ps1 index d2e79995..3b8b431b 100644 --- a/Tests/Functions/ConvertTo-JiraCreateMetaField.Unit.Tests.ps1 +++ b/Tests/Functions/ConvertTo-JiraCreateMetaField.Unit.Tests.ps1 @@ -39,71 +39,62 @@ Describe "ConvertTo-JiraCreateMetaField" -Tag 'Unit' { $sampleJson = @' { - "expand": "projects", - "projects": [ + "values": [ { - "expand": "issuetypes", - "issuetypes": [ + "required": true, + "schema": { + "type": "string", + "system": "summary" + }, + "name": "Summary", + "fieldId": "summary", + "hasDefaultValue": false, + "operations": [ + "set" + ] + }, + { + "required": false, + "schema": { + "type": "priority", + "system": "priority" + }, + "name": "Priority", + "fieldId": "priority", + "hasDefaultValue": true, + "operations": [ + "set" + ], + "allowedValues": [ + { + "self": "http://jiraserver.example.com/rest/api/2/priority/1", + "iconUrl": "http://jiraserver.example.com/images/icons/priorities/blocker.png", + "name": "Block", + "id": "1" + }, + { + "self": "http://jiraserver.example.com/rest/api/2/priority/2", + "iconUrl": "http://jiraserver.example.com/images/icons/priorities/critical.png", + "name": "Critical", + "id": "2" + }, + { + "self": "http://jiraserver.example.com/rest/api/2/priority/3", + "iconUrl": "http://jiraserver.example.com/images/icons/priorities/major.png", + "name": "Major", + "id": "3" + }, + { + "self": "http://jiraserver.example.com/rest/api/2/priority/4", + "iconUrl": "http://jiraserver.example.com/images/icons/priorities/minor.png", + "name": "Minor", + "id": "4" + }, { - "expand": "fields", - "fields": { - "summary": { - "required": true, - "schema": { - "type": "string", - "system": "summary" - }, - "name": "Summary", - "hasDefaultValue": false, - "operations": [ - "set" - ] - }, - "priority": { - "required": false, - "schema": { - "type": "priority", - "system": "priority" - }, - "name": "Priority", - "hasDefaultValue": true, - "operations": [ - "set" - ], - "allowedValues": [ - { - "self": "http://jiraserver.example.com/rest/api/2/priority/1", - "iconUrl": "http://jiraserver.example.com/images/icons/priorities/blocker.png", - "name": "Block", - "id": "1" - }, - { - "self": "http://jiraserver.example.com/rest/api/2/priority/2", - "iconUrl": "http://jiraserver.example.com/images/icons/priorities/critical.png", - "name": "Critical", - "id": "2" - }, - { - "self": "http://jiraserver.example.com/rest/api/2/priority/3", - "iconUrl": "http://jiraserver.example.com/images/icons/priorities/major.png", - "name": "Major", - "id": "3" - }, - { - "self": "http://jiraserver.example.com/rest/api/2/priority/4", - "iconUrl": "http://jiraserver.example.com/images/icons/priorities/minor.png", - "name": "Minor", - "id": "4" - }, - { - "self": "http://jiraserver.example.com/rest/api/2/priority/5", - "iconUrl": "http://jiraserver.example.com/images/icons/priorities/trivial.png", - "name": "Trivial", - "id": "5" - } - ] - } - } + "self": "http://jiraserver.example.com/rest/api/2/priority/5", + "iconUrl": "http://jiraserver.example.com/images/icons/priorities/trivial.png", + "name": "Trivial", + "id": "5" } ] }