from .cfg_app import PpCfgAppError, PpConfigApplication
-__version__ = '0.1.0'
+__version__ = '0.1.1'
LOG = logging.getLogger(__name__)
+_LIBRARY_NAME = "pp-pdns-api-client"
# =============================================================================
self._api_host = self.api_hosts['global']
self._api_port = self.default_api_port
self._api_servername = self.default_api_servername
- self._user_agent = '{}/{}'.format(_LIBRARY_NAME, __version__)
+ self._user_agent = '{}/{}'.format(_LIBRARY_NAME,self.version)
self._environment = 'global'
+ stems = []
+ if cfg_stems:
+ if isinstance(cfg_stems, list):
+ for stem in cfg_stems:
+ s = str(stem).strip()
+ if not s:
+ msg = "Invalid configuration stem {!r} given.".format(stem)
+ raise PpLdapAppError(msg)
+ stems.append(s)
+ else:
+ s = str(cfg_stems).strip()
+ if not s:
+ msg = "Invalid configuration stem {!r} given.".format(cfg_stems)
+ raise PpLdapAppError(msg)
+ stems.append(s)
+ else:
+ stems = [self.appname]
+ if 'pdns-api' not in stems:
+ stems.insert(0, 'pdns-api')
+
super(PpPDNSApplication, self).__init__(
appname=appname, verbose=verbose, version=version, base_dir=base_dir,
initialized=False, usage=usage, description=description,
return self._api_servername
@api_servername.setter
- def api_servername(self.value):
+ def api_servername(self, value):
if value is None or str(value).strip() == '':
raise PpPDNSAppError("Invalid API server name {!r} given.".format(value))
self._api_servername = str(value).strip()
return self._user_agent
@user_agent.setter
- def user_agent(self.value):
+ def user_agent(self, value):
if value is None or str(value).strip() == '':
raise PpPDNSAppError("Invalid user agent {!r} given.".format(value))
self._user_agent = str(value).strip()
pdns_group = self.arg_parser.add_argument_group('PowerDNS API options')
env_group = pdns_group.add_mutually_exclusive_group()
+ envs = []
+ for env in self.api_keys.keys():
+ envs.append(str(env))
+ envs.sort()
+
env_group.add_argument(
'-E', '--env', '--environment',
- metavar="ENVIRONMENT", choices=self.api_keys.keys().sort(), dest="env",
+ metavar="ENVIRONMENT", choices=envs, dest="env",
help=(
"Select, which PowerDNS environment to use. "
"Valid values: {v}, default: {d!r}.".format(
- v=', '.join(map(lambda x: repr(x), self.api_keys.keys().sort())),
+ v=', '.join(map(lambda x: repr(x), envs)),
d='global'))
)