Skip to content

Commit 86a8f11

Browse files
stsnelalanking
authored andcommitted
[#550] Add support for client hints
1 parent 04baaa8 commit 86a8f11

4 files changed

Lines changed: 52 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,16 @@ If you want to create a user in a federated zone, use:
16061606
>>> session.users.create('user', 'rodsuser', 'OtherZone', auth_str)
16071607
```
16081608

1609+
Showing client hints
1610+
--------------
1611+
1612+
You can get a list of available microservices, rules, etc. using the `client_hints`
1613+
attribute of the session.
1614+
1615+
```python
1616+
>>> session.client_hints
1617+
```
1618+
16091619
And more ...
16101620
------------
16111621

irods/api_number.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
# 1100 - 1200 - SSL API calls
177177
"SSL_START_AN": 1100,
178178
"SSL_END_AN": 1101,
179+
"CLIENT_HINTS_AN": 10215,
179180
"GET_RESOURCE_INFO_FOR_OPERATION_AN": 10220,
180181
"ATOMIC_APPLY_METADATA_OPERATIONS_APN": 20002,
181182
"GET_FILE_DESCRIPTOR_INFO_APN": 20000,

irods/session.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
from irods.query import Query
1212
from irods.pool import Pool
1313
from irods.account import iRODSAccount
14+
from irods.api_number import api_number
1415
from irods.manager.collection_manager import CollectionManager
1516
from irods.manager.data_object_manager import DataObjectManager
1617
from irods.manager.metadata_manager import MetadataManager
1718
from irods.manager.access_manager import AccessManager
1819
from irods.manager.user_manager import UserManager, GroupManager
1920
from irods.manager.resource_manager import ResourceManager
2021
from irods.manager.zone_manager import ZoneManager
22+
from irods.message import iRODSMessage
2123
from irods.exception import NetworkException
2224
from irods.password_obfuscation import decode
2325
from irods import NATIVE_AUTH_SCHEME, PAM_AUTH_SCHEMES
@@ -301,6 +303,14 @@ def __server_version(self):
301303
conn.release()
302304
return version
303305

306+
@property
307+
def client_hints(self):
308+
message = iRODSMessage('RODS_API_REQ', int_info=api_number['CLIENT_HINTS_AN'])
309+
with self.pool.get_connection() as conn:
310+
conn.send(message)
311+
response = conn.recv()
312+
return response.get_json_encoded_struct()
313+
304314
@property
305315
def pam_pw_negotiated(self):
306316
self.pool.account.store_pw = []

irods/test/client_hints_test.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
from __future__ import absolute_import
3+
import os
4+
import sys
5+
import unittest
6+
7+
import irods.test.helpers as helpers
8+
9+
class TestClientHints(unittest.TestCase):
10+
11+
def setUp(self):
12+
self.sess = helpers.make_session()
13+
14+
def tearDown(self):
15+
"""Close connections."""
16+
self.sess.cleanup()
17+
18+
def test_client_hints(self):
19+
client_hints = self.sess.client_hints
20+
21+
self.assertIn("specific_queries", client_hints)
22+
self.assertIn("rules", client_hints)
23+
self.assertIn("plugins", client_hints)
24+
self.assertIn("hash_scheme", client_hints)
25+
self.assertIn("match_hash_policy", client_hints)
26+
27+
28+
if __name__ == '__main__':
29+
# let the tests find the parent irods lib
30+
sys.path.insert(0, os.path.abspath('../..'))
31+
unittest.main()

0 commit comments

Comments
 (0)