-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from zcutlip/development
merge development into main: v5.1.0
- Loading branch information
Showing
74 changed files
with
931 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ | |
"3" | ||
], | ||
"search.useIgnoreFiles": true, | ||
"makefile.configureOnOpen": false, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ A Python API to sign into and query a 1Password account using the `op` command. | |
|
||
## Requirements | ||
|
||
- Python >= 3.9 | ||
- Python >= 3.10 | ||
- 1Password command-line tool >= 2.26.0 | ||
- Versions >= 2.21.0, < 2.26.0 supported but deprecated | ||
- Versions < 2.21.0 are unsupported and an exception will be raised | ||
|
@@ -349,6 +349,38 @@ def main(): | |
print(ope.err_output) | ||
``` | ||
|
||
### Item Sharing | ||
|
||
To generate a URL for sharing an item, use the `OP.item_share()` method. This is congruent to the `op item share` subcommand. | ||
|
||
> NOTE: There is no way to revoke a share URL via `pyonepassword` or the `op` CLI command. It can be revoked in the 1Password application. | ||
> NOTE: The `emails=` kwarg may be omitted or be an empty list. In this case the share URL returned will not be restricted. Anyone who has the URL may view the shared item. | ||
Some of the parameters passed to `item_share()` are not validated by `pyonepassword`, but are validated by the `op` command. These include the expiration and email addresses. | ||
|
||
Additionally, the email addresses may be a list of email address strings or a string object for one single email address. | ||
|
||
```python | ||
from pyonepassword import OP # noqa: E402 | ||
from pyonepassword.api.exceptions import OPItemShareException # noqa: E402 | ||
|
||
|
||
def main(): | ||
op: OP = do_signin() | ||
try: | ||
# op.item_share() can take any identifier accepted by the 'op' command: | ||
# Usage: op item share { <itemName> | <itemID> } | ||
share_url = op.item_share("Example Login Item 22", ["[email protected]", "[email protected]"], expires_in="2d") | ||
print(share_url) | ||
except OPItemShareException as ope: | ||
# 'op' command can fail for a few reaons, including | ||
# - item not found | ||
# - duplicate item names | ||
# - malformed emails or expiration duration | ||
# Inspect the error message from the command | ||
print(ope.err_output) | ||
``` | ||
|
||
### Item Creation | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ A Python API to sign into and query a 1Password account using the `op` command. | |
|
||
## Requirements | ||
|
||
- Python >= 3.9 | ||
- Python >= 3.10 | ||
- 1Password command-line tool >= SUPPORTED_CLI_VERSION__ | ||
- Versions >= MINIMUM_CLI_VERSION__, < SUPPORTED_CLI_VERSION__ supported but deprecated | ||
- Versions < MINIMUM_CLI_VERSION__ are unsupported and an exception will be raised | ||
|
@@ -349,6 +349,38 @@ def main(): | |
print(ope.err_output) | ||
``` | ||
|
||
### Item Sharing | ||
|
||
To generate a URL for sharing an item, use the `OP.item_share()` method. This is congruent to the `op item share` subcommand. | ||
|
||
> NOTE: There is no way to revoke a share URL via `pyonepassword` or the `op` CLI command. It can be revoked in the 1Password application. | ||
> NOTE: The `emails=` kwarg may be omitted or be an empty list. In this case the share URL returned will not be restricted. Anyone who has the URL may view the shared item. | ||
Some of the parameters passed to `item_share()` are not validated by `pyonepassword`, but are validated by the `op` command. These include the expiration and email addresses. | ||
|
||
Additionally, the email addresses may be a list of email address strings or a string object for one single email address. | ||
|
||
```python | ||
from pyonepassword import OP # noqa: E402 | ||
from pyonepassword.api.exceptions import OPItemShareException # noqa: E402 | ||
|
||
|
||
def main(): | ||
op: OP = do_signin() | ||
try: | ||
# op.item_share() can take any identifier accepted by the 'op' command: | ||
# Usage: op item share { <itemName> | <itemID> } | ||
share_url = op.item_share("Example Login Item 22", ["[email protected]", "[email protected]"], expires_in="2d") | ||
print(share_url) | ||
except OPItemShareException as ope: | ||
# 'op' command can fail for a few reaons, including | ||
# - item not found | ||
# - duplicate item names | ||
# - malformed emails or expiration duration | ||
# Inspect the error message from the command | ||
print(ope.err_output) | ||
``` | ||
|
||
### Item Creation | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Updating Python Support | ||
|
||
This file documents how to add a new python version and/or remove an old one to automated testing and GitHub CI. | ||
|
||
To add python 3.13 & remove python 3.9: | ||
|
||
|
||
Files to update: | ||
|
||
- tox.ini | ||
- replace all cases of `39,310,311,312` with `310,311,312,313` | ||
- setup.py | ||
- update minimum python: `python_requires='>=3.10'` | ||
- update `classifiers`: | ||
|
||
```"Programming Language :: Python :: 3.13"``` | ||
- Docker: | ||
- rename py39.Dockerfile to py313.Dockerfile | ||
- replace '3.9' with '3.13' globally | ||
- replace 'py39' with 'py313' globally | ||
- `clean.sh` | ||
- add `docker_py313` to `docker image rm` command | ||
- it's okay to leave `docker_py39` to ensure it gets removed | ||
- If there's a really old docker python image, e.g., `docker_py38`, go ahead and remove that | ||
- `build.sh` | ||
- copy 'docker buildx' command for python 3.12 | ||
- replace all `py312` with `py313` | ||
- delete `docker buildx` command for python 3.9 | ||
- `run.sh` | ||
- duplicate run command for `docker_py312`, replacing container name with `docker_py313` | ||
- delete `docker run` command for python 3.9 | ||
- `run-individual.sh` | ||
- duplicate `elif` clause for python 3.12, updating it to `docker_py312` | ||
- delete `if-elif` clause for python 3.9 | ||
- update help message: `"Specify py310, py311, py312, or py313"` | ||
- rennovate.json | ||
- add dict for 3.13 dockerfile | ||
- Note the name of the dockerfile, as well as `allowedVersions` key: | ||
``` | ||
{ | ||
"matchPaths": ["docker_testing/docker/py313.Dockerfile"], | ||
"matchPackageNames":["python"], | ||
"allowedVersions": "3.13" | ||
} | ||
``` | ||
- remove dict for 3.9 | ||
- .github/workflows/testing-linting.yml | ||
- update python version matrix: `["3.10", "3.11", "3.12", "3.13"]` | ||
- _readme_template.md | ||
- Update minimum python version under requirements | ||
- README.md: | ||
- run `scripts/update_readme.py` to apply changes to README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import sys | ||
|
||
from do_signin import do_signin | ||
|
||
parent_path = os.path.dirname( | ||
os.path.dirname( | ||
os.path.abspath(__file__) | ||
) | ||
) | ||
# isort: split | ||
if parent_path not in sys.path: | ||
sys.path.append(parent_path) | ||
|
||
from pyonepassword import OP # noqa: E402 | ||
from pyonepassword.api.exceptions import OPItemShareException # noqa: E402 | ||
|
||
|
||
def main(): | ||
op: OP = do_signin() | ||
try: | ||
# op.item_share() can take any identifier accepted by the 'op' command: | ||
# Usage: op item share { <itemName> | <itemID> } | ||
share_url = op.item_share("Example Login Item 22", [], expires_in="2d") | ||
print(share_url) | ||
except OPItemShareException as ope: | ||
# 'op' command can fail for a few reaons, including | ||
# - item not found | ||
# - duplicate item names | ||
# - malformed emails or expiration duration | ||
# Inspect the error message from the command | ||
print(ope.err_output) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
from _util.functions import get_op | ||
from dotenv import load_dotenv | ||
|
||
from pyonepassword import OP | ||
from pyonepassword.api.exceptions import OPCmdFailedException # noqa: F401 | ||
|
||
os.environ["LOG_OP_ERR"] = "1" | ||
# load_dotenv("./dot_env_files/.env_pyonepassword_test_rw") | ||
|
||
|
||
item_name = "Example Login Item 22" | ||
vault = "Test Data 1" | ||
emails = "[email protected]" | ||
op = OP() | ||
print(open(__file__, "r").read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.