Skip to content

feat: support scheduling content - #485

Merged
karawoo merged 4 commits into
mainfrom
kara/python-schedule-api
Jul 13, 2026
Merged

feat: support scheduling content#485
karawoo merged 4 commits into
mainfrom
kara/python-schedule-api

Conversation

@karawoo

@karawoo karawoo commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This adds a way to manage schedules for content on Connect. Closes #484.

The default variant's schedule can be managed with content.schedule, which supports looking up the schedule (find_one()), creating/updating a schedule (set()), and removing a schedule (delete()). variant.schedules does the same for a specific variant. set() creates or updates as needed and has per-type overloads, so pyright catches invalid parameter combinations.

Because this is backed by unversioned endpoints, set() and delete() emit FutureWarning similar to how we do for send_mail:

warnings.warn(
"send_mail() is experimental and may change in future releases.",
FutureWarning,
stacklevel=2,
)

I'm a little on the fence about these warnings and am open to removing them. I do think it's good to convey that this functionality relies on unversioned endpoints that Connect may change or remove.

@karawoo
karawoo requested a review from tdstein as a code owner July 8, 2026 22:21
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
2509 2359 94% 0% 🟢

New Files

File Coverage Status
src/posit/connect/schedules.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
src/posit/connect/content.py 99% 🟢
src/posit/connect/variants.py 100% 🟢
TOTAL 99% 🟢

updated for commit: cecd149 by action🐍

@karawoo
karawoo requested a review from a team July 8, 2026 22:24

@lucasrod16 lucasrod16 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a first pass at this and will followup with another pass. The overall API surface looks good to me so far

Comment thread src/posit/connect/content.py
Comment thread integration/tests/posit/connect/test_schedules.py

@lucasrod16 lucasrod16 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the first API resource in this SDK to use a set() method as opposed to create()/update(), but I think it provides a better UX since users don't have to know about or handle the create vs update decision and details themselves.

I think we should handle the app_mode == "unknown" case in content.schedule before merge, otherwise this LGTM.

Comment thread src/posit/connect/schedules.py

@tdstein tdstein left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall!

Although, the amount of logic required to make the Schedules API idiomatic in Python is unfortunate...

Comment thread src/posit/connect/variants.py Outdated
Comment thread src/posit/connect/schedules.py Outdated
Comment thread src/posit/connect/schedules.py Outdated
)
return variants[0]

@cached_property

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting. I've never used cached_property. Did you include this to avoid recomputing the default variant? Is there any risk that the default variant changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's there to avoid re-resolving the default variant. Without caching, create() followed by find_one() would look it up twice. I don't think the default variant changes so I think this should be safe.

karawoo and others added 3 commits July 13, 2026 11:21
Co-authored-by: Taylor Steinberg <taylor.steinberg@posit.co>
@karawoo

karawoo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback everyone. I opted to rename from set to create for consistency, though I do think set() has some advantages too.

@karawoo
karawoo merged commit 3026e0a into main Jul 13, 2026
55 checks passed
@karawoo
karawoo deleted the kara/python-schedule-api branch July 13, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support creating/setting content schedules programmatically

4 participants