Skip to content

Commit 2a07013

Browse files
committed
adding extractRuleComponents and documentation
1 parent 80b370f commit 2a07013

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

docs/releases.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ This has been started after the 0.3.0 release.\
77
* adding a `getBuilds` method on the `Library` class instance
88
* extend support for pagination on `getEnvironments`
99
* adding `getProductionEndpoint` and `getStagingEndpoint` to retrieve the URL to use on websites
10-
* support the instantiation of the `Library` class via a single libraryId string.
10+
* support the instantiation of the `Library` class via a single libraryId string.\
11+
Patch:
12+
* adding a name parameter for the `checkExtensionUpdate` method
13+
* adding the `extractRuleComponents` method in property.
14+
1115

1216
## 0.4.3
1317
* Refactor `Translator` class for removing `pandas` dependency\

launchpy/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.4"
1+
__version__ = "0.4.4-1"

launchpy/property.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,27 @@ def searchRules(self, name: str = None,name_contains:str=None, enabled: bool = N
310310
'url': rule['links']['rule_components']
311311
}
312312
return data
313+
314+
def extractRuleComponents(self,rule:dict=None)->list:
315+
"""
316+
Extract the rule component based on the rule definition.
317+
Arguments:
318+
rule : REQUIRED : The rule definition
319+
"""
320+
if rule is None:
321+
raise ValueError("No rule definition provided")
322+
params={'page[number]':0}
323+
rc_endpoint = rule['relationships']['rule_components']['links']['related']
324+
page1 = self.getRessource(rc_endpoint)
325+
data = page1.get('data',{})
326+
next_page = page1.get('meta',{}).get('pagination',{}).get('next_page',None)
327+
while next_page is not None:
328+
params['page[number]'] = next_page
329+
pageN = self.connector.getData(rc_endpoint,params=params)
330+
data += pageN.get('data',[])
331+
next_page = pageN.get('meta',{}).get('pagination',{}).get('next_page',None)
332+
return data
333+
313334

314335
def getRuleComponents(self, verbose:bool=False,**kwargs)->dict:
315336
"""

0 commit comments

Comments
 (0)