Skip to content

Commit

Permalink
Add HeadConfig API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barkin Simsek committed Apr 9, 2024
1 parent 0301000 commit 646b58f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.7.9 (2024-04-10)

### Changes

- Add `HeadConfig` API.


## 0.7.8 (2024-03-19)

### Changes
Expand Down
2 changes: 1 addition & 1 deletion python/mujinwebstackclient/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.7.8'
__version__ = '0.7.9'

# Do not forget to update CHANGELOG.md

15 changes: 15 additions & 0 deletions python/mujinwebstackclient/webstackclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,21 @@ def GetConfig(self, filename=None, timeout=5):
raise WebstackClientError(_('Failed to retrieve configuration from controller, status code is %d') % response.status_code, response=response)
return response.json()

def HeadConfig(self, filename, timeout=5):
"""Perform a HEAD operation on the given configuration filename to retrieve metadata.
:return: A dict containing "modified (datetime.datetime)" and "size (int)"
"""
path = '/config/'
if filename:
path = '/config/%s/' % filename
response = self._webclient.Request('HEAD', path, timeout=timeout)
if response.status_code != 200:
raise WebstackClientError(_('Failed to check configuration existence, status code is %d') % response.status_code, response=response)
return {
'modified': datetime.datetime(*parsedate(response.headers['Last-Modified'])[:6]),
}

def SetConfig(self, data, filename=None, timeout=5):
"""Set configuration file content to controller.
Expand Down

0 comments on commit 646b58f

Please sign in to comment.