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

put-link should update only specified fields instead of overwriting all fields #34

Open
mfioretti opened this issue Sep 4, 2018 · 3 comments

Comments

@mfioretti
Copy link

The Usage section of the documentation says that "put-link" "Updates an existing link or note". This is not true. What it does is to transform a link into a private note with a different title. Even the example ("shaarli put-link --private 3252") in the documentation itself shows this.

Also, the inline help says:

(shaarli) [root@fima-01-hetzner ~]# shaarli -c /root/scripts/shaarli.conf   put-link --help
usage: shaarli put-link [-h] [--description DESCRIPTION [DESCRIPTION ...]]
                        [--private] [--tags TAGS [TAGS ...]]
                        [--title TITLE [TITLE ...]] [--url URL]
                        resource

positional arguments:
  resource              Link ID

optional arguments:
  -h, --help            show this help message and exit
  --description DESCRIPTION [DESCRIPTION ...]
                        Link description
  --private             Link visibility
  --tags TAGS [TAGS ...]
                        List of tags associated with the link
  --title TITLE [TITLE ...]
                        Link title
  --url URL             Link URL

but if add and then I try to update a link, it gets changed title, and URL, just like in the docs. But why should they change, if one only sets status to private?:

(shaarli) [marco ~]# shaarli -c shaarli.conf  post-link --url https://www.linux.com --tags "freeSoftware testing" --description "go penguins" --title 'A nice operating system'
{
    "created": "2018-09-04T18:54:08+02:00",
    "description": "go penguins",
    "id": 4,
    "private": false,
    "shorturl": "Gxqflg",
    "tags": [
        "freeSoftware",
        "testing"
    ],
    "title": "A nice operating system",
    "updated": "",
    "url": "https://www.linux.com"
}
(shaarli) [marco ~]# shaarli -c shaarli.conf  put-link --private 4
{
    "created": "2018-09-04T18:54:08+02:00",
    "description": "",
    "id": 4,
    "private": true,
    "shorturl": "Gxqflg",
    "tags": [],
    "title": "?Gxqflg",
    "updated": "2018-09-04T18:54:36+02:00",
    "url": "https://localhost/?Gxqflg"

Besides: "put-link --private true 2" , or e.g "put-link --title 'new title' does not work at all:

(shaarli) [marco ~]# shaarli -c shaarli.conf  put-link --private true 4
usage: shaarli put-link [-h] [--description DESCRIPTION [DESCRIPTION ...]]
                        [--private] [--tags TAGS [TAGS ...]]
                        [--title TITLE [TITLE ...]] [--url URL]
                        resource
shaarli put-link: error: argument resource: true is not a positive integer
(shaarli) [marco ~]# shaarli -c shaarli.conf  put-link --title 'A new title' 4
usage: shaarli put-link [-h] [--description DESCRIPTION [DESCRIPTION ...]]
                        [--private] [--tags TAGS [TAGS ...]]
                        [--title TITLE [TITLE ...]] [--url URL]
                        resource
shaarli put-link: error: argument resource: A new title is not a positive integer

@virtualtam
Copy link
Member

Hi @mfioretti,

As we've haven't had much feedback on the REST API, there are some rough edges remaining on both the API itself, as well as the provided Python client.

From the API documentation for the PUT link endpoint:

Update an existing link with provided request data. Keep in mind that all link’s fields will be updated.

Which is indeed not ideal as it does not allow for atomic operations on relevant fields.

Besides: "put-link --private true 2" , or e.g "put-link --title 'new title' does not work at all:

--private sets the link visibility flag, and does not expect a boolean argument, e.g.:

  • shaarli put-link <parameters> 4 to update a link and set its visibility to public
  • shaarli put-link <parameters> --private 4 to update a link and set its visibility to private

@mfioretti
Copy link
Author

Hello @virtualtam .

I had NOT understood how the --private switch needs to be used, my bad!

As for the other issues... if every time I have to update a bookmark I have to pass to shaarli-client ALL its fields, even if only one changed, that is not ideal, but no big deal either, really. In my tests here, however, I noticed that sometimes shaarli-client did not return anything at all on STDOUT, even when it had succceeded. It should return the full json record of the updated bookmark, right? And when it returns nothing, can it be the memory issues of the php application mentioned at shaarli/Shaarli#1223, or should be worry about something else?

Thanks

@ArthurHoaro
Copy link
Member

Which is indeed not ideal as it does not allow for atomic operations on relevant fields.

I think that would be a PATCH request. It can be added if it's needed.

@mfioretti I'm not really familiar with this client, but if the PHP API exhausts its memory, you will find an error in the PHP/webserver logs.

@nodiscc nodiscc changed the title wrong documentation about put-link? put-link should update only specified fields instead of overwriting all fields Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants