Coverage for src/hush_hush/_generated/models/create_object_request.py: 66%
62 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-16 16:01 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-16 16:01 +0000
1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT.
3from __future__ import annotations
5from collections.abc import Mapping
6from typing import Any, TypeVar, cast
8from attrs import define as _attrs_define
9from attrs import field as _attrs_field
11from ..types import UNSET, Unset
13T = TypeVar("T", bound="CreateObjectRequest")
16@_attrs_define
17class CreateObjectRequest:
18 """
19 Attributes:
20 slug (str): A caller-chosen, unique identifier for an object - what every
21 documented request path (URL, CLI, API) addresses it by. Letters of
22 either case, digits, `_` and `-`, starting with a letter or digit;
23 names are case-sensitive, so `Api_Token` and `api_token` are two
24 secrets. Create and rename follow the same rule. The
25 object's internal id is a separate, opaque value never exposed to
26 or accepted from a caller (specs/secret-objects/spec.md's
27 "Internal id decoupled from user-facing slug" requirement).
28 value (str): The sealed (encrypted) value, base64-encoded. It has to be a
29 well-formed age file naming at least one recipient; the
30 service reads only its header, never the payload. At most 1 MiB
31 once decoded.
32 used_by (list[str] | Unset): The consumers (repos or hosts) recorded as depending on this
33 object. Set at creation, and replaceable later via
34 UpdateObjectRequest's own used_by field - a plain value update
35 that omits it leaves the list as it was.
36 A consumer named more than once is recorded once.
37 tags (list[str] | Unset): Labels for grouping and filtering objects (`GET /objects?tag=`).
38 Free-form, 1 to 32 characters from `a-z 0-9 . _ / -`, at most 10
39 per object. Uppercase is converted to lowercase and duplicates are dropped.
40 Metadata only - never part of the sealed value. A response always
41 carries the array, empty when the object has none.
42 description (str | Unset): A free-text label set at creation, for a reader who only knows the
43 slug. Fixed at creation - there is no way to change it later.
44 keep_readable_copy (bool | Unset): Requests that the owner's own escrowed identity public key be
45 included as an additional decrypt recipient, alongside whatever
46 consumer recipients the client already resolved
47 (specs/secret-objects/spec.md's "Opt-in owner-recipient inclusion
48 at create time" requirement). Omitting this field (the default)
49 means the owner is not added as a recipient - this service never
50 makes ownership imply decrypt access on its own.
52 This is a client-side sealing instruction, not something this
53 service enforces or verifies: it never decrypts, and never adds a
54 recipient to `value` itself - the caller has to add the owner's
55 public key (`GET /auth/identity`) to its own recipient list before
56 sealing. A create or update response echoes back exactly what that
57 same request asked for; it isn't persisted, so a later fetch never
58 carries this field.
59 """
61 slug: str
62 value: str
63 used_by: list[str] | Unset = UNSET
64 tags: list[str] | Unset = UNSET
65 description: str | Unset = UNSET
66 keep_readable_copy: bool | Unset = UNSET
67 additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
69 def to_dict(self) -> dict[str, Any]:
70 slug = self.slug
72 value = self.value
74 used_by: list[str] | Unset = UNSET
75 if not isinstance(self.used_by, Unset):
76 used_by = self.used_by
78 tags: list[str] | Unset = UNSET
79 if not isinstance(self.tags, Unset):
80 tags = self.tags
82 description = self.description
84 keep_readable_copy = self.keep_readable_copy
86 field_dict: dict[str, Any] = {}
87 field_dict.update(self.additional_properties)
88 field_dict.update(
89 {
90 "slug": slug,
91 "value": value,
92 }
93 )
94 if used_by is not UNSET:
95 field_dict["used_by"] = used_by
96 if tags is not UNSET:
97 field_dict["tags"] = tags
98 if description is not UNSET:
99 field_dict["description"] = description
100 if keep_readable_copy is not UNSET:
101 field_dict["keep_readable_copy"] = keep_readable_copy
103 return field_dict
105 @classmethod
106 def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
107 d = dict(src_dict)
108 slug = d.pop("slug")
110 value = d.pop("value")
112 used_by = cast(list[str], d.pop("used_by", UNSET))
114 tags = cast(list[str], d.pop("tags", UNSET))
116 description = d.pop("description", UNSET)
118 keep_readable_copy = d.pop("keep_readable_copy", UNSET)
120 create_object_request = cls(
121 slug=slug,
122 value=value,
123 used_by=used_by,
124 tags=tags,
125 description=description,
126 keep_readable_copy=keep_readable_copy,
127 )
129 create_object_request.additional_properties = d
130 return create_object_request
132 @property
133 def additional_keys(self) -> list[str]:
134 return list(self.additional_properties.keys())
136 def __getitem__(self, key: str) -> Any:
137 return self.additional_properties[key]
139 def __setitem__(self, key: str, value: Any) -> None:
140 self.additional_properties[key] = value
142 def __delitem__(self, key: str) -> None:
143 del self.additional_properties[key]
145 def __contains__(self, key: str) -> bool:
146 return key in self.additional_properties