lexicon
lexicon copied to clipboard
missing documentation for api usage
Hi, I am trying to use this to manage powerdns as a python package. Is there a doc somewhere on how to configure the endpoints for this with examples ? Thanks
Hi @gilzellner
Unfortunately there's no real documentation regarding how to use lexicon
as a library, however it documented fairly well via the code.
The cli.py
file documents it as follows:
config = ConfigResolver()
config.with_args(parsed_args).with_env().with_config_dir(parsed_args.config_dir)
client = Client(config)
results = client.execute()
Basically the steps are:
- Instantiate a ConfigResolver
- populate the config object. if you're going to execute
lexicon
programmatically, you'll probably wan to use the with_dict() method. - instantiate a
Client
and pass the config - call the
execute()
method on the Client to start the provider logic.
I hope that helps!
Hi,
lexincon_config = {
"provider_name" : "powerdns",
"action": "create",
"domain": "example.com",
"type": "cname",
"pdns_server": "powerdnstestgil-20001-001-test"
}
config = ConfigResolver()
config.with_dict(dict_object=lexincon_config)
client = Client(config)
results = client.execute()
and still getting this error:
/Users/gilzellner/.virtualenvs/lexicon/bin/python /Users/gilzellner/dev-private/af-python-dns-manager/main.py
Traceback (most recent call last):
File "/Users/gilzellner/dev-private/af-python-dns-manager/main.py", line 24, in <module>
client = Client(config)
File "/Users/gilzellner/.virtualenvs/lexicon/lib/python2.7/site-packages/lexicon/client.py", line 67, in __init__
self.provider = provider_class(self.config)
File "/Users/gilzellner/.virtualenvs/lexicon/lib/python2.7/site-packages/lexicon/providers/powerdns.py", line 54, in __init__
if self.api_endpoint.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
according to this line: self.api_endpoint = self._get_provider_option('pdns_server')
the field should be populated. what am i doing wrong ?