summaryrefslogtreecommitdiffstats
path: root/robot/resources/aai/add-relationship-list.robot
blob: 95363fdf40e8e88bf800fd9933ec1c188b483d5f (plain)
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
*** Settings ***
Documentation     Operations on relationship-list sub-object in AAI,
...    using specified base URL path including API version where it is implemented,
...    relies on system to choose default EdgeRule for the pair of object classes

Resource    aai_interface.robot
Library    Collections
Library    ONAPLibrary.Templating    WITH NAME    Templating
Library    ONAPLibrary.AAI    WITH NAME    AAI

*** Variables ***
${AAI_RELATIONSHIPLIST_PATH}      relationship-list
${AAI_RELATIONSHIP_PATH}=      ${AAI_RELATIONSHIPLIST_PATH}/relationship
${AAI_ADD_RELATIONSHIP_BODY}    aai/add-relationship.jinja
${AAI_RELATIONSHIP_DEPTH}=    ?depth=1

*** Keywords ***
Add Relationship
    [Documentation]    Adds Relationship sub-object to existing object in AAI
    [Arguments]    ${api_version_base_object_url}  ${related_class_name}  ${related_object_url}
    ${arguments}=    Create Dictionary     related_class_name=${related_class_name}  related_object_url=${related_object_url}
    Templating.Create Environment    aai    ${GLOBAL_TEMPLATE_FOLDER}
    ${data}=   Templating.Apply Template    aai   ${AAI_ADD_RELATIONSHIP_BODY}    ${arguments}
    ${auth}=  Create List  ${GLOBAL_AAI_USERNAME}    ${GLOBAL_AAI_PASSWORD}
    ${put_resp}=    AAI.Run Put Request     ${AAI_FRONTEND_ENDPOINT}    ${api_version_base_object_url}/${AAI_RELATIONSHIP_PATH}     ${data}    auth=${auth}
    ${status_string}=    Convert To String    ${put_resp.status_code}
    Should Match Regexp    ${status_string}     ^(201|200)$

Get RelationshipList
    [Documentation]   Return RelationshipList of the object in AAI
    [Arguments]    ${api_version_base_object_url}
    ${resp}=  Get Object With Depth  ${api_version_base_object_url}
    Log    Returning response ${resp['${AAI_RELATIONSHIPLIST_PATH}']}
    [Return]  ${resp['${AAI_RELATIONSHIPLIST_PATH}']}

Get Object With Depth
    [Documentation]   Return Object with Depth parameter to show RelationshipList
    [Arguments]    ${api_version_base_object_url}
    ${auth}=  Create List  ${GLOBAL_AAI_USERNAME}    ${GLOBAL_AAI_PASSWORD}
    ${resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${api_version_base_object_url}${AAI_RELATIONSHIP_DEPTH}    auth=${auth}
    Should Be Equal As Strings  ${resp.status_code}     200
    Log    Returning response ${resp.json()}
    [Return]  ${resp.json()}