3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from collections import OrderedDict
19 from dss.api import dss_error
25 "result": <description>,
30 def __init__(self, name=None, id=None, payload={}, result='OK'):
33 self.payload = payload
37 msg = OrderedDict([('name', self.name), ('id', self.id), ('result', self.result), ('payload', self.payload) ])
39 #msg['name'] = self.name
41 #msg['result'] = self.result
42 #msg['payload'] = self.payload
44 return json.dumps(msg, separators=(',', ':'))
46 def deserialize(self, msg):
47 data = json.loads(msg, object_pairs_hook=OrderedDict)
48 self.name = data['name']
50 self.result = data['result']
51 self.payload = data['payload']
53 if self.result != 'OK':
54 raise dss_error.Error('Request failed with error %s' % self.result)
65 def get_payload(self):