Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ecobytes
lab
PDNS API Snippets
Commits
a7590ebe
Commit
a7590ebe
authored
Jul 25, 2019
by
Johannes Winter
Browse files
initial commit
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
pdns-api.py
0 → 100644
View file @
a7590ebe
#!/usr/bin/env python
## imports
import
json
import
requests
import
os
,
sys
## loaders
from
dotenv
import
load_dotenv
env_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
curdir
,
os
.
path
.
relpath
(
'.env'
)
)
)
load_dotenv
(
verbose
=
True
,
dotenv_path
=
env_path
)
## constants
MODOBOA_API_BASE
=
os
.
getenv
(
"MODOBOA_API_BASE"
)
PDNS_API_BASE
=
os
.
getenv
(
"PDNS_API_BASE"
)
MODOBOA_TOKEN
=
os
.
getenv
(
"MODOBOA_TOKEN"
)
PDNS_TOKEN
=
os
.
getenv
(
"PDNS_TOKEN"
)
def
search_pdns
(
query
):
payload
=
{
'q'
:
query
,
'max'
:
10000
,
'object_type'
:
'all'
}
r
=
requests
.
get
(
PDNS_API_BASE
+
'search-data'
,
headers
=
{
'X-API-Key'
:
PDNS_TOKEN
},
params
=
payload
)
return
r
.
json
()
def
pprint
(
text
):
print
json
.
dumps
(
text
,
sort_keys
=
True
,
indent
=
4
,
separators
=
(
','
,
': '
))
if
len
(
sys
.
argv
)
>
1
:
[
pprint
(
result
)
for
result
in
search_pdns
(
sys
.
argv
[
1
])]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment