Skip to content

add createmeta_84age implementation #1503

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

Closed
wants to merge 5 commits into from

Conversation

dshvedchenko
Copy link

this is draft for implementation of createmeta required according to changes causing #1462

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

fix  myoy hook

add docstrings
Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start !!
Made some comments, it would also be great if we can get some tests in, let me know if you need help on that front.
I would have a look at the tests/resources/ folder

jira/client.py Outdated
issuetype_id = _meta[0]
except JIRAError:
raise JIRAError(
status_code=500,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
status_code=500,

We shouldn't try and set our own status code. I would just let this exception bubble up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could instead use the existing methods on the client to check if a project exists, for example like so:

def _project_exists(self, project_key: str) -> bool:

Might be making this its own method, and use it in the test harness as well.

jira/client.py Outdated

def createmeta_v2(
self,
projectKey: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@studioj did we decide what we wanted to do with the naming convention of new functions?

jira/client.py Outdated
)

if self.is_84_and_later():
DeprecationWarning("The `createmeta` is deprecated, use createmeta_v2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely cannot use a function name called _v2.

Let's instead deprecate at the argument level.

e.g.
User passes projectKeys as a List[str]
if version > 9 raise ValueError
else if version is >8.4 - raise deprecation warning
The deprecation warning can be more detailed, explaining exactly what is wrong with the arguments and must include a link to the Atlassian docs where they describe this deprecation, ie: https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html

I might structure it like this:

def createmeta(...): 
    is_deprecation_msg_raised = false
    def deprecate_or_raise(msg: str):
        if self._version >= (9, 0, 0):
            raise ValueError(msg)
        elif self._version >= (9, 0, 0):
            DeprecationWarning(f"From Jira version 9.0.0: {msg}") # might need to change the stacklevel for this to work as intended

    if not isinstance(projectKeys, str) or ("," in projectKeys):
        deprecate_or_raise("projectKeys must be a str of a single project key")

    # and so on for other
    ...

    if is_deprecation_msg_raised :
        DeprecationWarning(
            "Atlassian wil have deprecated the `/createmeta` endpoint in Jira version 9.0.0."
            + "Full details can be found on:"
            + "https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html"
        )

In the above proposal, people will be warned about ways they can change the calls in preparation. Feel free to use another method if more appropriate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, i have to skip this activity till war in Ukraine is finished

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dshvedchenko sorry to hear you're affected 😔 hope all is well for you! If you give write access to your fork, I'm more than happy to finish the job :)

@adehad adehad added the feature label Sep 30, 2022
@pmilosev
Copy link
Contributor

pmilosev commented Nov 7, 2022

I need this fix and will invest couple of days on it ... I'll try to reproduce a similar solution accounting for the comments provided here.

@dshvedchenko
Copy link
Author

dshvedchenko commented Nov 8, 2022

need suggestions on how to automate tests for this.
current ci server is still 8.17 so can not be used to test on 9.0.0 jira branch

edit : https://github.com/pycontribs/jira/blob/main/.github/workflows/jira_server_ci.yml#L15

@dshvedchenko
Copy link
Author

can we have a progress on this or on #1527 PRs

@adehad
Copy link
Contributor

adehad commented Jan 29, 2023

Thank you again for all the effort on this PR @dshvedchenko, sorry that we went with the alternative PR this time. Hope you can contribute again in the future !

@adehad adehad closed this Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants