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

Route53 fully implemented (no more XML blobs in the API) #89

Closed
wants to merge 3 commits into from
Closed

Route53 fully implemented (no more XML blobs in the API) #89

wants to merge 3 commits into from

Conversation

mitchellh
Copy link
Contributor

Hi!

I've implemented a complete set of objects for Route53. The previous API was complete but only allowed for creating and modify records using raw XML blobs, which was a bit rough. I was careful to follow the style of the rest of the codebase and API-style of the rest of the library, but please let me know if I messed up anywhere. Additionally it is all fully documented. :)

Some example usage is shown below (omitting imports for brevity):

conn = Route53Connection()
zone = conn.get_hosted_zone("Z123457681")
for record in zone.records():
    # Outputs name, type, ttl, value, etc.
    print record

# Create a record...
change = ChangeBatch(conn, zone.id)
change.add_change("CREATE", "foo.domain.com.", "CNAME", 60, "google.com.")
change.commit()

I use Route53 heavily and manually creating XML blobs was just not fun for me. I hope this helps!

Please let me know if I got anything wrong, I did my best to maintain previous code style and interfacing. I also documented the new classes.

Best,
Mitchell

@mitchellh
Copy link
Contributor Author

Added a simple test file :)

@ghostrocket
Copy link
Contributor

Thanks for pulling (pun!) this together Mitchell. Pulling it into my local now as I want to start using Route 53.

@mitchellh
Copy link
Contributor Author

Great, if everything looks good and this merge gets in, I have more changes I'd like to make, but since this is my first contribution to this project, I wanted to make sure I did things right before I attempted to add those to a pull request.

Specifically, its still a bit clunky to have to create a ChangeBatch in order to create a record, so some simplified helpers on that would be nice. But it can wait until this gets through.

Thanks :)

@kopertop
Copy link
Member

Before this pull request even appeared, I had already begun implementing this. I'll see what I can do about merging the two versions.

@kopertop
Copy link
Member

After looking at this change, it looks like you've made these changes on an older version of the Route53 module. The latest from trunk appears to have all of this functionality, plus some.

The only exception is the zoneinfo, which we have not implemented since it comes out in JSON. Mitch has, in the past, expressed reluctance to build objects around things like this since they're just simple dictionary objects which are already easy to manipulate.

The only other change is that you use "ChangeBatch" instead of "ResourceRecordSets", where you do:

change = ChangeBatch(conn, zone.id)
change.add_change("CREATE", "foo.domain.com.", "CNAME", 60, "google.com.")
change.commit()

I have

changes = ResourceRecordSets(conn, hosted_zone_id, comment)
change = changes.add_change("CREATE", name, type, ttl)
change.add_value(value)
changes.commit()

Other then naming changes, this pull also ignores that you may have multiple values within a single record. This is highly important in cloud-based environments, so I'm going to close this change since these features are already implemented.

@mitchellh
Copy link
Contributor Author

Kopertop,

I'm sorry, I may be blind, I've been browsing around the "boto/boto" master branch and I simply can't see where this is already implemented. There are a few things I don't see:

  • How do I get the name servers of a hosted zone?
  • When an API request goes in, how do I get the change status, along with updating this?

And what do you mean something comes out in JSON? As far as I know, none of the API endpoints return JSON, and my code definitely does not do any JSON parsing, so where is that?

Additionally, the Route53 API still returns "python data structures," in place of real models. This is unlike the rest (or majority) of the boto API. I don't want to make an API call to get "get_all_hosted_zone" and get some dict out of it, since there are actual operations on a zone I may want to make, and when I do EC2Connection.get_image, I definitely don't get a dict of info of that image.

The only thing that I generally agree with in your response is I ignored the ability to have multiple values for a record, since I didn't see anywhere in the Route 53 documentation to indicate this was even possible. I'm sorry about this.

I'm sorry if what I'm saying here is all wrong, I'd just like some clarification, since I have been using boto master branch in production and the route53 module is definitely not sufficient to be a comfortable API to use.

Thanks,
Mitchell

@mitchellh
Copy link
Contributor Author

Taking a closer look, I can see how you can get the name servers, and how you can get the change status, but it requires a lot of manually parsing a dict data structure, and is something I feel the model should take care of.

So my points I made previously still stand.

@garnaat
Copy link
Member

garnaat commented Feb 1, 2011

So, given the discussion on boto-users, I think this pull request should be re-opened. Or do we need another one? Does your fork work with the latest route53 code in master? I'd like to get this sorted today, if possible.

@garnaat
Copy link
Member

garnaat commented Feb 1, 2011

BTW, vagrant is very cool. Nice job with that mitchellh!

@mitchellh
Copy link
Contributor Author

I'll open another pull request today. There are enough improvements/changes made to the code to make up for Chris's points and your points that I'll just get those in.

Expect a pull request today.

And thanks about Vagrant :)

Mitchell

@garnaat
Copy link
Member

garnaat commented Feb 11, 2011

Where do we stand with this?

@mitchellh
Copy link
Contributor Author

Mitch,

Sorry I've been super busy lately from work. I've just been using my local lib up to this point but I still completely plan on integrating it with boto. I'm still working on the pull request.

Mitchell

@garnaat
Copy link
Member

garnaat commented Feb 11, 2011

Cool. Just wanted to make sure you weren't waiting on me.

This pull request was closed.
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.

None yet

4 participants