|
| 1 | +# bsc_finder.py |
| 2 | + |
| 3 | +## Table of Contents |
| 4 | + |
| 5 | +- [Overview](#overview) |
| 6 | +- [Features](#features) |
| 7 | +- [Requirements](#requirements) |
| 8 | +- [Installation](#installation) |
| 9 | +- [Usage](#usage) |
| 10 | +- [Output](#output) |
| 11 | +- [Logging](#logging) |
| 12 | +- [Error Handling](#error-handling) |
| 13 | +- [Dependencies](#dependencies) |
| 14 | +- [License](#license) |
| 15 | +- [Notes](#notes) |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Overview |
| 20 | + |
| 21 | +This Python script automates the process of gathering, processing and storing bug reports |
| 22 | +consuming Bugzilla REST API. |
| 23 | +It requires a valid API key to function. |
| 24 | + |
| 25 | +The script allows users to filter bug reports for SUMA 4.3 and 5.0 products. |
| 26 | + |
| 27 | +## Features |
| 28 | + |
| 29 | +- Fetches and stores bug reports from Bugzilla REST API through a CLI |
| 30 | + |
| 31 | +## Requirements |
| 32 | + |
| 33 | +- A valid Bugzilla API key |
| 34 | +- Python 3.6 or higher |
| 35 | +- `requests` library |
| 36 | +- `bugzilla_client` library: Ensure you have the `bugzilla_client` module available in |
| 37 | + your environment. |
| 38 | + |
| 39 | +## Installation |
| 40 | + |
| 41 | +To install the required dependencies, ensure you have `requests` installed: |
| 42 | + |
| 43 | +```bash |
| 44 | +pip install requests |
| 45 | +``` |
| 46 | + |
| 47 | +## Usage |
| 48 | + |
| 49 | +Command-Line Arguments |
| 50 | + |
| 51 | +The script accepts several command-line arguments to control its behavior. |
| 52 | + |
| 53 | +```bash |
| 54 | +python bsc_finder.py [options] |
| 55 | +``` |
| 56 | + |
| 57 | +Options: |
| 58 | + |
| 59 | +1) Required Argument: |
| 60 | + - API Key (-k or --api-key): |
| 61 | + Description: Bugzilla API key (required). |
| 62 | + Usage: -k YOUR_API_KEY or --api-key YOUR_API_KEY |
| 63 | + |
| 64 | +2) Filter Options: |
| 65 | + - All Products (-a or --all): |
| 66 | + Description: Returns results for all supported products, overriding version and cloud flags. |
| 67 | + Usage: -a or --all (flag) |
| 68 | + - Product Version (-p or --product-version): |
| 69 | + Description: Specify the product version of SUMA to run the script for. Options: 4.3 or 5.0. Default is 4.3. |
| 70 | + Usage: -p 5.0 or --product-version 5.0 |
| 71 | + - Cloud (-c or --cloud): |
| 72 | + Description: Returns BSCs for SUMA in Public Clouds. |
| 73 | + Usage: -c or --cloud (flag) |
| 74 | + - Status (-s or --status): |
| 75 | + Description: Filters BSCs by status. Options: NEW, CONFIRMED, IN_PROGRESS, RESOLVED. |
| 76 | + Usage: -s NEW or --status NEW |
| 77 | + - Resolution (-r or --resolution): |
| 78 | + Description: Filters issues by resolution. Leave empty for open bugs. |
| 79 | + Usage: -r FIXED or --resolution FIXED |
| 80 | + |
| 81 | +3) Output Options: |
| 82 | + - Output File (-o or --output): |
| 83 | + Description: Specifies the file in which the results will be saved. |
| 84 | + Usage: -o results.txt or --output results.txt |
| 85 | + - Output Format (-f or --format): |
| 86 | + Description: Format for the output file. Options: json, txt. Default is txt. |
| 87 | + Usage: -f json or --format json |
| 88 | + |
| 89 | +Example: |
| 90 | + |
| 91 | +```bash |
| 92 | +python bsc_finder.py -k YOUR_API_KEY -p 5.0 -s NEW -c -o results.txt -f txt |
| 93 | +``` |
| 94 | + |
| 95 | +This command will: |
| 96 | + |
| 97 | +1) Instantiate a new Bugzilla RESt API client with your API key |
| 98 | +2) Query the API for all the bug reports related to 'SUSE Manager 5.0 in Public Clouds', in status NEW |
| 99 | +3) Save the results to a file called 'results.txt', as a .md formatted list of link-summary elements |
| 100 | + |
| 101 | +## Output |
| 102 | + |
| 103 | +The produced output can be one of: |
| 104 | +1) a JSON file, containing all the bug reports info |
| 105 | +2) a txt file formatted in .md syntax, containing links and a summary for each report. |
| 106 | + |
| 107 | +## Logging |
| 108 | + |
| 109 | +The script includes basic logging for informational messages. To enable logging, |
| 110 | +ensure the setup_logging function is called at the beginning of the script. Log |
| 111 | +messages will display timestamped INFO-level messages. |
| 112 | + |
| 113 | +## Error Handling |
| 114 | + |
| 115 | +- If no, or an invalid, API key is provided via CLI the script will print an error |
| 116 | +message and halt execution. |
| 117 | +- Invalid flags values in appropriate error messages. |
| 118 | + |
| 119 | +## Dependencies |
| 120 | + |
| 121 | +`requests`: A popular Python library for making HTTP requests. It is used here to |
| 122 | +handle communication with the SMASH API. |
| 123 | + |
| 124 | +## License |
| 125 | + |
| 126 | +This script is licensed under the [MIT License](https://opensource.org/licenses/MIT). |
| 127 | + |
| 128 | +## Notes |
| 129 | + |
| 130 | +Ensure that the requests library is installed in your environment. |
| 131 | +This script relies on the Bugzilla REST API being available and responsive and having a valid API key for it. |
| 132 | + |
| 133 | +Handle possible exceptions appropriately in production environments. |
| 134 | +Caching helps in reducing the load on the API and speeds up access to the |
| 135 | +embargoed IDs, but make sure to handle cache invalidation if the data can change |
| 136 | +frequently. |
0 commit comments