Skip to content
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

v3 api version-update method not working #6559

Closed
Aricg opened this issue Jan 21, 2020 · 13 comments · Fixed by #6574
Closed

v3 api version-update method not working #6559

Aricg opened this issue Jan 21, 2020 · 13 comments · Fixed by #6574
Labels
Bug A bug Good First Issue Good for new contributors Needed: documentation Documentation is required

Comments

@Aricg
Copy link

Aricg commented Jan 21, 2020

Details

I am trying to activate/deactivate versions via the v3 api
https://docs.readthedocs.io/en/stable/api/v3.html#version-update

This is implemented per your docs, however does not appear to be
it working yet as this always returns a 404.

$ lftools rtd project-version-update o-ran-sc-doc master false
{'active': 'false', 'privacy_level': 'public'}
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://readthedocs.org/api/v3/projects/o-ran-sc-doc/version/master/

Code on our end:

    def project_version_update(self, project, version, active,
                               privacy_level):
        """Edit a version.

        :param project: The project slug
        :param version: The version slug
        :param active: 'true' or 'false'
        :param privacy_level: 'public' or 'private'
        :return: {result}
        """
        data = {
            'active': active,
            'privacy_level': privacy_level
        }
        print(data)

        json_data = json.dumps(data)
        result = self.patch('projects/{}/version/{}/'.format(project, version),
                            data=json_data)
        return result

Expected Result

I can activate versions via the API

Actual Result

API method returns 404.

@Aricg Aricg changed the title v3 api version-update method v3 api version-update method not working Jan 21, 2020
@stsewd
Copy link
Member

stsewd commented Jan 21, 2020

Believe there is a typo in the docs, it should be projects/{project}/versions/{version}

@Aricg
Copy link
Author

Aricg commented Jan 21, 2020

Yep, there we go. thanks.

@stsewd stsewd added Bug A bug Needed: documentation Documentation is required Good First Issue Good for new contributors labels Jan 21, 2020
@Aricg
Copy link
Author

Aricg commented Jan 21, 2020

Hi @stsewd No longer returns a 404,
but its not updating the field.

@Aricg
Copy link
Author

Aricg commented Jan 21, 2020

lftools rtd project-version-update o-ran-sc-doc master false
{'active': 'false', 'privacy_level': 'public'}
<Response [204]>

@Aricg
Copy link
Author

Aricg commented Jan 21, 2020

Changed to bool, still no dice.

$ lftools rtd project-version-update o-ran-sc-doc master false
{'active': False}
<Response [204]>
 'active_versions': [{'_links': {'_self': 'https://readthedocs.org/api/v3/projects/o-ran-sc-doc/versions/master/',
                                 'builds': 'https://readthedocs.org/api/v3/projects/o-ran-sc-doc/versions/master/builds/',
                                 'project': 'https://readthedocs.org/api/v3/projects/o-ran-sc-doc/'},
                      'active': True,
                      'built': True,
                      'downloads': {'htmlzip': 'https://docs.o-ran-sc.org/_/downloads/en/master/htmlzip/'},
                      'id': 4914070,
                      'identifier': 'origin/master',
                      'ref': None,
                      'slug': 'master',
                      'type': 'branch',
                      'urls': {'documentation': 'https://docs.o-ran-sc.org/en/master/',
                               'vcs': 'https://gerrit.o-ran-sc.org/r/doc'},
                      'verbose_name': 'master'},

@stsewd
Copy link
Member

stsewd commented Jan 21, 2020

I'll try to dig into this later.

If you only want to activate new versions based on something, you can use https://docs.readthedocs.io/en/stable/automation-rules.html btw

@Aricg
Copy link
Author

Aricg commented Jan 21, 2020

@stsewd It works via curl, so I'm guessing its on our side right now, digging into it.
Did you remove 'privacy_level' from the api?
I'm fine with that btw, I don't want to change it, just might want to mark the docs for update.

@stsewd
Copy link
Member

stsewd commented Jan 21, 2020

@Aricg yes, we removed the privacy_level field, that's part of #3781

@Aricg
Copy link
Author

Aricg commented Jan 21, 2020

@stsewd Hi if you forget the trailing slash on PATCH /api/v3/projects/(string:project_slug)/version/(string:version_slug)/
maybe it could return a 400 and not a 204. :D (it's fixed)

@Blackcipher101
Copy link
Contributor

@stsewd is this bug still valid if yes can I work on it

@Aricg
Copy link
Author

Aricg commented Jan 22, 2020

@Blackcipher101 Just the documentation needs to be updated to fix the typo
"it should be projects/{project}/versions/{version}" (versions not version)
There is already an issue about the privacy level stuff.

oh and the comma here can be removed

"active": true,

@preetmishra
Copy link
Contributor

@stsewd Has this been fixed? If not, can I work on this one?

@stsewd
Copy link
Member

stsewd commented Jan 23, 2020

@preetmishra there is a PR already open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Good First Issue Good for new contributors Needed: documentation Documentation is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants