Hi Brooklyners,


I am new here, but while writing CAMP blueprints  using Brooklyn DSL I hit
a wall.



Here’s my situation: I have a brooklyn.parameter of a custom type named
Credential, that is defined like this:

- *id*: Credential
  *format*: bean-with-type
  *item*:
    *type*: my.type.Credential



The Credential class has two properties: user and token.



I want to be able to use the value of the ‘user’ property when configuring
my service, like this:



*items*:
- *itemType*: template  *item*:    *brooklyn.parameters*:    - *name*:
user_credentials      *type*: Credential      *default*:
*user*: *"unsername"
        **token*: *"password"
    **services*:    - *id*: credential-service      *type*:
my.credential.Service      *brooklyn.initializers*:      - *type*:
my.initializer.AAA        *brooklyn.config*:          *name*:
user.name          *static.value*:
*$brooklyn:config("user_credentials")["user"]*


Currently I see no way to access the value of the "user" property of my
brooklyn parameter.  Also, in case the Credential type also has a "roles"
property which is a list<string> or an array, I would very much like to be
able to write

*$brooklyn:config("user_credentials")["roles"]["0"]*

Of if the “user.credentials” is of type  list<Credentials>, it would be
nice if I could do

*$brooklyn:config("user_credentials")["0"]["user"]*


I personally like the [x] approach where x is tried (in order):

   - an argument to a `get(x)` method (works for lists and maps: index or
   key)
   - a bean property (if x is a string, look for method called getX() or a
   field called  x
   - a config key, if the target is Configurable , ie getConfig(x) or
   config().get(x)


Or we could go for something pretty similar to a JsonPath style (
https://github.com/json-path/JsonPath)



This would allow us to write constructs like:

*$brooklyn:config("user_credentials").user*

*$brooklyn:config("user_credentials").roles[0]*

*$brooklyn:config("user_credentials")[0].user*



I think a change like this would make Brooklyn DSL more flexible and open
the door to further improvements and also make blueprints more readable.



I propose to work on the above and welcome any thoughts from the community.



Cheers,

Iuliana

-- 
Cheers,
Iuliana Cosmina

Reply via email to