Skip to content

Commit 0835e46

Browse files
author
Glenn Snyder
committed
adding example showing how to add a subproject to a parent project
1 parent 17c116d commit 0835e46

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

examples/add_subproject.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
3+
import http.client
4+
http.client._MAXHEADERS = 1000
5+
6+
import argparse
7+
import copy
8+
from datetime import datetime
9+
import json
10+
import logging
11+
import sys
12+
import timestring
13+
14+
from blackduck.HubRestApi import HubInstance, object_id
15+
16+
parser = argparse.ArgumentParser("Add a sub-project to a project")
17+
parser.add_argument("parent_project")
18+
parser.add_argument("parent_version")
19+
parser.add_argument("sub_project")
20+
parser.add_argument("sub_version")
21+
args = parser.parse_args()
22+
23+
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', stream=sys.stderr, level=logging.DEBUG)
24+
logging.getLogger("requests").setLevel(logging.WARNING)
25+
logging.getLogger("urllib3").setLevel(logging.WARNING)
26+
27+
hub = HubInstance()
28+
29+
parent_project = hub.get_project_version_by_name(args.parent_project, args.parent_version)
30+
sub_project = hub.get_project_version_by_name(args.sub_project, args.sub_version)
31+
32+
hub.add_version_as_component(parent_project, sub_project)

0 commit comments

Comments
 (0)