Giter Site home page Giter Site logo

vinyldns-python's Issues

Date fields throw BadRequest

Ran the following commands:

client = VinylDNSClient("http://localhost:9000", "xxx", "xxx")
existing_txt = [rs for rs in existing_records.record_sets if rs.type == "TXT"][0]
data_to_add = TXTData("some-test-txt-to-add")
existing_txt.records.append(data_to_add)
existing_txt.records
[<vinyldns.record.TXTData object at 0x102e970f0>, <vinyldns.record.TXTData object at 0x102e53e48>]
updated = client.update_record_set(existing_txt)
Traceback (most recent call last):
File "", line 1, in
File "/Users/rstar201/Desktop/Vinyl/python/vinyldns-python/src/vinyldns/client.py", line 519, in update_record_set
to_json_string(record_set), **kwargs)
File "/Users/rstar201/Desktop/Vinyl/python/vinyldns-python/src/vinyldns/client.py", line 157, in __make_request
return self.__check_response(response)
File "/Users/rstar201/Desktop/Vinyl/python/vinyldns-python/src/vinyldns/client.py", line 164, in __check_response
raise BadRequestError(response.text)
vinyldns.client.BadRequestError: {"errors":["Invalid date format 2019-06-25T16:37:09+00:00"]}

the api doesnt use created/update on an update_recordset call anyway, so i just cleared those fields to avoid it, but we should fix to make sure people dont run into this same issue

Add ownerGroupId to BatchRecordChanges create method

In support of the new shared zones feature coming to VinylDNS we need to add the optional ownerGroupId field to the BatchRecordChanges create method. Refer to the VinylDNS documentation for more information.

Example Request:

{
    "comments": "this is optional",
    "ownerGroupId": "f42385e4-5675-38c0-b42f-64105e743bfe"
    "changes": [
        {
            "inputName": "example.com.",
            "changeType": "Add",
            "type": "A",  
            "ttl": 3600, 
            "record": {
                "address": "1.1.1.1"
            } 
        }, 
        {
            "inputName": "192.0.2.195",
            "changeType": "Add",
            "type": "PTR", 
            "ttl": 3600,
            "record": {
                "ptrdname": "ptrdata.data."
            }
        }, 
        {
            "inputName": "cname.example.com.",
            "changeType": "DeleteRecordSet",
            "type": "CNAME"
        }, 
        {
            "inputName": "update.another.example.com.",
            "changeType": "DeleteRecordSet",
            "type": "AAAA"
        }, 
        {
            "inputName": "update.another.example.com.",
            "changeType": "Add",
            "type": "AAAA", 
            "ttl": 4000,
            "record": {
                "address": "1:2:3:4:5:6:7:8"
            }
        }
    ]
}

Additional Information

  • If no ownerGroupId is provided the attribute should not be included in the request.

Fix flake8 style guide failures

We are using the lowercase letter L as a variable name with can be confused with I or 1.

tests/test_membership.py:34:50: E741 ambiguous variable name 'l'
tests/test_membership.py:35:50: E741 ambiguous variable name 'l'
tests/test_membership.py:80:9: E741 ambiguous variable name 'l'
tests/test_membership.py:103:9: E741 ambiguous variable name 'l'
tests/test_membership.py:120:9: E741 ambiguous variable name 'l'
tests/test_membership.py:139:9: E741 ambiguous variable name 'l'
tests/test_membership.py:161:9: E741 ambiguous variable name 'l'
tests/test_batch_change.py:47:13: E741 ambiguous variable name 'l'
tests/test_batch_change.py:66:9: E741 ambiguous variable name 'l'
tests/test_batch_change.py:246:9: E741 ambiguous variable name 'l'
tests/test_records.py:32:50: E741 ambiguous variable name 'l'
tests/test_records.py:113:9: E741 ambiguous variable name 'l'
tests/test_records.py:139:9: E741 ambiguous variable name 'l'
tests/test_records.py:179:9: E741 ambiguous variable name 'l'
tests/test_zones.py:48:46: E741 ambiguous variable name 'l'
tests/test_zones.py:110:9: E741 ambiguous variable name 'l'
tests/test_zones.py:144:9: E741 ambiguous variable name 'l'

Need to release new updates?

Saw that couple of commits were added, especially the global "search_record_sets" in client.py. For some reason, even a new pip install does not reflect that change in packages. Would you be able to help me with this one? Thanks!

get_record_set method returning key error

Looks like a parsing issue.

โ€” Steps to Reproduce
Example:
local_client.get_record_set(zone_id,record_set_id)
get_record_set
line 198, in from_dict
zone_id=d['zoneId'],
KeyError: 'zoneId'

โ€” Possibly reasons
Method: get_record_set
line 525 : Client.py
return RecordSet.from_dict(data) if data is not None else None
needs to be changed to
return RecordSet.from_dict(data['recordSet']) if data is not None else None

