Release Automation

Expand all | Collapse all

How can I automate loading token definitions?

Jump to Best Answer

Chip Rabinowitz03-18-2016 09:10 AM

Chip Rabinowitz03-22-2016 12:06 PM

  • 1.  How can I automate loading token definitions?

    Posted 03-17-2016 06:10 PM

    In the documentation, I can see an API call for loading token values from a token manifest file. I need to automate loading token definitions from a manifest file too. Obviously, the definitions can be loaded from a file using the GUI, but that's not a good long term solution for me.



  • 2.  Re: How can I automate loading token definitions?

    Posted 03-18-2016 09:10 AM

    I was going to ask the exact same question today!



  • 3.  Re: How can I automate loading token definitions?

    Posted 03-22-2016 12:06 PM

    Somebody?



  • 4.  Re: How can I automate loading token definitions?

    Posted 03-23-2016 02:33 AM

    Currently there is no API for generating the token definitions so the only workaround I would think about will be collecting next token ID value from DB and creating the token using REST API.

    I would recommend create new idea for this requirement

    Jacky



  • 5.  Re: How can I automate loading token definitions?

    Posted 03-23-2016 11:55 AM

    eis_mlynch, I would recommend you submit the idea to add the API....

     

    Jacky_Mahadab, if i knew the DB table where the token definitions live, i could do a loop and add/replace/merge them, don't you think?  Gotta handy query in your back pocket?  Even a query to get a LIST of the current token defs would give me enough info to do it myself



  • 6.  Re: How can I automate loading token definitions?

    Posted 03-23-2016 12:19 PM

    The table if I remember correctly is rc_tokens _definition but do not  update it directly as there other related tables.

    Thanks

    Jacky



  • 7.  Re: How can I automate loading token definitions?

    Posted 03-23-2016 12:54 PM

    So how would I be able to create new token definitions WITHOUT loading the manifest in the UI?

     

    Chip Rabinowitz

    Senior Enterprise DevOps Architect

    A&I Solutions

    702-443-7520



  • 8.  Re: How can I automate loading token definitions?

    Posted 03-23-2016 02:39 PM

    Once you know the next token id (from the DB) you will create the new definition using REST API (Post method ) you will need the application id as well.

    e.g

    http://rademo:8080/datamanagement/a/applications/104/tokens  (104 is applicaiton id)

     

    payload

    {id: "10", name: "new_token", type: "STRING", defaultValue: "abc", applicationId: "104"}  (id 10 is the next token id)

     

     

     

    This is not formal way so please run proper testing to validate it.

    Jacky



  • 9.  Re: How can I automate loading token definitions?

    Posted 03-23-2016 02:52 PM

    Ummm……where is that REST call documented?

     

    So the correct sequence is:

     

     

    1.       Query DB to see if the token definition already exists

     

    a.       If it exists make sure the default value/mask match

     

    b.      If no match, update default/mask

     

    2.       If the definition doesn’t exist, query the table for the next ID

     

    3.       Add the token with the rest call using the new ID

     

    4.       Query the DB to make sure it’s been added and the “next” ID has changed

     

    Does this sound like the correct sequence?

     

    Chip Rabinowitz

    Senior Enterprise DevOps Architect

    A&I Solutions

    702-443-7520



  • 10.  Re: How can I automate loading token definitions?

    Posted 03-24-2016 03:22 AM

    Its not documented since its not formal way to do it

    As I said before, I advice you to tested it before use it in your deployment activities.



  • 11.  Re: How can I automate loading token definitions?

    Posted 03-24-2016 09:17 AM

    But does my flow design sound correct?

     

    Also….does the /token accept an existing ID and update it?  As well as creating a new token?

     

    Chip Rabinowitz

    Senior Enterprise DevOps Architect

    A&I Solutions

    702-443-7520



  • 12.  Re: How can I automate loading token definitions?

    Broadcom Employee
    Posted 03-24-2016 10:04 AM

    You can also try looking at the load-tokens REST call, the body of the call would look similar to the following (simply replace fields in red with parameters):

     

     

    {"environmentId":"9","manifest":"<TokensManifest><tokens-definition><token name=\"newToken\" type=\"String\" defaultValue=\"test\"></token></tokens-definition><values><environment name=\"dev\"><token name=\"newToken\" value=\"Test\"></token></environment></values></TokensManifest>"}



  • 13.  Re: How can I automate loading token definitions?

    Posted 03-25-2016 10:15 AM

    @Kevin, are you saying that the Load-Tokens REST call will create a new token if you pass in the definition?

     

    The documentation says it just loads values, not definitions.

     

    Can we get some clarification here?

     

    Chip Rabinowitz

    Senior Enterprise DevOps Architect

    A&I Solutions

    702-443-7520



  • 14.  Re: How can I automate loading token definitions?

    Broadcom Employee
    Posted 03-25-2016 11:39 PM

    Yes, that is correct.

     

    If we break down the rest call it is essentially passing through a manifest file to RA. This will have the same behavior as loading a token manifest file through ROC.

     

    Define Tokens in a Manifest File will create the tokens and also load the values, I guess we may need to add that clarification to the REST API reference as well.



  • 15.  Re: How can I automate loading token definitions?

    Posted 03-28-2016 08:30 AM

    Yes, definitely the REST API documentation needs to be updated.  The incorrect documentation caused us a lot of time and trouble.

     

    Now, as far as the functionality of the REST call (and probably the action, although I didn’t test that specifically), it is NOT possible to load just definitions.

     

    If you do a lot of tokenization, you will end up needing a file with the token defs, and environment-specific files with the values.

     

    You can load a file with just token values, no problem.

     

    But if you try to load a file with just definitions, it fails unless you add “” after the close of the definitions tag.  Doesn’t matter if the environment exists or not, you just need to have the values block with an environment name.

     

    It would be VERY useful to be able to load definitions and/or values simultaneously or separately instead of having to manipulate the definitions file manually.

     

    Am I making any sense here?

     

    Chip Rabinowitz

    Senior Enterprise DevOps Architect

    A&I Solutions

    702-443-7520



  • 16.  Re: How can I automate loading token definitions?

    Broadcom Employee
    Posted 03-28-2016 12:05 PM

    Not quite sure I follow you here. Just ran a test with the following parameters and the token definition was created without any issues. In this case the manifest payload only contains token definitions.

     

    http://ra-server:8080/datamanagement/a/api/v3/load-tokens

     

    {"environmentId":"9","manifest":"<TokensManifest><tokens-definition><token name=\"newToken\" type=\"String\" defaultValue=\"test\"></token></tokens-definition></TokensManifest>"}

     

    This is on RA 5.5.2, which version are you running on?



  • 17.  Re: How can I automate loading token definitions?

    Posted 03-28-2016 01:12 PM

    Try it without a default value, Kevin….

     

    Chip Rabinowitz

    Senior Enterprise DevOps Architect

    A&I Solutions

    702-443-7520



  • 18.  Re: How can I automate loading token definitions?

    Broadcom Employee
    Posted 03-28-2016 03:35 PM

    Ah, I see what you mean. If I run it with defaultValue=\"\" or without the defaultValue attribute I get back a "Couldn't parse XML document" message even though it still creates the token definition. If we load the exact same manifest through the GUI it gets added without any issues.

     

    Having said that, is there any specific reason why you wouldn't want a default value for the tokens?



  • 19.  Re: How can I automate loading token definitions?

    Posted 03-28-2016 04:52 PM

    Correct.  So without default values, I need to add the environment block to avoid the error.

     

    Sounds like a bug in the REST call ☺

     

    But I got mine working, so that’s good!

     

    Chip Rabinowitz

    Senior Enterprise DevOps Architect

    A&I Solutions

    702-443-7520



  • 20.  Re: How can I automate loading token definitions?
    Best Answer

    Posted 04-27-2016 11:22 AM

    Hi Kevin.

    Was just reviewing this thread and saw that your question about the reason to omit default values for tokens. We have a scheme where the tokens essentially represent the schema for a configuration file. That schema is controlled by 1 team, but many team use it, plugging in their own values. We prefer to import the tokens definitions without values so that when the token values get imported separately by an environment owning team, if they are missing a value in their value manifest file, deployments will fail early, at the de-tokenization stage rather than later because some default value was used during de-tokenization.

     

    I realize that description is a bit abstract, but do you get the idea?



  • 21.  Re: How can I automate loading token definitions?

    Broadcom Employee
    Posted 04-27-2016 05:57 PM

    Yes, that makes perfect sense. Thanks for clarifying the use case



  • 22.  Re: How can I automate loading token definitions?

    Posted 03-24-2016 10:00 AM