1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/usr/bin/python
import httplib, urllib
import sys
if len(sys.argv) < 1:
print("please supply a message")
sys.exit(1)
params = urllib.urlencode({'login':'candlepin', 'password':'cp_p@s$w0rd'})
headers = {"Content-type":"application/json",
"Accept": "application/json"}
conn = httplib.HTTPConnection("localhost", 8080)
conn.request("POST", '/candlepin/user', params, headers)
response = conn.getresponse()
print("Status: %d Response: %s" % (response.status, response.reason))
rsp = response.read()
conn.close()
print("create: %s" % rsp)
"""
response = urllib.urlopen('http://localhost:8080/candlepin/user/candlepin')
rsp = response.read()
print("get: %s" % rsp)
response = urllib.urlopen('http://localhost:8080/candlepin/user/list')
rsp = response.read()
print("list: %s" % rsp)
response = urllib.urlopen('http://localhost:8080/candlepin/user/listusers')
rsp = response.read()
print("listusers: %s" % rsp)
response = urllib.urlopen('http://localhost:8080/candlepin/user/uselist')
rsp = response.read()
print("uselist: %s" % rsp)
response = urllib.urlopen('http://localhost:8080/candlepin/user/listobjects')
rsp = response.read()
print("listobjects: %s" % rsp)
response = urllib.urlopen('http://localhost:8080/candlepin/user/listbasemodel')
rsp = response.read()
print("listbasemodel: %s" % rsp)
print("TESTING json get")
response = urllib.urlopen("http://localhost:8080/candlepin/user/testobject")
rsp = response.read()
print("testjsonobject get: %s" % rsp)
"""
print("TESTING json create")
params = urllib.urlencode({"name":"rhim","uuid":"joprsucks"})
headers = {"Content-type":"application/json",
"Accept": "application/json"}
conn = httplib.HTTPConnection("localhost", 8080)
conn.request("POST", '/candlepin/user/createtestobject', params, headers)
response = conn.getresponse()
print("Status: %d Response: %s" % (response.status, response.reason))
rsp = response.read()
conn.close()
|