blackducksoftware / hub-rest-api-python

HUB REST API Python bindings
Apache License 2.0
89 stars 104 forks source link

Filter Project Names #241

Closed RamkumarNagarajanMuthiah closed 1 year ago

RamkumarNagarajanMuthiah commented 1 year ago

I could able to set the limit to pull the project names like below,

hub = HubInstance() projects = hub.get_projects(limit=999)

Is there any way to filter the project names starting with particular string?

projects = hub.get_projects(limit=999, project_name="App1*") ?

OffBy0x01 commented 1 year ago

Using client you could do something like this (untested):

import re
from blackduck import Client

bd = Client(base_url='your.blackduck.instance', token='your token' ) 
pattern='^App*' 
matching_projects = [project if re.match(pattern, project['name']) for project in bd.get_resource('projects')]