Skip to content

REST: Environment configuration related API

bugzmanov edited this page Mar 11, 2013 · 2 revisions

Note: Terminology in this section can be changes in the future

Configuration is a container for environment specific properties. In a turn, any new created instance must refer to existing configuration. Project always has at least one configuration.

List existing configurations

Path: /rest/projects/(projectId)/configs
Type: GET
Path parameters

Parameter Type Description
projectId Number project id of the project configuration belong to

GET Parameters:

Name Type Value Mandatory Description
sorting string name, ~name no Sorting by entity field value. By default ordering direction is ascending. Use prefix '~' to produce result in descending order.

Example results:

{
    "items": [
        {
            "id":1,
            "name":"Default",
            "projectId":1,
            "description":"",
            "items":{},
            "links" : [
            {
               "rel" : "self",
               "href" : "http://genesis.example.com/rest/projects/1/configs/1",
               "methods" : [
                  "get",
                  "put",
                  "delete"
               ],
               "type" : "application/vnd.griddynamics.genesis.Configuration+json"
            }
            ]
        }
    ],
    "links" : [
      {
         "rel" : "self",
         "href" : "http://localhost:8081/rest/projects/1/configs",
         "methods" : [
            "get",
            "post"
         ],
         "type" : "application/vnd.griddynamics.genesis.Configuration+json"
      }
   ]
}

Get concrete configuration

Path: /rest/projects/(projectId)/configs/(configId)
Type: GET
Path parameters:

Parameter Type Description
projectId Number project id of the project configuration belong to
configId Number configuration id

Example results:

{
    "id":1,
    "name":"Default",
    "projectId":1,
    "description":"",
    "items":{"foo":"bar"},
    "links" : [
      {
         "rel" : "collection",
         "href" : "http://genesis.example.com/rest/projects/1/configs/1/access",
         "methods" : [
            "get",
            "put"
         ],
         "type" : "application/vnd.griddynamics.genesis.Access+json"
      },
      {
         "rel" : "self",
         "href" : "http://genesis.example.com/rest/projects/1/configs/1",
         "methods" : [
            "get",
            "put",
            "delete"
         ],
         "type" : "application/vnd.griddynamics.genesis.Configuration+json"
      }
  ]
}

##Create configuration

Path: /rest/projects/(projectId)/configs
Type: POST
Path parameters

Parameter Type Description
projectId Number project id of the project configuration belong to

POST parameters

JSON consisting of:

Parameter Type Description
name String Configuration name (mandatory)
projectId Number identifier of project new configuration belong to (mandatory)
description String Configuration description (optional)
items Map[String, String] Configuration items (optional)

###Example request

curl http://localhost:8081/rest/projects/1/configs -d '{"name":"Test", "projectId": 1, "description":"Test configuration", "items" : { "foo" : "bar"}}' -H 'Content-type: application/json' -X POST

Example response

{"result":
   {
     "id":1,
     "name":"Test",
     "projectId":1,
     "description":
     "Test configuration",
     "items":
        {"foo":"bar"}
   },
"isSuccess":true}

Update configuration

Path: /rest/projects/(projectId)/configs/(configId)

Type: PUT

Path parameters:

Parameter Type Description
projectId Integer Project id
configId Integer Configuration id

PUT parameters

JSON consisting of:

Parameter Type Description
name String Configuration name (mandatory)
projectId Number identifier of project new configuration belong to (mandatory)
description String Configuration description (optional)
items Map[String, String] Configuration items (optional)

###Example request

curl http://localhost:8081/rest/projects/1/configs/1 -d '{"name":"Test", "projectId": 1, "description":"Test configuration", "items" : { "foo" : "bar"}}' -H 'Content-type: application/json' -X PUT

Example response

{"result":
   {
     "id":1,
     "name":"Test",
     "projectId":1,
     "description":
     "Test configuration",
     "items":
        {"foo":"bar"}
   },
"isSuccess":true}

Delete configuration

Path: /rest/projects/(projectId)/configs/(configId)

Type: DELETE

Path parameters:

Parameter Type Description
projectId Integer Project id
configId Integer Configuration id

Example request

curl http://localhost:8081/rest/projects/1/configs/1 -H 'Content-type: application/json' -X DELETE

Example response

{
	"result":1,
	"isSuccess":true
}

Managing user access to configuration

It's possible to manage user access to configuration and instances contained in it when environment-level security is on.

Get permissions list

Path: /projects/(projectId)/configs/(configId)/access

Type: GET

Path parameters:

Parameter Type Description
projectId Integer Project id
configId Integer Configuration id

Example request

curl http://localhost:8081/rest/projects/1/configs/1/access -H 'Content-type: application/json' -X GET

Example response

{
   "groups" : [
      "test"
   ],
   "users" : [
      {
         "jobTitle" : "",
         "firstName" : "test",
         "email" : "test@example.com",
         "lastName" : "test",
         "username" : "test"
      }
   ],
   "links" : [
      {
         "rel" : "self",
         "href" : "http://localhost:8081/rest/projects/1/configs/1/access",
         "methods" : [
            "get",
            "put"
         ],
         "type" : "application/vnd.griddynamics.genesis.Access+json"
      }
   ]
}

Modify acccess to configuration

Path: /projects/(projectId)/configs/(configId)/access

Type: PUT

Path parameters:

Parameter Type Description
projectId Integer Project id
configId Integer Configuration id

PUT parameters

Parameter Type Descrtiption
users Array of strings User names
groups Array of strings Group names

Example request

curl http://localhost:8081/rest/projects/1/configs/1/access -H 'Content-type: application/json' -X PUT -d '{"users":["user"],"groups":["users"]}'

Example response

{
    "isSuccess": true, 
    "result": {
        "nonExistentGroups": [
            "group"
        ], 
        "nonExistentUsers": [
            "username"
        ]
    }
}
Clone this wiki locally