Skip to content

Commit 89dbc7c

Browse files
author
Kristinn
authored
Adding easier way to get to subaccounts and set subaccounts. (#92)
1 parent 0afcd4b commit 89dbc7c

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

jupyter/laceworkjupyter/helper.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ def __init__(
7676
else:
7777
setattr(self, wrapper, wrapper_object)
7878

79+
@property
80+
def subaccount(self):
81+
"""Returns the subaccount that is in use."""
82+
return self.sdk.subaccount
83+
84+
@subaccount.setter
85+
def subaccount(self, subaccount):
86+
"""Changes the subaccount that is in use."""
87+
if subaccount == self.subaccount:
88+
return
89+
90+
self.sdk.set_subaccount(subaccount)
91+
7992
def __enter__(self):
8093
"""
8194
Support the with statement in python.

laceworksdk/api/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ def __init__(self,
178178
self.vulnerability_exceptions = VulnerabilityExceptionsAPI(self._session)
179179
self.vulnerability_policies = VulnerabilityPoliciesAPI(self._session)
180180

181+
@property
182+
def subaccount(self):
183+
"""
184+
Returns the value of the session's subaccount.
185+
"""
186+
return self._session.subaccount
187+
181188
def set_org_level_access(self, org_level_access):
182189
"""
183190
A method to set whether the client should use organization-level API calls.
@@ -193,4 +200,4 @@ def set_subaccount(self, subaccount):
193200
A method to update the subaccount the client should use for API calls.
194201
"""
195202

196-
self._session._subaccount = subaccount
203+
self._session.subaccount = subaccount

laceworksdk/http_session.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ def _request(self, method, uri, **kwargs):
266266

267267
return response
268268

269+
@property
270+
def subaccount(self):
271+
"""
272+
Returns the current subaccount for the session.
273+
"""
274+
return self._subaccount
275+
276+
@subaccount.setter
277+
def subaccount(self, subaccount):
278+
"""
279+
Modifies the value of the sessions's subaccount.
280+
"""
281+
self._subaccount = subaccount
282+
269283
def get(self, uri, params=None, **kwargs):
270284
"""
271285
A method to build a GET request to interact with Lacework.

0 commit comments

Comments
 (0)