Project

General

Profile

Actions

Bug #3756

closed

Modifying the group of a Rule by API need to use the data "ruleTarget" instead of "targets"

Added by Nicolas PERRON over 10 years ago. Updated over 10 years ago.

Status:
Released
Priority:
1
Category:
API
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
Name check:
Fix check:
Regression:

Description

When getting information from a group with the API, we've got:

{
  "action":"ruleDetails",
  "id":"e8cf66a9-f891-48c4-8adb-c86dfc1451d6",
  "result":"success",
  "data":{
    "rules":[{
      "id":"e8cf66a9-f891-48c4-8adb-c86dfc1451d6",
      "displayName":"Rule to Remove (renamed)",
      "shortDescription":"",
      "longDescription":"",
      "directives":["b3d2a48b-18b9-49c1-804d-91a2f797ab6a"],
      "targets":[],
      "enabled":true,
      "system":false
    }]
  }

But if we want to modify the targets (the group, indeed), we have to use ruleTarget instead of targets:

curl -H "X-API-Token:cEMKWn38wzgpIZPwmipe1NPeAmfzwroR" -H "X-API-Version: 1.0" -X POST http://localhost/rudder/api/rules/e8cf66a9-f891-48c4-8adb-c86dfc1451d6?prettify=true -d "targets=group:db58aaa7-f51c-42a5-af32-4d1e3bf95b10" 
{
  "action":"updateRule",
  "id":"e8cf66a9-f891-48c4-8adb-c86dfc1451d6",
  "result":"success",
  "data":{
    "rules":[{
      "id":"e8cf66a9-f891-48c4-8adb-c86dfc1451d6",
      "displayName":"Rule to Remove (renamed)",
      "shortDescription":"Little comment",
      "longDescription":"Big comment with strange characters: œ$%!\\/\r\nEnd of comment",
      "directives":["b3d2a48b-18b9-49c1-804d-91a2f797ab6a"],
      "targets":[],
      "enabled":true,
      "system":false
    }]
  }

curl -H "X-API-Token:cEMKWn38wzgpIZPwmipe1NPeAmfzwroR" -H "X-API-Version: 1.0" -X POST http://localhost/rudder/api/rules/e8cf66a9-f891-48c4-8adb-c86dfc1451d6?prettify=true -d "ruleTarget=group:db58aaa7-f51c-42a5-af32-4d1e3bf95b10" 
{
  "action":"updateRule",
  "id":"e8cf66a9-f891-48c4-8adb-c86dfc1451d6",
  "result":"success",
  "data":{
    "rules":[{
      "id":"e8cf66a9-f891-48c4-8adb-c86dfc1451d6",
      "displayName":"Rule to Remove (renamed)",
      "shortDescription":"Little comment",
      "longDescription":"Big comment with strange characters: œ$%!\\/\r\nEnd of comment",
      "directives":["b3d2a48b-18b9-49c1-804d-91a2f797ab6a"],
      "targets":["group:db58aaa7-f51c-42a5-af32-4d1e3bf95b10"],
      "enabled":true,
      "system":false
    }]
  }
Actions #1

Updated by Nicolas PERRON over 10 years ago

  • Description updated (diff)
Actions #2

Updated by Vincent MEMBRÉ over 10 years ago

  • Status changed from New to Pending technical review
  • Assignee changed from Vincent MEMBRÉ to François ARMAND
  • Pull Request set to https://github.com/Normation/rudder/pull/268
Actions #3

Updated by Vincent MEMBRÉ over 10 years ago

  • Status changed from Pending technical review to Pending release
  • % Done changed from 0 to 100
Actions #4

Updated by Anonymous over 10 years ago

Actions #5

Updated by Nicolas PERRON over 10 years ago

  • Status changed from Pending release to Released
Actions

Also available in: Atom PDF