Start vinyldns-python client

Background
We have most of the makings of a good vinyldns python client in the functional tests at https://github.com/vinyldns/vinyldns/blob/master/modules/api/functional_test/vinyldns_python.py

With a little cleanup, this can be moved into the vinyldns-python repository and setup as a first class project.

Scope of work

  • Port the vinyldns_python.py library to the vinyldns-python repository
  • Clean up anything that is not-standard for python
  • Add unit tests? Unclear on how to unit test this, since it is just an API wrapper for vinyldns api. There seem to be a lot of unit testing API tools out there, would like whoever starts this up to laydown some opinions on the matter. If not, this looked interesting and it works with pytest which we use for vinyldns - https://github.com/taverntesting/tavern
  • Setup a release process (setup.py) to be able to build and release the project to pypi
  • Add LICENSE and license headers
  • Add a README on usage
  • Setup travis

Add ownerGroupId to RecordSet create method

In support of the new shared zones feature coming to VinylDNS we need to add the optional ownerGroupId field to the RecordSet create method.

Example Request:

{
  "name": "foo",
  "type": "A",
  "ttl": 300,
  "records": [
    {
      "address": "10.10.10.10"
    }
  ],
  "zoneId": "2467dc05-68eb-4498-a9d5-78d24bb0893c",
  "ownerGroupId": "f42385e4-5675-38c0-b42f-64105e743bfe"
}

Additional Information

  • If no ownerGroupId is provided the attribute should not be included in the request.

Sanitize the python client

Background
Presently, the methods on the python client do not properly handle error conditions. The in line docs for the methods also do not indicate how each method could fail. This will make it difficult for anyone to use.

Solution

  • Clean up the return types for all of the methods.
  • Return None on a 404
  • raise an error on other error codes coming back like Forbidden, Conflict, BadRequest
  • Remove unnecessary methods like color and ping and especially post_status
  • Rename create_zone to connect_zone
  • Rename delete_zone to abandon_zone
  • Make functions that are not to be consumed private, for example build_request

Setup travis

This is probably a bit blocked by #9 and maybe #7.

Once we have testing at least, we would want travis to run the tests and pass (or fail) prs accordingly. Failed PRs should not be mergable.

Add travis build badge to Readme

We use Travis CI to build and test the VinylDNS Python client. Adding the Travis badge will quickly indicate that to users and let them know if the master branch is building and passing.

Should be: [![Travis build](https://api.travis-ci.org/vinyldns/vinyldns-python.svg?branch=master)](https://travis-ci.org/vinyldns/vinyldns-python)

see the main VinylDNS Readme for reference

Python 3 support

See title. Need to have a python 3 version of this.

Unsure what amount of code changes are required for this, need to investigate

Build out README

Can definitely leverage https://github.com/vinyldns/vinyldns-ruby for help on this. A few things to include:

  • this will be installed with pip install vinyldns-python
  • example usage:
from vinyldns_python import *
vinyl_client = client.VinylDNSClient("http://localhost:9000", "testUserAccessKey", "testUserSecretKey")
vinyl_client.list_zones()

Add Parameter Type Information to Docstrings

Description

Docstrings are missing type info for parameters, which has led to confusion amongst some users. We should also enhance the docstrings with more detailed information where necessary.

Add testing framework

Needs a little research (or expertise) here. We need some kind of testing framework.
Unclear on how to unit test this, since it is just an API wrapper for vinyldns api. There seem to be a lot of unit testing API tools out there, would like whoever starts this up to laydown some opinions on the matter. If not, this looked interesting and it works with pytest which we use for the vinyldns api - https://github.com/taverntesting/tavern

whatever testing is added here should be tied into travis

AC:

  • We have one function tested (pick any, say getRecordSet)
  • That test is running travis

If the tests arent just copy/paste, we will make followup cards to test the other functions

Add ownerGroupId to RecordSet update method

In support of the new shared zones feature coming to VinylDNS we need to add the optional ownerGroupId field to the RecordSet update method.

Example Request

{
  "id": "dd9c1120-0594-4e61-982e-8ddcbc8b2d21",
  "name": "already-exists",
  "type": "A",
  "ttl": 38400,
  "records": [
    {
      "address": "6.5.4.3"
    }
  ],
  "zoneId": "2467dc05-68eb-4498-a9d5-78d24bb0893c",
  "ownerGroupId": "f42385e4-5675-38c0-b42f-64105e743bfe"
}

Additional Information

  • Get recordSet first then update
  • If ownerGroupId is removed or set to an empty string, the attribute should not be included in the update request.
  • If ownerGroupId is not modified from the retrieved recordSet it should be sent in the update.
  • If ownerGroupId is modified, send the modification

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.