blackduck

blackduck

# Overview The hub-rest-api-python provides Python bindings for Hub REST API. # Paging and Black Duck v2022.2 In v2022.2 of Black Duck the REST API introduced a max page size to protect system resource usage. See the Black Duck [release notes on Synopsys Community](https://community.synopsys.com/s/article/Black-Duck-Release-Notes) for the details of which API endpoints are affected. Users of the the python bindings here should leverage the Client interface which provides automatic paging support to make best use of these endpoints. **The old HubInstance interface and many of the examples using it do not perform paging and will break as a result of the changes in v2022.2**. Any issues related to the HubInstance Interface will be closed as *Won't Fix* Any PRs with new or modified example scripts/utilities **must** use the client interface. # New in 1.0.0 Introducing the new Client class. In order to provide a more robust long-term connection, faster performance, and an overall better experience a new Client class has been designed. It is backed by a [Requests session](https://docs.python-requests.org/en/master/user/advanced/#session-objects) object. The user specifies a base URL, timeout, retries, proxies, and TLS verification upon initialization and these attributes are persisted across all requests. At the REST API level, the Client class provides a consistent way to discover and traverse public resources, uses a [generator](https://wiki.python.org/moin/Generators) to fetch all items using pagination, and automatically renews the bearer token. See [Client versus HubInstance Comparison](https://github.com/blackducksoftware/hub-rest-api-python/wiki/Client-versus-HubInstance-Comparison) and also read the [Client User Guide](https://github.com/blackducksoftware/hub-rest-api-python/wiki/Client-User-Guide) on the [Hub REST API Python Wiki](https://github.com/blackducksoftware/hub-rest-api-python/wiki). ### Important Notes The old HubInstance (in HubRestApi.py) keeps its existing functionality for backwards compatibility and therefore does **not** currently leverage any of the new features in the Client class. We believe that the new features are compelling enough to strongly encourage users to consider moving from HubInstance to Client. See [Client versus HubInstance Comparison](https://github.com/blackducksoftware/hub-rest-api-python/wiki/Client-versus-HubInstance-Comparison). Please give it a try and let us know what you think! # To use ``` pip3 install blackduck ``` ```python from blackduck import Client import logging import os logging.basicConfig( level=logging.INFO, format="[%(asctime)s] {%(module)s:%(lineno)d} %(levelname)s - %(message)s" ) bd = Client( token=os.environ.get('blackduck_token'), base_url="https://your.blackduck.url", # verify=False # TLS certificate verification ) for project in bd.get_resource(name='projects'): print(project.get('name')) ``` ### Examples Example code showing how to work with the new Client can be found in the *examples/client* folder. **Examples which use the old HubInstance interface -which is not maintained- are not guaranteed to work. Use at your own risk.** # Version History Including a version history on a go-forward basis. ## v1.1.0 Retries will be attempted for all HTTP verbs, not just GET. # Test # Using [pytest](https://pytest.readthedocs.io/en/latest/contents.html) ```bash git clone https://github.com/blackducksoftware/hub-rest-api-python.git cd hub-rest-api-python # optional but advisable: create/use virtualenv # you should have 3.x+, e.g. Python 3.8.0+ pip3 install -r requirements.txt pip3 install . cd test pytest ``` ## Install package locally Do this when testing a new version. ``` git clone https://github.com/blackducksoftware/hub-rest-api-python.git cd hub-rest-api-python pip3 install -r requirements.txt pip3 install . ``` To uninstall: ``` pip3 uninstall blackduck ``` ## Where can I get the latest release? ## This package is available on PyPi: `pip3 install blackduck` ## Documentation ## Documentation for hub-rest-api-python can be found on the base project: [Hub REST API Python Wiki](https://github.com/blackducksoftware/hub-rest-api-python/wiki)

Release History

Subscribe above to receive notifications when new versions are released.
Version Date Stability
1.1.0 Feb 24, 2023 stable
1.0.7 Jun 13, 2022 stable
1.0.6 Jun 13, 2022 stable
1.0.5 Dec 17, 2021 stable
1.0.4 Jun 14, 2021 stable
1.0.3 May 20, 2021 stable
1.0.2 Apr 26, 2021 stable
1.0.1 Apr 23, 2021 stable
1.0.0 Apr 23, 2021 stable
0.0.56 Dec 9, 2020 stable
0.0.55 Nov 5, 2020 stable
0.0.54 Oct 23, 2020 stable
0.0.53 Oct 22, 2020 stable
0.0.52 Oct 20, 2020 stable
0.0.51 Aug 19, 2020 stable
0.0.50 May 28, 2020 stable
0.0.49 May 26, 2020 stable
0.0.48 May 22, 2020 stable
0.0.47 May 22, 2020 stable
0.0.46 May 19, 2020 stable
0.0.45 Apr 16, 2020 stable
0.0.44 Mar 18, 2020 stable
0.0.43 Feb 19, 2020 stable
0.0.42 Feb 14, 2020 stable
0.0.41 Jan 16, 2020 stable
0.0.40 Dec 10, 2019 stable
0.0.39 Nov 22, 2019 stable
0.0.38 Nov 7, 2019 stable
0.0.37 Oct 30, 2019 stable
0.0.36 Oct 3, 2019 stable
0.0.35 Sep 11, 2019 stable
0.0.34 Sep 9, 2019 stable
0.0.33 Aug 30, 2019 stable
0.0.32 Aug 26, 2019 stable
0.0.31 Aug 26, 2019 stable
0.0.30 Jul 22, 2019 stable
0.0.29 Jun 3, 2019 stable
0.0.28 May 30, 2019 stable
0.0.27 May 24, 2019 stable
0.0.26 May 17, 2019 stable
0.0.25 Apr 26, 2019 stable
0.0.24 Apr 23, 2019 stable
0.0.23 Mar 14, 2019 stable
0.0.22 Mar 14, 2019 stable
0.0.21 Mar 5, 2019 stable
0.0.20 Mar 4, 2019 stable
0.0.19 Mar 1, 2019 stable
0.0.18 Mar 1, 2019 stable
0.0.17 Feb 27, 2019 stable
0.0.16 Feb 26, 2019 stable
0.0.15 Feb 25, 2019 stable
0.0.14 Feb 25, 2019 stable
0.0.12 Feb 7, 2019 stable
0.0.11 Feb 6, 2019 stable
0.0.10 Jan 25, 2019 stable
0.0.9 Jan 14, 2019 stable
0.0.8 Jan 9, 2019 stable
0.0.7 Jan 8, 2019 stable
0.0.6 Dec 16, 2018 stable
0.0.5 Dec 6, 2018 stable
0.0.4 Nov 20, 2018 stable
0.0.3 Nov 15, 2018 stable
0.0.2 Nov 8, 2018 stable