From 780ca207e0ac842b52117acd79c8770a33813966 Mon Sep 17 00:00:00 2001 From: tdstein Date: Fri, 26 Apr 2024 10:51:59 -0400 Subject: [PATCH] docs: adds additional docstrings --- src/posit/connect/content.py | 8 ++++++++ src/posit/connect/tasks.py | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/posit/connect/content.py b/src/posit/connect/content.py index 2261fd2f..4213b426 100644 --- a/src/posit/connect/content.py +++ b/src/posit/connect/content.py @@ -221,10 +221,18 @@ def delete(self) -> None: def deploy(self) -> tasks.Task: """Deploy the content. + Spawns an asynchronous task, which activates the latest bundle. + Returns ------- tasks.Task The task for the deployment. + + Examples + -------- + >>> task = content.deploy() + >>> task.wait_for() + None """ path = f"v1/content/{self.guid}/deploy" url = urls.append(self.config.url, path) diff --git a/src/posit/connect/tasks.py b/src/posit/connect/tasks.py index 24aff6f9..05554449 100644 --- a/src/posit/connect/tasks.py +++ b/src/posit/connect/tasks.py @@ -98,7 +98,29 @@ def update(self, *args, **kwargs) -> None: ... def update(self, *args, **kwargs) -> None: - """Update the task.""" + """Update the task. + + See Also + -------- + task.wait_for : Wait for the task to complete. + + Notes + ----- + When waiting for a task to complete, one should consider utilizing `task.wait_for`. + + Examples + -------- + >>> task.output + [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." + ] + >>> task.update() + >>> task.output + [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Pretium aenean pharetra magna ac placerat vestibulum lectus mauris." + ] + """ params = dict(*args, **kwargs) path = f"v1/tasks/{self.id}" url = urls.append(self.config.url, path) @@ -113,6 +135,16 @@ def wait_for(self, sleep: int = 1) -> None: ---------- sleep : int, optional Maximum number of seconds to wait between status checks. + + Examples + -------- + >>> task = tasks.get(task_id) + >>> task.wait_for() + None + + >>> task tasks.get(task_id) + >>> task.wait_for(5) # wait five seconds between status checks + None """ while not self.is_finished: self.update(wait=sleep)