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

support document editing #150

Closed
kantandane opened this issue Sep 22, 2023 · 7 comments · Fixed by #177
Closed

support document editing #150

kantandane opened this issue Sep 22, 2023 · 7 comments · Fixed by #177
Assignees
Labels
enhancement New feature or request

Comments

@kantandane
Copy link

Reading the project issues, the doc and code, it seems like your library doesn't support updating (replacing) a document right now, am I missing something ?

My use case is that i store a zip file in 1Password (as a document), and I would like to be able to update it as well (replacing only the file in 1Password, but keeping the same uuid etc.

Deleting it and Recreating it would be a decent workaround but it seems like document deletion isn't supported yet as well :(

@zcutlip zcutlip added the help wanted Extra attention is needed label Sep 22, 2023
@zcutlip zcutlip self-assigned this Sep 22, 2023
@zcutlip
Copy link
Owner

zcutlip commented Sep 22, 2023

Hi @kantandane, thank you for this issue and the great description of your use case

As I understand your use case, no pyonepassword doesn't currently support what you're describing. However, I'm in the process of pulling together a major 4.0 release, the marquee feature of which will be item editing. I don't know if 4.0 will satisfy your requirement exactly but if you're able to do what you're describing via op item edit, then I should be able to support it without too much trouble soon after 4.0, as editing is the main category of op operation this release aims to support.

Just to be sure we're thinking of the same thing: documents in 1Password are a little confusing. There are document items where op item get <document name> would give you the JSON description of a document entry in your vault. Then there are document objects themselves where op document get gives you the literal bytes representing the file. The document item references the document.

As far as deleting, yes, there is both OP.item_delete() to delete a document item as well OP.document_delete() to delete the document object. So you can delete documents. But no you can't currently edit an item and have it point to a new document object.

Let me know if I'm understanding your question correctly, and also please confirm that you can do what you're describing manually via the op command. From there I'll update this issue to track this feature work.

@zcutlip
Copy link
Owner

zcutlip commented Sep 22, 2023

Also, I apologize, but my free time to work on pyonepassword is a bit more scarce than normal, so progress has slowed down on feature work. I'm hoping to pick the pace up soon, but in the mean time please bear with me

@kantandane
Copy link
Author

Hi @zcutlip
Thank you for your quick answer.

Let me know if I'm understanding your question correctly, and also please confirm that you can do what you're describing manually via the op command. From there I'll update this issue to track this feature work.

What I want to do translated in op commands is :

  1. Creating a document test.txt with "test" in it
  2. Creating the document item with the binary in it with 1Password
op document create "test.txt" --title "test"
  1. Then I get the json response with the UUID of the item, so later I can replace the document with an updated one with the following command:
op document edit <Previously generated UUID> "test.txt"

And voilà, the same 1Password document Item, has now the updated binary file in it

I Hope it is more understandable !

Also, I apologize, but my free time to work on pyonepassword is a bit more scarce than normal, so progress has slowed down on feature work. I'm hoping to pick the pace up soon, but in the mean time please bear with me

Of course, it's an open source project, take all the time you need, i'm glad this lib exists anyway !

@zcutlip
Copy link
Owner

zcutlip commented Sep 23, 2023

Oh interesting, somehow op document edit had escaped my attention! I'll have a look at this, but my intuition is this should be fairly straight forward

Thank you for the great GH issue and the clarification

@zcutlip
Copy link
Owner

zcutlip commented Sep 23, 2023

Oh, and just to clarify, does OP.document_delete() address your document deletion question?

@zcutlip zcutlip changed the title Is document update or delete supported ? support for document editing via op document edit Sep 23, 2023
@zcutlip zcutlip added enhancement New feature or request and removed help wanted Extra attention is needed labels Sep 23, 2023
@zcutlip zcutlip changed the title support for document editing via op document edit support document editing Nov 8, 2023
@zcutlip
Copy link
Owner

zcutlip commented Nov 8, 2023

have OP.document_edit() implemented in the dev/150-support-document-editing branch, and it's working in casual testing

need to add support for the optional flags to op document edit including:

  • --file-name
  • --title
  • --tags

Also need to add a suite of test cases

cc: @kantandane

@zcutlip zcutlip linked a pull request Nov 27, 2023 that will close this issue
zcutlip added a commit that referenced this issue Nov 27, 2023
@zcutlip
Copy link
Owner

zcutlip commented Nov 28, 2023

This is complete as of pr #178, v4.1.0

You may get v4.1.0 vi PyPI:
pip3 install pyonepassword --upgrade "pyonepassword>=4.1.0"

cc: @kantandane

@zcutlip zcutlip closed this as completed Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants