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

OO API? #1049

Closed
fragmede opened this issue Apr 27, 2016 · 2 comments
Closed

OO API? #1049

fragmede opened this issue Apr 27, 2016 · 2 comments

Comments

@fragmede
Copy link

Hello,

The API currently returns a dict from many calls where it seems, perhaps naively, an object would be more useful. I'm aiming to add some OO notions to the API exposed by docker-py, but not before consulting people here.

For example, Client.create_container returns a dict, and usage looks like:

client = Client()
cont = client.create_container(**info)
if 'Id' in cont:
    client.start(cont['Id'])

with needing both client and cont for the 'start' call. Whereas if create_container returned a hypothetical Container object, the container run code then look like:

client = Client()
cont = client.create_container(**info)
cont.start()

There's a branch called 'objects' that looks like the very beginnings of such an approach, but it hasn't been touched in 3 years, and current master shows no sign of incorporating any OO notions for the API, outside of docker.Client.

Why that approach was dropped? I'd like to look at adding some objects to the API, but not if there were unforeseen issues with that. If there are issues, it would be preferable to have them written down and documented here. (There are various ways to approach supporting legacy code, but if an OO api is fundamentally incisompatible, for whatever reason, then discussing support of legacy code seems premature.)

I was unable to find any docs or issues relating to this particular architectural decision, though I did come across #417 and #538, which aren't this specific question.

@shin-
Copy link
Contributor

shin- commented Apr 27, 2016

It's been considered. A more recent branch that implements a similar behavior is efficiency ( https://github.com/docker/docker-py/commits/efficiency ), but it's not yet at a point where I'm satisfied with it in terms of code quality and robustness, and it's stayed fairly low priority compared to other tasks.

The reality is, not everyone needs or even wants an OO approach, so if any efforts are made in that direction, they should keep the experience intact for people using the library as it is currently.

@bfirsh
Copy link
Contributor

bfirsh commented Nov 28, 2016

#1186. 🎉

@bfirsh bfirsh closed this as completed Nov 28, 2016
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

No branches or pull requests

3 participants