REST API - Create PVA from Traffic File

Looking for examples of creating a PVA from a traffic file using the REST API. Any information or sample code would be greatly appreciated. Thanks, JT

Comments

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    Hi,
    It sounds like you would want to use the resource "POST /v6/files/pvas/traffic" which will need a traffic file uploaded to the server. An example payload might be
    { "repositoryConnectionSettings": { "port": 2424, "host": "dataRepositoryServer", "repositoryName": "createPvaFromTraffic", "password": "admin", "user": "admin" }, "name": "createPvaFromTraffic", "parent": { "id": "/CreateFromTraffic" }, "trafficFile": { "id": "/uploads/Traffic.txt" }, "characterEncoding": "UTF-8" }

    You'll want to replace most of these values with your own but in this example we are creating a pva called "createPvaFromTraffic" in a project named "CreateFromTraffic" in the workspace. We are using a traffic file in the workspace located at "/uploads/Traffic.txt" and the data for messages will be put into the repository with connection settings specified.

    To try it out there is a useful api documentation page that you can find on the server be opening a browser and going to http://::9080/soavirt/api and you can find the resource mention and test out different payloads.

    Hope this helps!

  • jefftuckerbofajefftuckerbofa Posts: 30

    Thanks for the information. I am using the example you provided, adjusted slightly to match my setup. Getting a 404 stating that it can not find the /uploads/Traffic.txt file. Tells me to fix the trafficFile.id.

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    Hi,
    Where did you upload your traffic file to? The traffic file needs to be in the workspace on the server and that id should be changed to be the id of where your traffic file is.

  • jefftuckerbofajefftuckerbofa Posts: 30

    I was able to get it to find the traffic file. I'm at the point now where I am trying to create a template file to go along with the request.

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    A template should not been needed if you specify the repository settings. If you need some non default settings then yes create a template using the desktop then upload it to the server.

    Hope this helps!

  • jefftuckerbofajefftuckerbofa Posts: 30

    I created a data repository called createPvaFromTraffic in the embedded server. What port does that listen on? Thanks.

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    The embedded data repository is not very portable. It's meant to be for your local testing but other servers won't be able to use that data repository. Is it possible to use a remote repository rather than the embedded one?

  • jefftuckerbofajefftuckerbofa Posts: 30

    Not at the moment. My employer just recently inked the deal to migrate to this product and we don't have full access to the infrastructure. I'm one of the early adopters. I am ok using the embedded server at this stage. I realize it will not be used in the final implementation of the tools I am creating.

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    Ok, I think if you create the template it should have the settings for the embedded repository saved in it. In the payload to the REST api leave out the "repository" object and just set the template. It should find the settings in the template file.

  • jefftuckerbofajefftuckerbofa Posts: 30

    I wasn't able to find where to create the template. Sorry, I've been a CA SV guy for quite some time. Trying to get familiar with a new product here.

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    No worries :smile:

    To create a template proceed through the traffic wizard in the desktop to create the pva file. Go all the way to the last step of the wizard, before clicking finish click the box to say you want a template and pick a file name plus location. See attached screenshot.

  • jefftuckerbofajefftuckerbofa Posts: 30

    Awesome. Thanks. I believe I should be able to take it from here. Much appreciated!

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    Happy to help!

  • jefftuckerbofajefftuckerbofa Posts: 30

    So, if I generate the VirtualAsset using /soavirt/api/v5/files/pvas/traffic without specifying a traffic template, is the default simply Fixed Message responders?

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    Without a template I believe it will create parameterized responders and the api should require that you provide data repository information.

  • jefftuckerbofajefftuckerbofa Posts: 30

    Thanks. I didn't see an option to download a traffic template when I went through the Fixed flow. And, looking at the template that was created in the Parameterized flow I didn't see anything that looked like a way to change to Fixed.

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    Hi,
    I don't think traffic templates are supported for fixed traffic wizard. The rest api mentioned is for parameterized responders and doesn't create fixed traffic.

    You want to automate the creation of fixed responders from traffic using the rest api?

  • jefftuckerbofajefftuckerbofa Posts: 30

    I'll wait until I do a little more research on parameterized responders before I answer that.. ;-)

  • jefftuckerbofajefftuckerbofa Posts: 30

    There was a script posted in another discussion that referenced a "v6" API endpoint. Is that in the GA release now? I get a 404 and I do not see it referenced in the API docs.

    Get the Deployment ID

    response=$(curl -vs \
    --user $VIRT_USER:$VIRT_PASS \
    -X GET \
    -H "Accept: application/json" \
    "http://$VIRT_HOST:$VIRT_PORT/soavirt/api/v6/virtualAssets?fields=id&pvaLocation=/VirtualAssets/$VA_SUBFOLDER/$ASSET_NAME.pva")

    DEP_ID=${response:25:50}
    echo $DEP_ID

  • williammccuskerwilliammccusker Posts: 227 ✭✭

    That version of the api should be in the 9.10.7 release. Also v5 has that same resource so you should be able to use that older version.

Sign In or Register to comment.