ctreminiom / go-atlassian

✨ Golang Client Library for Atlassian Cloud.
https://docs.go-atlassian.io
MIT License
114 stars 29 forks source link

Question on adding fixVersions #255

Closed stephanwesten closed 2 weeks ago

stephanwesten commented 4 months ago

Hello,

Thank you for your project. It is very useful!

I've a question; I would like to update the fixVersions field of an issue. I thought I could use the same approach as described in the cookbook 'edit jira issue (implicit)'. So using a AddStringOperation like in:

    var operations = &models.UpdateOperations{}
    err = operations.AddArrayOperation("fixVersions", map[string]string{
        "v1": "add",
    })

However I get an error that I need to "Specify a valid version 'id' or 'name' for fixVersions"".

In examples from other languages I see people explicitly including 'name'. However this is not possible with an arrayOperation as it expects a map[string]string.

Do you know how to set the fixVersions field?

thanks

Stephan

PS in the cookbook code it says "atlassian", but it should say "client"

ctreminiom commented 3 months ago

Hi @stephanwesten,

I appreciate your contribution to this open-source project! However, I apologies for the delayed response due I'm in the middle of a job change and my time's a bit tight.

Regarding your question, you're right, the AddArrayOperation() can't handle the multi-picker customfields like the versions, multi-groups, multi-users, etc.

I just created a new method called AddMultiRawOperation() that can handle the fixVersions and any multipicker customfield, the format is the following:


var operations = &models.UpdateOperations{}
operations.AddMultiRawOperation("fixVersions", []map[string]interface{}{

{
    "remove": map[string]interface{}{
        "name": "Version 00",
    },
},

{
    "remove": map[string]interface{}{
        "name": "Version 101",
    },
},

{
    "add": map[string]interface{}{
        "name": "Version 301",
    },
},
}
)

Before the execution

image

After the execution

image

image

Finally, can you please test the new method from your side and confirm the correct behavior?, just go get with the commit hash:

go get github.com/ctreminiom/go-atlassian@8d27166c4ebb9a10f725dd022107fc3aae7fb008

Pura vida 🏄

stephanwesten commented 3 months ago

Thanks for your support. Honestly, I do not know if i’ve the time to test it. I implemented a solution with just a plain http call that works fine and moved on. It is not nice, but i rather be open about it. Hopefully other people will benefit from your work. Thank you.