Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
verktoy
kindnavsync
Commits
844bb165
Commit
844bb165
authored
Nov 20, 2019
by
Morten Brekkevold
Browse files
Format all Python code using Black.
parent
64cf304c
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
bin/kindnavsync
View file @
844bb165
This diff is collapsed.
Click to expand it.
kindnavsync/navapi.py
View file @
844bb165
...
...
@@ -8,6 +8,7 @@ from simple_rest_client.exceptions import NotFoundError, ClientError
def
_translate_notfounderror
(
func
):
"""Decorator for standardized handling of NotFoundError"""
@
functools
.
wraps
(
func
)
def
wrapper
(
*
args
,
**
kwargs
):
try
:
...
...
@@ -23,22 +24,22 @@ class NAVAPI(object):
self
.
api
=
API
(
url
,
headers
=
{
'
Authorization
'
:
'
Token {}
'
.
format
(
auth_token
),
'
Content-Type
'
:
'
application/json
'
,
"
Authorization
"
:
"
Token {}
"
.
format
(
auth_token
),
"
Content-Type
"
:
"
application/json
"
,
},
append_slash
=
True
,
json_encode_body
=
True
,
)
self
.
api
.
add_resource
(
resource_name
=
'
netbox
'
)
self
.
api
.
add_resource
(
resource_name
=
'
room
'
)
self
.
api
.
add_resource
(
resource_name
=
"
netbox
"
)
self
.
api
.
add_resource
(
resource_name
=
"
room
"
)
self
.
api
.
add_resource
(
resource_name
=
"version"
)
self
.
api
.
add_resource
(
resource_name
=
"management_profile"
,
resource_class
=
ManagementProfileResource
)
def
list_netboxes
(
self
):
response
=
self
.
api
.
netbox
.
list
(
params
=
{
'
page_size
'
:
1000
})
return
response
.
body
[
'
results
'
]
response
=
self
.
api
.
netbox
.
list
(
params
=
{
"
page_size
"
:
1000
})
return
response
.
body
[
"
results
"
]
@
_translate_notfounderror
def
get_netbox
(
self
,
netbox_id
):
...
...
@@ -93,8 +94,10 @@ class ManagementProfileResource(Resource):
"update"
:
{
"method"
:
"PUT"
,
"url"
:
"management-profile/{}"
},
}
# Exception classes
class
ApiError
(
Exception
):
pass
...
...
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