Skip to content

Commit 8c5bb3e

Browse files
Update core to version 9be455ec
1 parent ef6be31 commit 8c5bb3e

File tree

7 files changed

+205
-2
lines changed

7 files changed

+205
-2
lines changed
318 KB
Binary file not shown.
348 KB
Binary file not shown.
309 KB
Binary file not shown.
325 KB
Binary file not shown.
288 KB
Binary file not shown.

src/onepassword/secrets.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .iterator import SDKIterator
55
from typing import Optional, List
66
from pydantic import TypeAdapter
7-
from .types import GeneratePasswordResponse, PasswordRecipe
7+
from .types import GeneratePasswordResponse, PasswordRecipe, ResolveAllResponse
88

99

1010
class Secrets:
@@ -35,6 +35,25 @@ async def resolve(self, secret_reference: str) -> str:
3535
response = TypeAdapter(str).validate_json(response)
3636
return response
3737

38+
async def resolve_all(self, secret_references: List[str]) -> ResolveAllResponse:
39+
"""
40+
Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
41+
"""
42+
response = await _invoke(
43+
{
44+
"invocation": {
45+
"clientId": self.client_id,
46+
"parameters": {
47+
"name": "SecretsResolveAll",
48+
"parameters": {"secret_references": secret_references},
49+
},
50+
}
51+
}
52+
)
53+
54+
response = TypeAdapter(ResolveAllResponse).validate_json(response)
55+
return response
56+
3857
@staticmethod
3958
def validate_secret_reference(secret_reference: str) -> None:
4059
"""

src/onepassword/types.py

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

77
from enum import Enum
88
from pydantic import BaseModel, ConfigDict, Field
9-
from typing import List, Literal, Optional, Union
9+
from typing import Generic, List, Literal, Optional, TypeVar, Union
10+
11+
E = TypeVar("E")
12+
T = TypeVar("T")
13+
14+
15+
ErrorMessage = str
1016

1117

1218
class GeneratePasswordResponse(BaseModel):
@@ -453,6 +459,184 @@ class OtpFieldDetails(BaseModel):
453459
"""
454460

455461

462+
class Response(BaseModel, Generic[T, E]):
463+
content: Optional[T] = Field(default=None)
464+
error: Optional[E] = Field(default=None)
465+
466+
467+
class ResolveReferenceErrorTypes(str, Enum):
468+
PARSING = "parsing"
469+
FIELD_NOT_FOUND = "fieldNotFound"
470+
VAULT_NOT_FOUND = "vaultNotFound"
471+
TOO_MANY_VAULTS = "tooManyVaults"
472+
ITEM_NOT_FOUND = "itemNotFound"
473+
TOO_MANY_ITEMS = "tooManyItems"
474+
TOO_MANY_MATCHING_FIELDS = "tooManyMatchingFields"
475+
NO_MATCHING_SECTIONS = "noMatchingSections"
476+
TOO_MANY_MATCHING_SECTIONS = "tooManyMatchingSections"
477+
INCOMPATIBLE_TOTP_QUERY_PARAMETER_FIELD = "incompatibleTOTPQueryParameterField"
478+
UNABLE_TO_GENERATE_TOTP_CODE = "unableToGenerateTotpCode"
479+
S_SH_KEY_METADATA_NOT_FOUND = "sSHKeyMetadataNotFound"
480+
UNSUPPORTED_FILE_FORMAT = "unsupportedFileFormat"
481+
482+
483+
class ResolveReferenceErrorParsing(BaseModel):
484+
"""
485+
Error parsing the secret reference
486+
"""
487+
488+
type: Literal[ResolveReferenceErrorTypes.PARSING] = (
489+
ResolveReferenceErrorTypes.PARSING
490+
)
491+
message: ErrorMessage
492+
493+
494+
class ResolveReferenceErrorFieldNotFound(BaseModel):
495+
"""
496+
The specified reference cannot be found within the item
497+
"""
498+
499+
type: Literal[ResolveReferenceErrorTypes.FIELD_NOT_FOUND] = (
500+
ResolveReferenceErrorTypes.FIELD_NOT_FOUND
501+
)
502+
503+
504+
class ResolveReferenceErrorVaultNotFound(BaseModel):
505+
"""
506+
No vault matched the secret reference query
507+
"""
508+
509+
type: Literal[ResolveReferenceErrorTypes.VAULT_NOT_FOUND] = (
510+
ResolveReferenceErrorTypes.VAULT_NOT_FOUND
511+
)
512+
513+
514+
class ResolveReferenceErrorTooManyVaults(BaseModel):
515+
"""
516+
More than one vault matched the secret reference query
517+
"""
518+
519+
type: Literal[ResolveReferenceErrorTypes.TOO_MANY_VAULTS] = (
520+
ResolveReferenceErrorTypes.TOO_MANY_VAULTS
521+
)
522+
523+
524+
class ResolveReferenceErrorItemNotFound(BaseModel):
525+
"""
526+
No item matched the secret reference query
527+
"""
528+
529+
type: Literal[ResolveReferenceErrorTypes.ITEM_NOT_FOUND] = (
530+
ResolveReferenceErrorTypes.ITEM_NOT_FOUND
531+
)
532+
533+
534+
class ResolveReferenceErrorTooManyItems(BaseModel):
535+
"""
536+
More than one item matched the secret reference query
537+
"""
538+
539+
type: Literal[ResolveReferenceErrorTypes.TOO_MANY_ITEMS] = (
540+
ResolveReferenceErrorTypes.TOO_MANY_ITEMS
541+
)
542+
543+
544+
class ResolveReferenceErrorTooManyMatchingFields(BaseModel):
545+
"""
546+
More than one field matched the provided secret reference
547+
"""
548+
549+
type: Literal[ResolveReferenceErrorTypes.TOO_MANY_MATCHING_FIELDS] = (
550+
ResolveReferenceErrorTypes.TOO_MANY_MATCHING_FIELDS
551+
)
552+
553+
554+
class ResolveReferenceErrorNoMatchingSections(BaseModel):
555+
"""
556+
No section found within the item for the provided identifier
557+
"""
558+
559+
type: Literal[ResolveReferenceErrorTypes.NO_MATCHING_SECTIONS] = (
560+
ResolveReferenceErrorTypes.NO_MATCHING_SECTIONS
561+
)
562+
563+
564+
class ResolveReferenceErrorTooManyMatchingSections(BaseModel):
565+
"""
566+
More than one matching section found within the item
567+
"""
568+
569+
type: Literal[ResolveReferenceErrorTypes.TOO_MANY_MATCHING_SECTIONS] = (
570+
ResolveReferenceErrorTypes.TOO_MANY_MATCHING_SECTIONS
571+
)
572+
573+
574+
class ResolveReferenceErrorIncompatibleTOTPQueryParameterField(BaseModel):
575+
"""
576+
Incompatiable TOTP query parameters
577+
"""
578+
579+
type: Literal[
580+
ResolveReferenceErrorTypes.INCOMPATIBLE_TOTP_QUERY_PARAMETER_FIELD
581+
] = ResolveReferenceErrorTypes.INCOMPATIBLE_TOTP_QUERY_PARAMETER_FIELD
582+
583+
584+
class ResolveReferenceErrorUnableToGenerateTotpCode(BaseModel):
585+
"""
586+
The totp was not able to be generated
587+
"""
588+
589+
type: Literal[ResolveReferenceErrorTypes.UNABLE_TO_GENERATE_TOTP_CODE] = (
590+
ResolveReferenceErrorTypes.UNABLE_TO_GENERATE_TOTP_CODE
591+
)
592+
message: ErrorMessage
593+
594+
595+
class ResolveReferenceErrorSSHKeyMetadataNotFound(BaseModel):
596+
"""
597+
Couldn't find attributes specific to an SSH Key field
598+
"""
599+
600+
type: Literal[ResolveReferenceErrorTypes.S_SH_KEY_METADATA_NOT_FOUND] = (
601+
ResolveReferenceErrorTypes.S_SH_KEY_METADATA_NOT_FOUND
602+
)
603+
604+
605+
class ResolveReferenceErrorUnsupportedFileFormat(BaseModel):
606+
"""
607+
Currently only support text files
608+
"""
609+
610+
type: Literal[ResolveReferenceErrorTypes.UNSUPPORTED_FILE_FORMAT] = (
611+
ResolveReferenceErrorTypes.UNSUPPORTED_FILE_FORMAT
612+
)
613+
614+
615+
ResolveReferenceError = Union[
616+
ResolveReferenceErrorParsing,
617+
ResolveReferenceErrorFieldNotFound,
618+
ResolveReferenceErrorVaultNotFound,
619+
ResolveReferenceErrorTooManyVaults,
620+
ResolveReferenceErrorItemNotFound,
621+
ResolveReferenceErrorTooManyItems,
622+
ResolveReferenceErrorTooManyMatchingFields,
623+
ResolveReferenceErrorNoMatchingSections,
624+
ResolveReferenceErrorTooManyMatchingSections,
625+
ResolveReferenceErrorIncompatibleTOTPQueryParameterField,
626+
ResolveReferenceErrorUnableToGenerateTotpCode,
627+
ResolveReferenceErrorSSHKeyMetadataNotFound,
628+
ResolveReferenceErrorUnsupportedFileFormat,
629+
]
630+
631+
632+
class ResolveAllResponse(BaseModel):
633+
model_config = ConfigDict(populate_by_name=True)
634+
635+
individual_responses: List[Response[str, ResolveReferenceError]] = Field(
636+
alias="individualResponses"
637+
)
638+
639+
456640
class VaultOverview(BaseModel):
457641
"""
458642
Represents a decrypted 1Password vault.

0 commit comments

Comments
 (0)