Skip to content

Commit 8bffc7f

Browse files
committed
Export types correctly
1 parent abfffea commit 8bffc7f

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

example/example.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
from onepassword import *
44

5-
65
async def main():
76
# Gets your service account token from the OP_SERVICE_ACCOUNT_TOKEN environment variable.
87
token = os.getenv("OP_SERVICE_ACCOUNT_TOKEN")
@@ -16,15 +15,15 @@ async def main():
1615
)
1716

1817
# Retrieves a secret from 1Password. Takes a secret reference as input and returns the secret to which it points.
19-
value = await client.secrets.resolve("op://vault/item/field")
20-
print(value)
18+
# value = await client.secrets.resolve("op://vault/item/field")
19+
# print(value)
2120

2221
# Create an Item and add it to your vault.
2322
to_create = Item(
2423
id="",
2524
title="MyName",
2625
category="Login",
27-
vault_id="vault_id",
26+
vault_id="q73bqltug6xoegr3wkk2zkenoq",
2827
fields=[
2928
ItemField(
3029
id="username",
@@ -48,7 +47,7 @@ async def main():
4847
print(dict(created_item))
4948

5049
# Retrieve an item from your vault.
51-
item = await client.items.get("vault_id", created_item.id)
50+
item = await client.items.get(created_item.vault_id, created_item.id)
5251

5352
print(dict(item))
5453

@@ -59,7 +58,7 @@ async def main():
5958
print(dict(updated_item))
6059

6160
# Delete a item from your vault.
62-
await client.items.delete("vault_id", updated_item.id)
61+
await client.items.delete(created_item.vault_id, updated_item.id)
6362

6463

6564
if __name__ == "__main__":

src/onepassword/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .secrets import Secrets
66
from .items import Items
77

8+
import sys, inspect, typing
89

910
__all__ = [
1011
"Client",
@@ -14,5 +15,6 @@
1415
"DEFAULT_INTEGRATION_VERSION",
1516
]
1617

17-
if hasattr(types, "__all__"):
18-
__all__ += types.__all__
18+
for name, obj in inspect.getmembers(sys.modules["onepassword.types"]):
19+
if inspect.isclass(obj) or type(eval(name)) == typing._LiteralGenericAlias:
20+
__all__.append(name)

src/onepassword/types.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@
22
Generated by typeshare 1.9.2
33
"""
44

5-
from __future__ import annotations
6-
75
from pydantic import BaseModel
86
from typing import List, Literal, Optional
97

108

11-
class Item(BaseModel):
12-
id: str
13-
title: str
14-
category: ItemCategory
15-
vault_id: str
16-
fields: List[ItemField]
17-
sections: List[ItemSection]
18-
19-
209
ItemCategory = Literal[
2110
"Login",
2211
"SecureNote",
@@ -45,6 +34,9 @@ class Item(BaseModel):
4534
]
4635

4736

37+
ItemFieldType = Literal["Text", "Concealed", "Unsupported"]
38+
39+
4840
class ItemField(BaseModel):
4941
id: str
5042
title: str
@@ -53,9 +45,15 @@ class ItemField(BaseModel):
5345
value: str
5446

5547

56-
ItemFieldType = Literal["Text", "Concealed", "Unsupported"]
48+
class ItemSection(BaseModel):
49+
id: str
50+
title: str
5751

5852

59-
class ItemSection(BaseModel):
53+
class Item(BaseModel):
6054
id: str
6155
title: str
56+
category: ItemCategory
57+
vault_id: str
58+
fields: List[ItemField]
59+
sections: List[ItemSection]

0 commit comments

Comments
 (0)