@@ -58,9 +58,6 @@ class StructurizrClient:
5858 agent (str): A string identifying the agent (e.g. 'structurizr-java/1.2.0').
5959 workspace_archive_location (pathlib.Path): A directory for archiving downloaded
6060 workspaces, or None to suppress archiving.
61- ignore_free_plan_locking_errors (bool): When True (the default), attempts to
62- lock a workspace on a free plan licence will succeed even though free plans
63- don't allow locking.
6461 """
6562
6663 def __init__ (self , * , settings : StructurizrClientSettings , ** kwargs ):
@@ -84,7 +81,6 @@ def __init__(self, *, settings: StructurizrClientSettings, **kwargs):
8481 self .agent = settings .agent
8582 self .workspace_archive_location = settings .workspace_archive_location
8683 self .merge_from_remote = True
87- self .ignore_free_plan_locking_errors = True
8884 self ._workspace_url = f"/workspace/{ self .workspace_id } "
8985 self ._lock_url = f"{ self ._workspace_url } /lock"
9086 self ._params = {
@@ -138,11 +134,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
138134 def lock (self ):
139135 """Provide a context manager for locking and unlocking a workspace."""
140136 locked , paid_plan = self ._lock_workspace ()
141- if not locked :
142- if paid_plan or not self .ignore_free_plan_locking_errors :
143- raise StructurizrClientException (
144- f"Failed to lock the Structurizr workspace { self .workspace_id } ."
145- )
137+ if paid_plan and not locked :
138+ raise StructurizrClientException (
139+ f"Failed to lock the Structurizr workspace { self .workspace_id } ."
140+ )
146141 try :
147142 yield self
148143 finally :
@@ -242,25 +237,27 @@ def _lock_workspace(self) -> Tuple[bool, bool]:
242237 response .raise_for_status ()
243238 logger .debug ("%r" , response .json ())
244239 response = APIResponse .parse_raw (response .text )
240+ paid_plan = self ._paid_plan (response )
245241 if not response .success :
246242 logger .warning (
247243 f"Failed to lock workspace { self .workspace_id } . { response .message } "
248244 )
249- return response .success , self ._paid_plan (response )
245+ if not paid_plan :
246+ logger .warning ("Locking not supoprted on free plan. Ignoring." )
247+ return response .success , paid_plan
250248
251249 def lock_workspace (self ) -> bool :
252250 """Lock the Structurizr workspace.
253251
254252 Returns:
255253 bool: `True` if the workspace could be locked, `False` otherwise.
256254
257- Note that free plan Structurizr licences do not support locking. By
258- default this failure will be ignored, however if you do want such locks
259- to fail then set ignore_free_plan_locking_errors to False.
255+ Note that free plan Structurizr licences do not support locking, so this
256+ will fail but continue anyway.
260257 """
261258 success , paid_plan = self ._lock_workspace ()
262- if not success and not paid_plan and self . ignore_free_plan_locking_errors :
263- logger . debug ( "Ignoring lock failure on free plan" )
259+ if not success and not paid_plan :
260+ # Free plans can't lock so ignore.
264261 success = True
265262 return success
266263
@@ -284,8 +281,8 @@ def unlock_workspace(self) -> bool:
284281 logger .warning (
285282 f"Failed to unlock workspace { self .workspace_id } . { response .message } "
286283 )
287- if self . ignore_free_plan_locking_errors and not self ._paid_plan (response ):
288- logger .debug ( "Ignoring unlock failure on free plan" )
284+ if not self ._paid_plan (response ):
285+ logger .warning ( "Unlocking not supported on free plan. Ignoring. " )
289286 success = True
290287 return success
291288
0 commit comments