summaryrefslogtreecommitdiffstats
path: root/robot/resources/dcae/inventory.robot
diff options
context:
space:
mode:
Diffstat (limited to 'robot/resources/dcae/inventory.robot')
-rw-r--r--robot/resources/dcae/inventory.robot43
1 files changed, 43 insertions, 0 deletions
diff --git a/robot/resources/dcae/inventory.robot b/robot/resources/dcae/inventory.robot
new file mode 100644
index 00000000..647c3780
--- /dev/null
+++ b/robot/resources/dcae/inventory.robot
@@ -0,0 +1,43 @@
+*** Settings ***
+Documentation The main interface for interacting with 5G Bulkpm.
+Library RequestsLibrary
+Library OperatingSystem
+Library String
+Library ONAPLibrary.Templating WITH NAME Templating
+Resource ../global_properties.robot
+
+
+*** Variables ***
+${INVENTORY_SERVER} ${GLOBAL_INVENTORY_SERVER_PROTOCOL}://${GLOBAL_INVENTORY_SERVER_NAME}:${GLOBAL_INVENTORY_SERVER_PORT}
+${INVENTORY_ENDPOINT} /dcae-service-types
+${BLUEPRINT_TEMPLATE} ${EXECDIR}/robot/assets/cmpv2/blueprintTemplate.json
+*** Keywords ***
+
+Load Blueprint To Inventory
+ [Arguments] ${blueprint_path} ${typeName}
+ Disable Warnings
+ ${blueprint}= OperatingSystem.Get File ${blueprint_path}
+ ${templatejson}= Load JSON From File ${BLUEPRINT_TEMPLATE}
+ ${templatejson}= Update Value To Json ${templatejson} blueprintTemplate ${blueprint}
+ ${templatejson}= Update Value To Json ${templatejson} typeName ${typeName}
+ ${data} Convert JSON To String ${templatejson}
+ ${headers}= Create Dictionary content-type=application/json
+ ${session}= Create Session inventory_session ${INVENTORY_SERVER}
+ ${resp}= Post Request inventory_session ${INVENTORY_ENDPOINT} data=${data} headers=${headers}
+ ${serviceTypeId}= Set Variable ${resp.json().get('typeId')}
+ [Return] ${serviceTypeId}
+
+Delete Blueprint From Inventory
+ [Arguments] ${serviceTypeId}
+ Disable Warnings
+ ${session}= Create Session inventory_session ${INVENTORY_SERVER}
+ ${resp}= Delete Request inventory_session ${INVENTORY_ENDPOINT}/${serviceTypeId}
+ [Return] ${resp}
+
+Get Blueprint From Inventory
+ [Arguments] ${typeName}
+ Disable Warnings
+ ${headers}= Create Dictionary content-type=application/json
+ ${session}= Create Session inventory_session ${INVENTORY_SERVER}
+ ${resp}= Get Request inventory_session ${INVENTORY_ENDPOINT}?typeName=${typeName} headers=${headers}
+ [Return] ${resp} \ No newline at end of file