POST /v2/rules
Create a rule
POST /v2/project_sessions/:project_session_id/rules
Create a rule for the given Project session
live_help Notes
assignment
This action requires one of theses roles:
Advanced tutor
settings Params
| Param name | Description |
|---|---|
| project_session_id |
optional
. Must be String
The project_session id |
| rule | optional , nil allowed . Must be a Hash |
| rule[id] |
optional
, nil allowed
. Must be Fixnum
The id. |
| rule[kind] |
required
. Must be one of: inscription, retry_inscription, correction, final_compilation, eval_compilation, retriable, group_validation, team_generation, experience_modification.
The kind. |
| rule[name] |
required
. Must be String
The name. Must be unique in the scope of a given kind. |
| rule[description] |
optional
, nil allowed
. Must be String
The description. |
| rule[created_at] |
optional
, nil allowed
. Must be DateTime
The created at. |
| rule[updated_at] |
optional
, nil allowed
. Must be DateTime
The updated at. |
| rule[slug] |
optional
, nil allowed
. Must be String
The slug. |
| rule[internal_name] |
optional
, nil allowed
. Must be String
The internal name. |
| rule[params_attributes] |
optional
, nil allowed
. Must be an Array of nested elements
The params attributes. |
| rule[params_attributes][id] |
optional
, nil allowed
. Must be Fixnum
The id. |
| rule[params_attributes][name] |
required
. Must be String
The name. |
| rule[params_attributes][default_value] |
optional
, nil allowed
. Must be String
The default value. |
| rule[params_attributes][rule_id] |
optional
, nil allowed
. Must be Fixnum
The rule id. |
| rule[params_attributes][data_type] |
required
. Must be one of: string, parsed_string, integer, array.
The data type. |
| rule[params_attributes][_destroy] |
optional
, nil allowed
. Must be String
The destroy. |
Examples
POST /v2/rules
{
"rule": {
"description": "The user first name must start by the #{letter} letter",
"internal_name": "FirstNameStartingBy",
"kind": "inscription",
"name": "First name starting by",
"params_attributes": [
{
"data_type": "string",
"default_value": "",
"name": "letter"
}
]
}
}
201
{
"id": 11,
"kind": "inscription",
"name": "First name starting by",
"description": "The user first name must start by the #{letter} letter",
"created_at": "2017-11-22T13:43:59.860Z",
"updated_at": "2017-11-22T13:43:59.860Z",
"slug": "inscription-first-name-starting-by",
"internal_name": "FirstNameStartingBy",
"params": [
{
"id": 1,
"name": "letter",
"default_value": "",
"rule_id": 11,
"created_at": "2017-11-22T13:43:59.863Z",
"updated_at": "2017-11-22T13:43:59.863Z",
"data_type": "string"
}
]
}
curl -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"rule":{"description":"The user first name must start by the #{letter} letter","internal_name":"FirstNameStartingBy","kind":"inscription","name":"First name starting by","params_attributes":[{"data_type":"string","default_value":"","name":"letter"}]}}' "https://api.intra.42.fr/v2/rules"
{
"id": 11,
"kind": "inscription",
"name": "First name starting by",
"description": "The user first name must start by the #{letter} letter",
"created_at": "2017-11-22T13:43:59.860Z",
"updated_at": "2017-11-22T13:43:59.860Z",
"slug": "inscription-first-name-starting-by",
"internal_name": "FirstNameStartingBy",
"params": [
{
"id": 1,
"name": "letter",
"default_value": "",
"rule_id": 11,
"created_at": "2017-11-22T13:43:59.863Z",
"updated_at": "2017-11-22T13:43:59.863Z",
"data_type": "string"
}
]
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token
params = {rule: {description: "The user first name must start by the #{letter} letter", internal_name: "FirstNameStartingBy", kind: "inscription", name: "First name starting by", params_attributes: [{data_type: "string", default_value: "", name: "letter"}]}}
response = token.post("/v2/rules", params: params)
response.status
# => 201
response.parsed
# => {"id"=>11, "kind"=>"inscription", "name"=>"First name starting by", "description"=>"The user first name must start by the \#{letter} letter", "created_at"=>"2017-11-22T13:43:59.860Z", "updated_at"=>"2017-11-22T13:43:59.860Z", "slug"=>"inscription-first-name-starting-by", "internal_name"=>"FirstNameStartingBy", "params"=>[{"id"=>1, "name"=>"letter", "default_value"=>"", "rule_id"=>11, "created_at"=>"2017-11-22T13:43:59.863Z", "updated_at"=>"2017-11-22T13:43:59.863Z", "data_type"=>"string"}]}