Skip to content

Commit ae8bbf1

Browse files
Update core to version 43762a9b
1 parent 1256a90 commit ae8bbf1

File tree

7 files changed

+126
-1
lines changed

7 files changed

+126
-1
lines changed
1.3 MB
Binary file not shown.
1.34 MB
Binary file not shown.
1.31 MB
Binary file not shown.
1.37 MB
Binary file not shown.
1.29 MB
Binary file not shown.

src/onepassword/secrets.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .core import _invoke, _invoke_sync
44
from json import loads
55
from .iterator import SDKIterator
6+
from .types import GeneratePasswordResponse
67

78

89
class Secrets:
@@ -46,3 +47,17 @@ def validate_secret_reference(secret_reference):
4647
}
4748
}
4849
)
50+
51+
@staticmethod
52+
def generate_password(recipe):
53+
response = _invoke_sync(
54+
{
55+
"invocation": {
56+
"parameters": {
57+
"name": "GeneratePassword",
58+
"parameters": {"recipe": recipe.model_dump(by_alias=True)},
59+
}
60+
}
61+
}
62+
)
63+
return GeneratePasswordResponse.model_validate_json(response)

src/onepassword/types.py

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66

77
from enum import Enum
88
from pydantic import BaseModel, ConfigDict, Field
9-
from typing import List, Literal, Optional
9+
from typing import List, Literal, Optional, Union
10+
11+
12+
class GeneratePasswordResponse(BaseModel):
13+
"""
14+
For future use, if we want to return more information about the generated password.
15+
Currently, it only returns the password itself.
16+
"""
17+
18+
password: str
19+
"""
20+
The generated password.
21+
"""
1022

1123

1224
class ItemCategory(str, Enum):
@@ -40,6 +52,7 @@ class ItemFieldType(str, Enum):
4052
TEXT = "Text"
4153
CONCEALED = "Concealed"
4254
CREDITCARDTYPE = "CreditCardType"
55+
CREDITCARDNUMBER = "CreditCardNumber"
4356
PHONE = "Phone"
4457
URL = "Url"
4558
TOTP = "Totp"
@@ -273,3 +286,100 @@ class VaultOverview(BaseModel):
273286
"""
274287
The vault's title
275288
"""
289+
290+
291+
class PasswordRecipeMemorableInner(BaseModel):
292+
"""
293+
Generated type representing the anonymous struct variant `Memorable` of the `PasswordRecipe` Rust enum
294+
"""
295+
296+
model_config = ConfigDict(populate_by_name=True)
297+
298+
separator_type: SeparatorType = Field(alias="separatorType")
299+
"""
300+
The type of separator between chunks.
301+
"""
302+
capitalize: bool
303+
"""
304+
Uppercase one randomly selected chunk.
305+
"""
306+
word_list_type: WordListType = Field(alias="wordListType")
307+
"""
308+
The type of word list used.
309+
"""
310+
word_count: int = Field(alias="wordCount")
311+
"""
312+
The number of "words" (words or syllables).
313+
"""
314+
315+
316+
class PasswordRecipePinInner(BaseModel):
317+
"""
318+
Generated type representing the anonymous struct variant `Pin` of the `PasswordRecipe` Rust enum
319+
"""
320+
321+
length: int
322+
"""
323+
Number of digits in the PIN.
324+
"""
325+
326+
327+
class PasswordRecipeRandomInner(BaseModel):
328+
"""
329+
Generated type representing the anonymous struct variant `Random` of the `PasswordRecipe` Rust enum
330+
"""
331+
332+
model_config = ConfigDict(populate_by_name=True)
333+
334+
include_digits: bool = Field(alias="includeDigits")
335+
"""
336+
Include at least one digit in the password.
337+
"""
338+
include_symbols: bool = Field(alias="includeSymbols")
339+
"""
340+
Include at least one symbol in the password.
341+
"""
342+
length: int
343+
"""
344+
The length of the password.
345+
"""
346+
347+
348+
class PasswordRecipeTypes(str, Enum):
349+
MEMORABLE = "Memorable"
350+
PIN = "Pin"
351+
RANDOM = "Random"
352+
353+
354+
class PasswordRecipeMemorable(BaseModel):
355+
type: Literal[PasswordRecipeTypes.MEMORABLE] = PasswordRecipeTypes.MEMORABLE
356+
parameters: PasswordRecipeMemorableInner
357+
358+
359+
class PasswordRecipePin(BaseModel):
360+
type: Literal[PasswordRecipeTypes.PIN] = PasswordRecipeTypes.PIN
361+
parameters: PasswordRecipePinInner
362+
363+
364+
class PasswordRecipeRandom(BaseModel):
365+
type: Literal[PasswordRecipeTypes.RANDOM] = PasswordRecipeTypes.RANDOM
366+
parameters: PasswordRecipeRandomInner
367+
368+
369+
PasswordRecipe = Union[PasswordRecipeMemorable, PasswordRecipePin, PasswordRecipeRandom]
370+
371+
372+
class SeparatorType(str, Enum):
373+
DIGITS = "digits"
374+
DIGITSANDSYMBOLS = "digitsAndSymbols"
375+
SPACES = "spaces"
376+
HYPHENS = "hyphens"
377+
UNDERSCORES = "underscores"
378+
PERIODS = "periods"
379+
COMMAS = "commas"
380+
381+
382+
class WordListType(str, Enum):
383+
FULLWORDS = "fullWords"
384+
SYLLABLES = "syllables"
385+
THREELETTERS = "threeLetters"

0 commit comments

Comments
 (0)