pjdev-op 3.7.1a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,165 @@
1
+ .DS_Store
2
+ .idea
3
+
4
+ !**/.gitkeep
5
+
6
+ # Byte-compiled / optimized / DLL files
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+
11
+ # C extensions
12
+ *.so
13
+
14
+ # Distribution / packaging
15
+ .Python
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ downloads/
20
+ eggs/
21
+ .eggs/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ var/
27
+ wheels/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py,cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+ cover/
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+ db.sqlite3
67
+ db.sqlite3-journal
68
+
69
+ # Flask stuff:
70
+ instance/
71
+ .webassets-cache
72
+
73
+ # Scrapy stuff:
74
+ .scrapy
75
+
76
+ # Sphinx documentation
77
+ docs/_build/
78
+
79
+ # PyBuilder
80
+ .pybuilder/
81
+ target/
82
+
83
+ # Jupyter Notebook
84
+ .ipynb_checkpoints
85
+
86
+ # IPython
87
+ profile_default/
88
+ ipython_config.py
89
+
90
+ # pyenv
91
+ # For a library or package, you might want to ignore these files since the code is
92
+ # intended to run in multiple environments; otherwise, check them in:
93
+ # .python-version
94
+
95
+ # pipenv
96
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
98
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
99
+ # install all needed dependencies.
100
+ #Pipfile.lock
101
+
102
+ # poetry
103
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
104
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
105
+ # commonly ignored for libraries.
106
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
107
+ #poetry.lock
108
+
109
+ # pdm
110
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
111
+ #pdm.lock
112
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
113
+ # in version control.
114
+ # https://pdm.fming.dev/#use-with-ide
115
+ .pdm.toml
116
+
117
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
118
+ __pypackages__/
119
+
120
+ # Celery stuff
121
+ celerybeat-schedule
122
+ celerybeat.pid
123
+
124
+ # SageMath parsed files
125
+ *.sage.py
126
+
127
+ # Environments
128
+ .env
129
+ .venv
130
+ env/
131
+ venv/
132
+ ENV/
133
+ env.bak/
134
+ venv.bak/
135
+
136
+ # Spyder project settings
137
+ .spyderproject
138
+ .spyproject
139
+
140
+ # Rope project settings
141
+ .ropeproject
142
+
143
+ # mkdocs documentation
144
+ /site
145
+
146
+ # mypy
147
+ .mypy_cache/
148
+ .dmypy.json
149
+ dmypy.json
150
+
151
+ # Pyre type checker
152
+ .pyre/
153
+
154
+ # pytype static type analyzer
155
+ .pytype/
156
+
157
+ # Cython debug symbols
158
+ cython_debug/
159
+
160
+ # PyCharm
161
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
162
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
163
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
164
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
165
+ #.idea/
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present Purple Jay LLC <developers@purplejay.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.3
2
+ Name: pjdev-op
3
+ Version: 3.7.1a1
4
+ Project-URL: Documentation, https://gitlab.purplejay.net/keystone/python/-/tree/main/pjdev-op/README.md
5
+ Project-URL: Issues, https://gitlab.purplejay.net/keystone/python/-/issues
6
+ Project-URL: Source, https://gitlab.purplejay.net/keystone/python
7
+ Author-email: Purple Jay LLC <developers@purplejay.io>
8
+ License-Expression: MIT
9
+ License-File: LICENSE.txt
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: Implementation :: CPython
14
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
15
+ Requires-Python: >=3.12
16
+ Requires-Dist: loguru
17
+ Requires-Dist: nest-asyncio
18
+ Requires-Dist: onepassword-sdk
19
+ Requires-Dist: pydantic
20
+ Requires-Dist: pydantic-settings
21
+ Description-Content-Type: text/markdown
22
+
23
+ # pjdev-op
24
+
25
+ [![PyPI - Version](https://img.shields.io/pypi/v/pjdev-op.svg)](https://pypi.org/project/pjdev-op)
26
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pjdev-op.svg)](https://pypi.org/project/pjdev-op)
27
+
28
+ -----
29
+
30
+ ## Table of Contents
31
+
32
+ - [Installation](#installation)
33
+ - [License](#license)
34
+
35
+ ## Installation
36
+
37
+ ```console
38
+ pip install pjdev-op
39
+ ```
40
+
41
+ ## License
42
+
43
+ `pjdev-op` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,21 @@
1
+ # pjdev-op
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/pjdev-op.svg)](https://pypi.org/project/pjdev-op)
4
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pjdev-op.svg)](https://pypi.org/project/pjdev-op)
5
+
6
+ -----
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [License](#license)
12
+
13
+ ## Installation
14
+
15
+ ```console
16
+ pip install pjdev-op
17
+ ```
18
+
19
+ ## License
20
+
21
+ `pjdev-op` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,63 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "pjdev-op"
7
+ dynamic = ["version"]
8
+ description = ''
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "MIT"
12
+ keywords = []
13
+ authors = [
14
+ { name = "Purple Jay LLC", email = "developers@purplejay.io" },
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: Implementation :: CPython",
21
+ "Programming Language :: Python :: Implementation :: PyPy",
22
+ ]
23
+ dependencies = [
24
+ "onepassword-sdk",
25
+ "loguru",
26
+ "nest-asyncio",
27
+ "pydantic-settings",
28
+ "pydantic"
29
+ ]
30
+
31
+ [project.urls]
32
+ Documentation = "https://gitlab.purplejay.net/keystone/python/-/tree/main/pjdev-op/README.md"
33
+ Issues = "https://gitlab.purplejay.net/keystone/python/-/issues"
34
+ Source = "https://gitlab.purplejay.net/keystone/python"
35
+
36
+ [tool.hatch.version]
37
+ path = "src/pjdev_op/__about__.py"
38
+
39
+ [tool.hatch.envs.types]
40
+ extra-dependencies = [
41
+ "mypy>=1.0.0",
42
+ ]
43
+ [tool.hatch.envs.types.scripts]
44
+ check = "mypy --install-types --non-interactive {args:src/pjdev_op tests}"
45
+
46
+ [tool.coverage.run]
47
+ source_pkgs = ["pjdev_op", "tests"]
48
+ branch = true
49
+ parallel = true
50
+ omit = [
51
+ "src/pjdev_op/__about__.py",
52
+ ]
53
+
54
+ [tool.coverage.paths]
55
+ pjdev_op = ["src/pjdev_op", "*/pjdev-op/src/pjdev_op"]
56
+ tests = ["tests", "*/pjdev-op/tests"]
57
+
58
+ [tool.coverage.report]
59
+ exclude_lines = [
60
+ "no cov",
61
+ "if __name__ == .__main__.:",
62
+ "if TYPE_CHECKING:",
63
+ ]
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2024-present Chris O'Neill <chris@purplejay.io>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "3.7.1a1"
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2024-present Chris O'Neill <chris@purplejay.io>
2
+ #
3
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,87 @@
1
+ import asyncio
2
+
3
+ from onepassword import Client, ItemField, VaultOverview, ItemOverview
4
+ from pydantic_settings import BaseSettings, SettingsConfigDict
5
+
6
+ __ctx = {}
7
+
8
+
9
+ class Config(BaseSettings):
10
+ service_token: str
11
+
12
+ model_config = SettingsConfigDict(
13
+ env_prefix="OP_",
14
+ case_sensitive=False,
15
+ extra="ignore",
16
+ )
17
+
18
+
19
+ def __get_client() -> Client:
20
+ return __ctx["client"]
21
+
22
+
23
+ def __get_config() -> Config:
24
+ return __ctx["config"]
25
+
26
+
27
+ async def init() -> None:
28
+ __ctx["config"] = Config()
29
+
30
+ client = await Client.authenticate(
31
+ auth=__get_config().service_token,
32
+ integration_name="pj-stack",
33
+ integration_version="v1.0.0",
34
+ )
35
+
36
+ __ctx["client"] = client
37
+
38
+
39
+ async def load_secret(op_path: str) -> str:
40
+ client = __get_client()
41
+ return await client.secrets.resolve(f"op://{op_path}")
42
+
43
+
44
+ async def update_secret(
45
+ item_name: str, vault_name: str, field_title: str, new_field_value: str
46
+ ) -> ItemField:
47
+ client = __get_client()
48
+
49
+ vault = await get_vault_by_name(vault_name)
50
+ item_overview = await get_item_by_name(vault.id, item_name)
51
+ item = await client.items.get(vault_id=vault.id, item_id=item_overview.id)
52
+ filtered_fields_indices = [
53
+ ndx for ndx, f in enumerate(item.fields) if f.title == field_title
54
+ ]
55
+ if len(filtered_fields_indices) == 0:
56
+ raise ValueError(f"field {field_title} does not exist")
57
+
58
+ item.fields[filtered_fields_indices[0]].value = new_field_value
59
+ updated_item = await client.items.put(item)
60
+ return updated_item
61
+
62
+
63
+ async def get_vault_by_name(name: str) -> VaultOverview:
64
+ client = __get_client()
65
+
66
+ vaults = await client.vaults.list_all()
67
+ async for vault in vaults:
68
+ if vault.title == name:
69
+ return vault
70
+
71
+
72
+ async def get_item_by_name(vault_id: str, name: str) -> ItemOverview:
73
+ client = __get_client()
74
+ items = await client.items.list_all(vault_id=vault_id)
75
+
76
+ async for item in items:
77
+ if item.title == name:
78
+ return item
79
+
80
+
81
+ if __name__ == "__main__":
82
+
83
+ async def main() -> None:
84
+ await init()
85
+ await update_secret("dummy", "fake", "test", "1234")
86
+
87
+ asyncio.run(main())
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2024-present Chris O'Neill <chris@purplejay.io>
2
+ #
3
+ # SPDX-License-Identifier: MIT