|
17 | 17 | from .tasks import Task |
18 | 18 | from .variants import Variants |
19 | 19 |
|
| 20 | +class ContentItemRepository(Resource): |
| 21 | + def __init__(self, params: ResourceParameters, content_guid: str, **kwargs) -> None: |
| 22 | + super().__init__(params, **kwargs) |
| 23 | + self.content_guid = content_guid |
| 24 | + |
| 25 | + def delete(self) -> None: |
| 26 | + """Delete the content's repository.""" |
| 27 | + path = f"v1/content/{self.content_guid}/repository" |
| 28 | + url = self.params.url + path |
| 29 | + self.params.session.delete(url) |
| 30 | + |
| 31 | + @overload |
| 32 | + def update( |
| 33 | + self, |
| 34 | + *, |
| 35 | + repository: Optional[str] = None, |
| 36 | + branch: Optional[str] = "main", |
| 37 | + directory: Optional[str] = ".", |
| 38 | + polling: Optional[bool] = False, |
| 39 | + ) -> None: |
| 40 | + """Update the content's repository. |
| 41 | +
|
| 42 | + Parameters |
| 43 | + ---------- |
| 44 | + repository: str, optional |
| 45 | + URL for the repository. Default is None. |
| 46 | + branch: str, optional |
| 47 | + The tracked Git branch. Default is 'main'. |
| 48 | + directory: str, optional |
| 49 | + Directory containing the content. Default is '.' |
| 50 | + polling: bool, optional |
| 51 | + Indicates that the Git repository is regularly polled. Default is False. |
| 52 | + |
| 53 | +
|
| 54 | + Returns |
| 55 | + ------- |
| 56 | + None |
| 57 | + """ |
| 58 | + ... |
| 59 | + |
| 60 | + @overload |
| 61 | + def update(self, **attributes: Any) -> None: |
| 62 | + """Update the content's repository.""" |
| 63 | + ... |
| 64 | + |
| 65 | + def update(self, **attributes: Any) -> None: |
| 66 | + """Update the content's repository.""" |
| 67 | + url = self.params.url + f"v1/content/{self.content_guid}/repository" |
| 68 | + response = self.params.session.patch(url, json=attributes) |
| 69 | + super().update(**response.json()) |
20 | 70 |
|
21 | 71 | class ContentItemOAuth(Resource): |
22 | 72 | def __init__(self, params: ResourceParameters, content_guid: str) -> None: |
@@ -101,6 +151,16 @@ def render(self) -> Task: |
101 | 151 | f"Render not supported for this application mode: {self.app_mode}. Did you need to use the 'restart()' method instead? Note that some application modes do not support 'render()' or 'restart()'." |
102 | 152 | ) |
103 | 153 |
|
| 154 | + |
| 155 | + def repository(self) -> ContentItemRepository: |
| 156 | + """Return the content item's git repository, if one exists""" |
| 157 | + |
| 158 | + path = f"v1/content/{self.guid}/repository" |
| 159 | + url = self.params.url + path |
| 160 | + response = self.params.session.get(url) |
| 161 | + return ContentItemRepository(self.params, self['guid'], **response.json()) |
| 162 | + |
| 163 | + |
104 | 164 | def restart(self) -> None: |
105 | 165 | """Mark for restart. |
106 | 166 |
|
|
0 commit comments