Skip to content

Commit ca8336e

Browse files
committed
cleanup
1 parent 91aa99b commit ca8336e

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

integration/tests/posit/connect/test_vanities.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class TestVanities:
5-
65
@classmethod
76
def setup_class(cls):
87
cls.client = connect.Client()
@@ -52,7 +51,6 @@ def test_property(self):
5251
# Cleanup
5352
content.delete()
5453

55-
5654
def test_destroy(self):
5755
content = self.client.content.create(name="example")
5856

src/posit/connect/vanities.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from .errors import ClientError
66
from .resources import Resource, ResourceParameters, Resources
77

8-
AfterDestroyCallback = Callable[[], None]
9-
108

119
class Vanity(Resource):
1210
"""A vanity resource.
@@ -44,17 +42,22 @@ class Vanity(Resource):
4442
- `/content`
4543
"""
4644

47-
_fuid: str = "content_guid"
48-
"""str : the foreign unique identifier field that points to the owner of this vanity, by default 'content_guid'"""
45+
AfterDestroyCallback = Callable[[], None]
46+
47+
class VanityAttributes(TypedDict):
48+
"""Vanity attributes."""
49+
50+
path: str
51+
content_guid: Required[str]
52+
created_time: str
4953

5054
def __init__(
5155
self,
5256
/,
5357
params: ResourceParameters,
5458
*,
55-
content_guid: str,
5659
after_destroy: Optional[AfterDestroyCallback] = None,
57-
**kwargs,
60+
**kwargs: Unpack[VanityAttributes],
5861
):
5962
"""Initialize a Vanity.
6063
@@ -64,9 +67,13 @@ def __init__(
6467
after_destroy : AfterDestroyCallback, optional
6568
Called after the Vanity is successfully destroyed, by default None
6669
"""
67-
super().__init__(params, content_guid=content_guid, **kwargs)
68-
self._endpoint = self.params.url + f"v1/content/{content_guid}/vanity"
70+
super().__init__(params, **kwargs)
6971
self._after_destroy = after_destroy
72+
self._content_guid = kwargs["content_guid"]
73+
74+
@property
75+
def _endpoint(self):
76+
return self.params.url + f"v1/content/{self._content_guid}/vanity"
7077

7178
def destroy(self) -> None:
7279
"""Destroy the vanity.
@@ -120,12 +127,12 @@ class HasGuid(TypedDict):
120127

121128
def __init__(self, /, params: ResourceParameters, **kwargs: Unpack[HasGuid]):
122129
super().__init__(params, **kwargs)
123-
self._uid = kwargs['guid']
130+
self._content_guid = kwargs["guid"]
124131
self._vanity: Optional[Vanity] = None
125132

126133
@property
127134
def _endpoint(self):
128-
return self.params.url + f"v1/content/{self._uid}/vanity"
135+
return self.params.url + f"v1/content/{self._content_guid}/vanity"
129136

130137
@property
131138
def vanity(self) -> Optional[Vanity]:

0 commit comments

Comments
 (0)