blob: 1e342873356cc338c131365785669b8d6199ef0d [file] [log] [blame]
krzysztof kuzmickidadd0e62019-07-31 20:08:36 +02001*** Settings ***
2Documentation Creates a macro service recipe in SO Catalog DB
3
4Library OperatingSystem
5Library Collections
6Library ONAPLibrary.SO WITH NAME SO
7Library ONAPLibrary.Templating WITH NAME Templating
DR695H87b84d02019-08-02 17:18:13 -04008Resource ../global_properties.robot
krzysztof kuzmickidadd0e62019-07-31 20:08:36 +02009
10*** Variables ***
11${SERVICE_RECIPE_PATH} /serviceRecipe
12
13${SYSTEM USER} robot-ete
14${SO_ADD_SERVICE_RECIPE} so/service_recipe.jinja
15
16
17
18*** Keywords ***
19Add Service Recipe
20 [Documentation] Creates a macro service recipe in SO Catalog DB
21 [Arguments] ${service_model_UUID} ${orchestrationUri}
22 ${id}= Get First Free Service Recipe Id
23 ${arguments}= Create Dictionary service_model_UUID=${service_model_UUID} orchestrationUri=${orchestrationUri} id=${id}
24 Templating.Create Environment so ${GLOBAL_TEMPLATE_FOLDER}
25 ${data}= Templating.Apply Template so ${SO_ADD_SERVICE_RECIPE} ${arguments}
26 ${auth}= Create List ${GLOBAL_SO_CATDB_USERNAME} ${GLOBAL_SO_PASSWORD}
27 ${get_resp}= SO.Run Post Request ${GLOBAL_SO_CATDB_ENDPOINT} ${SERVICE_RECIPE_PATH} ${data} auth=${auth}
28 Should Be Equal As Strings ${get_resp.status_code} 201
Krzysztof Kuzmicki044f47d2020-01-23 14:37:30 +010029 [Return] ${id}
krzysztof kuzmickidadd0e62019-07-31 20:08:36 +020030
31Get Service Recipe
32 [Documentation] Gets service recipe/s in SO
33 [Arguments] ${service_id}=
34 ${auth}= Create List ${GLOBAL_SO_CATDB_USERNAME} ${GLOBAL_SO_PASSWORD}
35 ${get_resp}= SO.Run Get Request ${GLOBAL_SO_CATDB_ENDPOINT} ${SERVICE_RECIPE_PATH}/${service_id} auth=${auth}
36 Should Be Equal As Strings ${get_resp.status_code} 200
37 [Return] ${get_resp}
38
39Get First Free Service Recipe Id
40 [Documentation] Gets first free service recipe id in SO
41 ${get_resp}= Get Service Recipe
42 ${source data}= Set Variable ${get_resp.json()}
43 Log ${source data}
44 ${serviceRecipes}= Set Variable ${source data['_embedded']['serviceRecipe']}
45 ${ids}= Create List
46 :FOR ${recipe} IN @{serviceRecipes}
47 \ ${id}= Get From Dictionary ${recipe} id
48 \ Append To List ${ids} ${id}
49 Sort list ${ids}
50 ${biggest_id}= Get From List ${ids} -1
51 Log Biggest id is ${biggest_id} first free is ${biggest_id+1}
52 [Return] ${biggest_id+1}
Krzysztof Kuzmicki044f47d2020-01-23 14:37:30 +010053
54Delete Service Recipe
55 [Documentation] Deletes service recipe/s in SO
56 [Arguments] ${service_id}
57 ${auth}= Create List ${GLOBAL_SO_CATDB_USERNAME} ${GLOBAL_SO_PASSWORD}
58 ${get_resp}= SO.Run Delete Request ${GLOBAL_SO_CATDB_ENDPOINT} ${SERVICE_RECIPE_PATH}/${service_id} auth=${auth}
Krzysztof Kuzmicki82263f02020-01-23 15:05:27 +010059 Should Be Equal As Strings ${get_resp.status_code} 204