Skip to content

Conversation

@tdstein
Copy link
Collaborator

@tdstein tdstein commented Dec 10, 2024

Adds environment support.

The create, update, and destroy methods are abstracted in the resources module as base classes. This alleviates potential duplication across API bindings. Future changes should utilize these classes instead of reimplementing these methods from scratch.

Closes #307

@github-actions
Copy link

github-actions bot commented Dec 10, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
2155 2029 94% 0% 🟢

New Files

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

Modified Files

File Coverage Status
src/posit/connect/client.py 99% 🟢
src/posit/connect/resources.py 89% 🟢
TOTAL 94% 🟢

updated for commit: 2c6d327 by action🐍

@tdstein tdstein force-pushed the tdstein/307-environments branch from 3391873 to eddfc31 Compare December 10, 2024 19:01
@tdstein tdstein force-pushed the tdstein/307-environments branch from f552fe2 to 2942856 Compare December 11, 2024 18:39
@tdstein tdstein changed the title --wip-- feat: add environments Dec 11, 2024
@tdstein tdstein marked this pull request as ready for review December 11, 2024 18:49
endpoint = self._ctx.url + self._path
response = self._ctx.session.put(endpoint, json=attributes)
result = response.json()
super().update(**result)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would we like for this method to return a new definition of self?

Something like

Suggested change
super().update(**result)
return self.__class__(**result)

This sets up an easy transition to a read only self.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm ok with keeping the .update() as is. I'd like to make a followup PR to revert Task.update and ContentItemRepository.update

Comment on lines +43 to +57
id: str,
guid: str,
created_time: str,
updated_time: str,
title: str,
name: str,
description: str | None,
cluster_name: str | Literal["Kubernetes"],
environment_type: str | Literal["Kubernetes"],
matching: Literal["any", "exact", "none"],
supervisor: str | None,
python: _Installations | None,
quarto: _Installations | None,
r: _Installations | None,
tensorflow: _Installations | None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these variables be Unpack[_Attrs] so that if typing isn't followed 100% there is some sort of type check?

Something like:

def __init__(self, ctx: Context, path: str, /, **attributes: Unpack[_Attrs]):

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same applies to .update(), .create(), and .find_by() below

@tdstein
Copy link
Collaborator Author

tdstein commented Dec 12, 2024

Closing in favor of #355

@tdstein tdstein closed this Dec 12, 2024
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.

Add Environments API endpoint bindings

3 participants