|
2 | 2 | Created on Jan 27, 2023
|
3 | 3 | @author: dnichol
|
4 | 4 | Bulk update user group names from CSV. CSV file requires two columns, titled 'Existing' and 'New'. This script is case sensitive.
|
| 5 | +
|
| 6 | +This script requires a .restconfig.json file present to configure the connection details. For more details see : https://community.synopsys.com/s/article/How-to-use-the-hub-rest-api-python-for-Black-Duck |
| 7 | +
|
| 8 | +The .restconfig.json file should be in the following format: |
| 9 | +
|
| 10 | +{ |
| 11 | + "baseurl": "https://your-hub-dns", |
| 12 | + "api_token": "insert-token-here", |
| 13 | + "insecure": true, |
| 14 | + "debug": false |
| 15 | +} |
| 16 | +
|
| 17 | +Copyright (C) 2023 Synopsys, Inc. |
| 18 | +http://www.synopsys.com/ |
| 19 | +
|
| 20 | +Licensed to the Apache Software Foundation (ASF) under one |
| 21 | +or more contributor license agreements. See the NOTICE file |
| 22 | +distributed with this work for additional information |
| 23 | +regarding copyright ownership. The ASF licenses this file |
| 24 | +to you under the Apache License, Version 2.0 (the |
| 25 | +"License"); you may not use this file except in compliance |
| 26 | +with the License. You may obtain a copy of the License at |
| 27 | +
|
| 28 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 29 | +
|
| 30 | +Unless required by applicable law or agreed to in writing, |
| 31 | +software distributed under the License is distributed on an |
| 32 | +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 33 | +KIND, either express or implied. See the License for the |
| 34 | +specific language governing permissions and limitations |
| 35 | +under the License. |
5 | 36 | '''
|
6 | 37 |
|
7 | 38 | import csv
|
|
15 | 46 | from blackduck import Client
|
16 | 47 |
|
17 | 48 | def log_config():
|
18 |
| - # TODO: debug option in .restconfig file to be reflected |
19 | 49 | logging.basicConfig(format='%(asctime)s:%(levelname)s:%(module)s: %(message)s', stream=sys.stderr, level=logging.DEBUG)
|
20 | 50 | logging.getLogger("requests").setLevel(logging.WARNING)
|
21 | 51 | logging.getLogger("urllib3").setLevel(logging.WARNING)
|
@@ -73,7 +103,7 @@ def update_user_group(hub_client, existing_name, new_name, user_group):
|
73 | 103 | # Update the name.
|
74 | 104 | user_group['name'] = new_name
|
75 | 105 |
|
76 |
| - logging.info(f"Updating user group {existing_name} to {user_group['name']} for user group {user_group_url}s") |
| 106 | + logging.info(f"Updating user group {existing_name} to {user_group['name']} for user group {user_group_url}") |
77 | 107 | hub_client.session.put(user_group_url, json=user_group)
|
78 | 108 |
|
79 | 109 |
|
|
0 commit comments