lexicon icon indicating copy to clipboard operation
lexicon copied to clipboard

missing documentation for api usage

Open gilzellner opened this issue 5 years ago • 2 comments

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

gilzellner avatar Oct 27 '19 10:10 gilzellner

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:

  1. Instantiate a ConfigResolver
  2. populate the config object. if you're going to execute lexicon programmatically, you'll probably wan to use the with_dict() method.
  3. instantiate a Client and pass the config
  4. call the execute() method on the Client to start the provider logic.

I hope that helps!

AnalogJ avatar Oct 29 '19 03:10 AnalogJ

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 ?

gilzellner avatar Oct 29 '19 09:10 gilzellner