Support for document API?
VictorioBerra opened this issue · 17 comments
https://developer.1password.com/docs/cli/reference/management-commands/document
Does this package support the above CLI subcommand for documents?
No at the moment. Shouldn't be too much effort to add support for it.
Maybe that they've added new Roslyn analyzers since the last build.
You can try lowering the analysis level in the csproj: https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysislevel
Setting <CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
in Build.props let the project compile.
Toggling the various analysislevels had no effect.
Started work in this branch:
https://github.com/VictorioBerra/OnePassword.NET/tree/VictorioBerra/feat/documents
Just got the op.exe document list
command working, not much work done on tests yet or other commands.
Some sample output I am working from is here:
PS C:\Program Files\1Password CLI> .\op.exe document create "C:\Users\me\Downloads\HelloWorld.txt" --vault OnePasswordNET --title Test1 --format json
{
"uuid":"ABCD123",
"createdAt":"2023-08-05T13:21:37.7611269-05:00",
"updatedAt":"2023-08-05T13:21:37.7611269-05:00",
"vaultUuid":"ikfkfwx2efxsdkqvcwiz666mgi"
}
PS C:\Program Files\1Password CLI> ./op.exe document list --vault OnePasswordNET --format json
[
{
"id": "ABCD123",
"title": "Test1",
"version": 1,
"vault": {
"id": "ikfkfwx2efxsdkqvcwiz666mgi",
"name": ""
},
"last_edited_by": "ABCD123",
"created_at": "2023-08-05T18:21:38Z",
"updated_at": "2023-08-05T18:21:38Z"
}
]
./op.exe document get Test1 --vault OnePasswordNET --format json
No output
.\op.exe document edit Test1 "C:\Users\me\Downloads\HelloWorld.txt" --vault OnePasswordNET --title Test2 --format json
No output
./op.exe document delete Test1 --vault OnePasswordNET --format json
No output
Some things to note, creating a document returns a smaller JSON object where id
is called uuid
, and created_at
is instead createdAt
so making use of a base class becomes a lot harder. Do I need to worry about that with ResultBase<TInterface>
? That only has id
.
All command complete. https://github.com/VictorioBerra/OnePassword.NET/blob/VictorioBerra/feat/documents/OnePassword.NET/OnePasswordManager.Documents.cs
I just need help with the tests now. When I run them, they all say skipped...
You have to set the environment variables for the tests: https://github.com/jscarle/OnePassword.NET#running-tests
I'll take a closer look when I'm in the office on Monday.
Ah the testing stuff is all at the bottom of the README my bad.
PR ready for initial review 🎉
@jscarle Have you had a chance to peek at this yet?
I took a look at the PR, I'll need to do a refactor of certain parts. I understand the challenge that the 1Password team decided to be inconsistent in their property names, so I'll have to work around that. The main issue is that the API should be consistent, and in there is a different in the way that documents and items are managed. So I'll want to rework it a bit to make it consistent. Also, I'm not sure why there's a DocumentVault class...
@jscarle Please re-work as needed. This should get you started.
There is a DocumentVault object due to this nested object:
PS C:\Program Files\1Password CLI> ./op.exe document list --vault OnePasswordNET --format json
[
{
"id": "ABCD123",
"title": "Test1",
"version": 1,
"vault": { // <--------------------------------------- Document vault object
"id": "ikfkfwx2efxsdkqvcwiz666mgi",
"name": ""
},
"last_edited_by": "ABCD123",
"created_at": "2023-08-05T18:21:38Z",
"updated_at": "2023-08-05T18:21:38Z"
}
]
You can see above that listing documents will return an object with a nested Vault object.
@jscarle Is there anything I can do to help nudge this along?
I finally had the time to work through it, it's been merged with some changes.
Thank you!