RESTlos icon indicating copy to clipboard operation
RESTlos copied to clipboard

Problem adding timeperiod

Open petrovicboban opened this issue 8 years ago • 2 comments

$ cat /tmp/timeperiods 
[
  {
    "thursday" : "00:00-24:00", 
    "wednesday" : "00:00-24:00", 
    "friday" : "00:00-24:00", 
    "sunday" : "00:00-24:00", 
    "alias": "Always-2", 
    "monday" : "00:00-24:00", 
    "tuesday" : "00:00-24:00", 
    "timeperiod_name": "24x7-2", 
    "saturday" : "00:00-24:00"
  }
]

$ curl -X POST -d @/tmp/timeperiods  -H "content-type: application/json" 'http://admin:[email protected]:8080/timeperiod'
{
  "results": [
    {
      "404": "unknown attribute: monday"
    }
  ], 
  "summary": {
    "failed": 1, 
    "succeeded": 0, 
    "total": 1
  }
}

unknown attribute: monday wtf?? However, it is possible that this is related to pynag issue I've submited.

petrovicboban avatar Aug 16 '16 13:08 petrovicboban

Hi @petrovicboban,

This message is generated here. The validate function should prevent malformed api requests to the endpoints. Valid attributes are gathered from pynag here.

Checking the issue you opened for pynag, they (whyever) have put the key AND the value in the key portion of the dictionary. That breaks the whole concept of RESTlos (and any RESTful API as well).

I can't see a real workaround for that right now. So I guess you have to place the timeperiods manually in your config directory (which is one reason why I build RESTlos, you can do things manually with an editor without screwing things up).

Let's see what the pynag guys say about the issue.

Regards, Christian

Crapworks avatar Aug 16 '16 14:08 Crapworks

Hi @petrovicboban,

My colleague made a PR for timeperiods: https://github.com/Crapworks/RESTlos/pull/14

You should try it ;-)

CharlesJUDITH avatar Jan 31 '17 16:01 CharlesJUDITH