fix creation board request
This commit is contained in:
parent
71cfaf235e
commit
f4432869b0
@ -14,7 +14,7 @@ case "$1" in
|
|||||||
|
|
||||||
list) curl $BASE/boards/
|
list) curl $BASE/boards/
|
||||||
;;
|
;;
|
||||||
create-board) curl -X POST $BASE/boards/
|
create-board) curl -H "Content-Type: application/json" -X POST $BASE/boards/ -d '{"code":"'"$2"'"}'
|
||||||
;;
|
;;
|
||||||
delete-board) curl -X DELETE $BASE/boards/$2
|
delete-board) curl -X DELETE $BASE/boards/$2
|
||||||
;;
|
;;
|
||||||
|
@ -17,7 +17,7 @@ class Board(base.APIBase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
uuid = types.uuid
|
uuid = types.uuid
|
||||||
code = wsme.wsattr(int)
|
code = wsme.wsattr(wtypes.text)
|
||||||
status = wsme.wsattr(wtypes.text)
|
status = wsme.wsattr(wtypes.text)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -190,49 +190,19 @@ class BoardsController(rest.RestController):
|
|||||||
|
|
||||||
#@expose.expose(Board, body=Board, status_code=201)
|
#@expose.expose(Board, body=Board, status_code=201)
|
||||||
#def post(self, Board):
|
#def post(self, Board):
|
||||||
@expose.expose(Board, status_code=201)
|
@expose.expose(Board, body=Board, status_code=201)
|
||||||
def post(self):
|
def post(self,Board):
|
||||||
"""Create a new Board.
|
"""Create a new Board.
|
||||||
|
|
||||||
:param Board: a Board within the request body.
|
:param Board: a Board within the request body.
|
||||||
"""
|
"""
|
||||||
'''
|
|
||||||
if not Board.uuid:
|
if not Board.uuid:
|
||||||
Board.uuid = uuidutils.generate_uuid()
|
Board.uuid = uuidutils.generate_uuid()
|
||||||
|
if not Board.status:
|
||||||
try:
|
Board.status = 'DISCONNECTED'
|
||||||
pecan.request.rpcapi.get_topic_for(Board)
|
|
||||||
except exception.NoValidHost as e:
|
|
||||||
e.code = 400
|
|
||||||
raise e
|
|
||||||
|
|
||||||
if Board.name:
|
|
||||||
if not api_utils.allow_Board_logical_names():
|
|
||||||
raise exception.NotAcceptable()
|
|
||||||
if not api_utils.is_valid_Board_name(Board.name):
|
|
||||||
msg = _("Cannot create Board with invalid name %(name)s")
|
|
||||||
raise wsme.exc.ClientSideError(msg % {'name': Board.name},
|
|
||||||
status_code=400)
|
|
||||||
'''
|
|
||||||
#new_Board = objects.Board(pecan.request.context,
|
|
||||||
# **Board.as_dict())
|
|
||||||
|
|
||||||
#new_Board = objects.Board(pecan.request.context,
|
|
||||||
# **Board.as_dict())
|
|
||||||
#rpc_board = api_utils.get_rpc_board('a9a86ab8-ad45-455e-86c3-d8f7d892ec9d')
|
|
||||||
|
|
||||||
"""{'status': u'1', 'uuid': u'a9a86ab8-ad45-455e-86c3-d8f7d892ec9d',
|
|
||||||
'created_at': datetime.datetime(2015, 1, 30, 16, 56, tzinfo=<iso8601.iso8601.Utc object at 0x7f5b81e0dd90>),
|
|
||||||
'updated_at': None,
|
|
||||||
'reservation': None, 'id': 106, 'name': u'provaaaa'}
|
|
||||||
"""
|
|
||||||
|
|
||||||
uuid = uuidutils.generate_uuid()
|
|
||||||
b={'status': 'DISCONNECTED', 'uuid': uuid, 'code':'11223344'}
|
|
||||||
board = Board(**b)
|
|
||||||
|
|
||||||
new_Board = objects.Board(pecan.request.context,
|
new_Board = objects.Board(pecan.request.context,
|
||||||
**board.as_dict())
|
**Board.as_dict())
|
||||||
new_Board.create()
|
new_Board.create()
|
||||||
#pecan.response.location = link.build_url('Boards', new_Board.uuid)
|
#pecan.response.location = link.build_url('Boards', new_Board.uuid)
|
||||||
return Board.convert_with_links(new_Board)
|
return Board.convert_with_links(new_Board)
|
||||||
|
Loading…
Reference in New Issue
Block a user