1 from string import Template
3 # helps in taking the hostname entered by the user
8 __author__ = "Basheeruddin Ahmed"
9 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
10 __license__ = "New-style BSD"
11 __email__ = "syedbahm@cisco.com"
15 return hostname + ":" + port # noqa
19 """Cars resource URL for GET"""
20 return "http://" + getServer() + "/restconf/config/car:cars"
24 """People resouce URL for GET"""
25 return "http://" + getServer() + "/restconf/config/people:people"
28 def getCarPersonUrl():
29 """GET cars persons mapping resource URL"""
30 return "http://" + getServer() + "/restconf/config/car-people:car-people"
34 """POST or DELETE URL"""
35 return "http://" + getServer() + "/restconf/config"
38 def getAddPersonUrl():
39 """POST or DELETE URL"""
40 return "http://" + getServer() + "/restconf/config"
43 def getAddPersonRpcUrl():
44 """POST URL -using rpc"""
45 return "http://" + getServer() + "/restconf/operations/people:add-person"
48 def getAddCarPersonUrl():
49 """POST URL for car person mapping"""
50 return "http://" + getServer() + "/restconf/config"
53 def getBuyCarRpcUrl():
54 """POST URL for buy car rpc"""
55 return "http://" + getServer() + "/restconf/operations/car-purchase:buy-car"
58 # Template for Car resource payload
59 add_car_payload_template = Template(
65 "category": "$category",
67 "manufacturer": "$manufacturer",
74 # Template for Person resource payload
75 add_person_payload_template = Template(
83 "address": "$address",
84 "contactNo":"$contactNo"
90 # Template for Car Person mapping payload
91 add_car_person_template = Template(
93 {"car-people:car-people":{
97 "person-id": "$personId"
103 # Template for adding person using RPC
104 add_person_rpc_payload_template = Template(
109 "people:id" : "$personId",
110 "people:gender":"$gender",
111 "people:address" : "$address",
112 "people:contactNo":"$contactNo",
118 # Template for buying car rpc
119 buy_car_rpc_template = Template(
124 "car-purchase:person" : "/people:people/people:person[people:id='$personId']",
125 "car-purchase:person-id" : "$personId",
126 "car-purchase:car-id" : "$carId"