Layer7 API Management

  • 1.  Unable to use RESTMAN to move service into another folder

    Posted Nov 23, 2016 11:14 AM

    It would seem you can't use RESTMAN call in order to move a service into a different folder.

    We tried to dump service, modify "folderId" and then update service, without success.

    Error returned by RESTMAN:

       Resource validation failed due to 'INVALID_VALUES' Unable to update service: Folder update not permitted.

     

    Is there another a way to move a service into another folder or did we missed something ?

    Digging a little bit at the MySQL statement level shows we could do it using Mysql the following way:

       

       policyId=select policy_goid from published_service where goid=to_binary('$serviceId')
       update published_service set folder_goid=to_binary('$folderId') where goid=to_binary('$serviceId')
       update policy set folder_goid=to_binary('$folderId') WHERE policy_goid='$policyId'

     

    Is this something that could be supported ?



  • 2.  Re: Unable to use RESTMAN to move service into another folder

    Broadcom Employee
    Posted Nov 23, 2016 07:25 PM

    Philippe,

     

    Good afternoon. We do not support direct database modifications to do what you are looking for as the gateway will not pick it up properly and may cause other unknown problems. Please provide what you attempted to do in terms of restman commands and payloads.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 3.  Re: Unable to use RESTMAN to move service into another folder

    Posted Nov 24, 2016 04:06 AM

    RESTMAN calls are handled by our own framework we've developed internally in order to cope with our 45+ gateways deployment.

    What we want to achieve:

    • When publishing an API from Portal, service ends up at Root Node on the API Gateway, and due to our role-based model on the APi Gateway, developers can't see what's on the root node (would mean 15 organizations can see other's work). So we need upon landing that service would be moved to a specific folder, one per organization.

     

    As it seems not possible (except perhaps modifying API portal integration policy) to do it the automatic way, we were thinking about a scheduled job.

    This job is launched from our central administration server, on which our framework is installed (shell based)

     

    Basically the "service_move_folder" function is only modifying a single field being the folder ID:

    • getting service id using GET 1.0/services?name=foobar
    • dumping current "foobar" published service using GET 1.0/services/{id} (to restrict dump with only one Item)
    • extract Service from List using xml_grep --nowrap 'l7:Service'  --pretty_print >xml_file
    • modifying folderId inside the xml_file sed -i "s/folderId=\".*\"/folderId=\"${folderId}\"/" ${xml_file}
    • RESTMAN call using callPUTService "/services/${serviceId}?active=true" "@${xml_file}"
    • callPUTService being a wrapper around curl, sending: curl -X PUT -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u '*********' --cacert /etc/pki/tls/private/CA_chain.pem 'https://the_gateway_ip:7443/restman/1.0/services/2dbdf800194243fafdefc4e94f1e0e59?active=true' -d @/var/tmp/handleGateway48624.xml

     

    Result:Resource validation failed due to 'INVALID_VALUES' Unable to update service: Folder update not permitted.



  • 4.  Re: Unable to use RESTMAN to move service into another folder

    Posted Nov 24, 2016 04:34 AM
      |   view attached

    BTW the MySQL way works:

     

    policyId=$($GMYSQL "select lower(hex(policy_goid)) from published_service where goid=unhex('$serviceId')")
    admin=$($GMYSQL "update published_service set folder_goid=unhex('$folderId') where goid=unhex('$serviceId')")
    admin=$($GMYSQL "update policy set folder_goid=unhex('$folderId') WHERE goid=unhex('$policyId')")

     

    If you're logged into Policy Manager you still need to perform a refresh though...

    Because only the folderId is modified, do you really think there could be side effects ?

    We really need to have the move_folder functionality... why is it not possible to have RESTMAN handle it ?

     

    As we're using a load-balanced multi-master cluster, I'm assuming 2nd gateway is receiving updates through only MySQL replication, so it should basically works...

     

     

    NOTE: attached is OTK DB Get policy fragment, which was impossible to attach in the other discussion.

    Attachment(s)



  • 5.  Re: Unable to use RESTMAN to move service into another folder
    Best Answer

    Broadcom Employee
    Posted Nov 24, 2016 04:54 PM

    Philippe,

     

    I've been able to duplicate the error you get with the Restman service and have confirmed that this is expected. I have create an idea (Need the ability to move services to different folders using Restman service ) to have this added to the product. I have also added another idea for the ability to pick a folder to publish the service to for the API Portal (Need the ability within the API Portal to publish a service to a particular folder ). Please make sure to vote on these ideas to ensure that are viewed important.

     

    As for the support of the direct DB calls, we don't test this method of updating the database so it can not be supported. Without doing testing we will not know if the change will cause other issues within the system.

     

    Sincerely,

     

    Stephen Hughes

    Director, CA Support



  • 6.  Re: Unable to use RESTMAN to move service into another folder

    Posted Jan 31, 2018 04:09 AM

    Hello,

     

    I was trying to do the same action without success, ( moving an existing Service using RESTMAN to another folder)

     

    As pointed in this topic I am getting the expected error:

     

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <l7:Error xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
    <l7:Type>InvalidResource</l7:Type>
    <l7:TimeStamp>2018-01-31T09:33:12.474+01:00</l7:TimeStamp>
    <l7:Link rel="self" uri="xxxx"/>
    <l7:Detail>Resource validation failed due to 'INVALID_VALUES' Unable to update service: Folder update not permitted.</l7:Detail>
    </l7:Error>

     

    My questions:

     

    - @Stephen Hughes:   Is this feature already implemented? 

    @PhBrand: Have you found out a way to achieve it?

     

     

    I think, a possible approach would be following:

     

    1. RESTMAN:   GET 1.0/services/{id_example}
    2. RESTMAN:   DELETE 1.0/services/{id_example}
    3. RESTMAN:   PUT 1.0/services/{id_example}    (with folderId modification)

     

    Have you tried it?



  • 7.  Re: Unable to use RESTMAN to move service into another folder

    Posted Feb 09, 2018 03:38 AM

    Hi,

     

    Nope didn't try this approach, it should work but we sticked to MySQL modification, while waiting for a direct RESTman implementation (we have patience as my original post is from late 2016  )