Skip to content

Commit

Permalink
create put method to ApiInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
laurapanzariello committed May 29, 2018
1 parent eaf84b9 commit 0aa98b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
15 changes: 9 additions & 6 deletions networkapiclient/ApiGenericClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def get(self, uri):
@raise NetworkAPIClientError: Client failed to access the API.
"""
request = None

try:

request = requests.get(
Expand All @@ -79,12 +81,13 @@ def get(self, uri):
raise NetworkAPIClientError(error.get('detail', ''))
finally:
self.logger.info('URI: %s', uri)
self.logger.info('Status Code: %s',
request.status_code if request else '')
self.logger.info('X-Request-Id: %s',
request.headers.get('x-request-id'))
self.logger.info('X-Request-Context: %s',
request.headers.get('x-request-context'))
if request:
self.logger.info('Status Code: %s',
request.status_code if request else '')
self.logger.info('X-Request-Id: %s',
request.headers.get('x-request-id'))
self.logger.info('X-Request-Context: %s',
request.headers.get('x-request-context'))

def post(self, uri, data=None, files=None):
"""
Expand Down
13 changes: 12 additions & 1 deletion networkapiclient/ApiInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_interface_type(self, ids=None, **kwargs):
"""
Method to get interfaces by their ids.
:param ids: List containing identifiers of interfaces.
:return: Dict containing interfaces.git
:return: Dict containing interfaces.git
"""

url = 'api/v3/interfacetype/'
Expand All @@ -111,3 +111,14 @@ def get_interface_type(self, ids=None, **kwargs):
url = build_uri_with_ids(url, ids)

return super(ApiInterfaceRequest, self).get(self.prepare_url(url, kwargs))

def update(self, interfaces=None):
"""
Method to update interface.
:param ids: List containing interface's desired to be updated on database.
:return: None.
"""

data = {'interfaces': interfaces}

return super(ApiInterfaceRequest, self).put('api/v3/interface/', data)

0 comments on commit 0aa98b4

Please sign in to comment.