Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/support boot timeout #1

Open
wants to merge 6 commits into
base: add_sni_endpoints
Choose a base branch
from

Conversation

marcelloromani
Copy link

No description provided.

Comment on lines 363 to 367
r = self._h._http_resource(
method="DELETE",
resource=("apps", self.id, "limits", "boot_timeout")
)
return r.status_code

Choose a reason for hiding this comment

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

can these use _get_resource instead of _http_resource and can you please throw together a return value object for this? Just wanna be consistent with the other stuff.

Copy link
Author

Choose a reason for hiding this comment

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

_get_resource only uses GET AFAICT, so there should probably be a _delete_resource method for consistency, I guess.

I agree with the consistency argument, but I'm not sure in this case which return value object I should create, since DELETEing only returns a status code.

Choose a reason for hiding this comment

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

can u find some other instances of DELETE in the codebase and check out what they do there?

Copy link
Author

@marcelloromani marcelloromani Apr 12, 2021

Choose a reason for hiding this comment

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

        """
        Removes a collaborator from a project
        options = id_or_email
        """
        r = self._h._http_resource(method="DELETE", resource=("apps", self.name, "collaborators", id_or_email))
        r.raise_for_status()

        return r.ok

yeah, it was super easy :/

raise_for_status() seems redundant, as it's already executed by _http_resource, https://github.com/smartpension/heroku3.py/blob/master/heroku3/api.py#L209

but a lot of other functions call it anyway, so...


obj = r.json()
assert obj["name"] == "boot_timeout"
return obj["value"]
Copy link
Author

Choose a reason for hiding this comment

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

Re: the return value object, I could probably create a BootTimeout or Limit object and return that for consistency, although it feels a bit over-engineered (we're returning an int after all). I'll try to come up with something.

raise

obj = r.json()
assert obj["name"] == "boot_timeout"
Copy link
Author

Choose a reason for hiding this comment

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

This is not done anywhere else as far as I can tell, but I think a sanity check is always better to have than not to have.
Probably it would be clearer to raise a RunTimeError as anything else than that string, as well as any error raised on line 350, would be a violation of the contract by the APIs.

Choose a reason for hiding this comment

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

if we can find any other isntances of raising if response isn't what we expect and can copy their pattern, that would be amazing. One of the benefits of the value object you're gonna add is that it will fail to initialize if the response isn't the right format though so that should help 😂

@marcelloromani
Copy link
Author

Closing due to branch renaming.

@marcelloromani marcelloromani changed the base branch from add_sni_endpoints to master May 19, 2021 15:25
@marcelloromani marcelloromani changed the base branch from master to add_sni_endpoints May 19, 2021 15:25
@marcelloromani
Copy link
Author

@bclewis1 I forgot why this PR is against add_sni_endpoints, should that branch be merged into master first?

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.

2 participants