Назначение владельца ресурса

Назначение владения ресурсами осуществляется с помощью действия set_ownership. Это действие доступно для следующих ресурсов:

  • /api/auth_key_pairs;
  • /api/cloud_templates;
  • /api/instances;
  • /api/service_templates
  • /api/services;
  • /api/templates;
  • /api/vms.

Назначение владельца

Назначение владельца в запросах осуществляется через спецификации owner и group:

    {
"owner" : { "href" : "http://localhost:3000/api/users/:id" },
"group" : { "href" : "http://localhost:3000/api/groups/:id" }
    }

Примечание:

  • Назначить владельца можно через href, id, name или userid.
  • Назначить группу можно через href, id или description.

Назначение владельца может быть выполнено для определенного ресурса или нескольких ресурсов в одном запросе.

Пример назначения владельца на единичный ресурс

Запрос:

POST /api/vms/320
{
"action" : "set_ownership",
"resource" : {
"owner" : { "userid" : "jdoe" },
"group" : { "description" : "TestGroup" }
}

Ответ:

{
"success": true,
"message": "setting ownership of vms id 320 to owner: jdoe, group: TestGroup",
"href": "http://localhost:3000/api/vms/320"
}

Пример назначения владельца на несколько ресурсов в одном запросе

Запрос:

POST /api/services
{
"action" : "set_ownership",
"resources" : [
{ "href" : "http://localhost:3000/api/services/104", "owner" : { "name" : "John Doe" } },
{ "href" : "http://localhost:3000/api/services/105", "owner" : { "name" : "John Doe" } },
{ "href" : "http://localhost:3000/api/services/106", "owner" : { "name" : "John Doe" } }
]
}

Ответ:

{
"results": [
{
"success": true,
"message": "setting ownership of services id 104 to owner: John Doe",
"href": "http://localhost:3000/api/services/104"
},
{
"success": true,
"message": "setting ownership of services id 105 to owner: John Doe",
"href": "http://localhost:3000/api/services/105"
},
{
"success": true,
"message": "setting ownership of services id 106 to owner: John Doe",
"href": "http://localhost:3000/api/services/106"
}
}