RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
Cloud.py
Go to the documentation of this file.
1 
2 class CloudMsg(object):
3  """ Cloud Message base class implementation. Inherit to implement
4  service specific cloud message objects
5  """
6 
7  def __init__(self, svcname='', **kwargs):
8  self._svcname = svcname
9  for key, value in kwargs.iteritems():
10  if hasattr(self.req, key):
11  setattr(self.req, key, value)
12  else:
13  raise AttributeError(''.join(self.__class__.__name__ +
14  ' object does not have a property named ' + str(key)))
15 
16 
17  @property
18  def svcname(self):
19  return self._svcname
20 
21 
22 
23 
24 class CloudRequest(object):
25  """ Cloud request base class implementation. Inheric to implement
26  Cloud Message specific Request objects.
27  """
28  def __init__(self, **kwargs):
29  for key, value in kwargs.iteritems():
30  if hasattr(self, key):
31  setattr(self, key, value)
32  else:
33  raise AttributeError(''.join(self.__class__.__name__ +
34  ' object does not have a property named ' + str(key)))
35 
36 
37  def __eq__(self, other):
38  """! Equality method """
39  return self.serialize() == other.serialize()
40 
41 
42  def set(self, key, val):
43  if hasattr(self, key):
44  setattr(self, key, val)
45 
46 
47  def make_payload(self):
48  """! Abstract method. Return Payload Object.
49 
50  @returns Payload - The Payload object
51  """
52  raise NotImplementedError()
53 
54 
55  def make_files(self):
56  """! Abstract methor. Return Array of File Objects.
57 
58  @returns Array - Array of File Objects.
59  """
60  raise NotImplementedError()
61 
62 
63  def serialize(self):
64  """! Serialize CloudRequest object to dictionary.
65 
66  @returns Dictionary - Serialized CloudRequest object.
67  """
68  return { k:v for k,v in vars(self).items() if not k.startswith('_') or callable(v) }
69 
70 
71 
72 
73 class CloudResponse(object):
74  """ Cloud Response base class implementation. Inherit to implement
75  Cloud Object specific Response objects.
76  """
77  def __init__(self, **kwargs):
78  for key, val in kwargs.iteritems():
79  if hasattr(self, key):
80  setattr(self, key, val)
81  else:
82  raise AttributeError()
83 
84 
85  def __eq__(self, other):
86  """! Equality method """
87  return self.serialize() == other.serialize()
88 
89 
90  def set(self, key, val):
91  if hasattr(self, key):
92  setattr(self, key, val)
93 
94 
95  def serialize(self):
96  """! Serialize CloudResponse object to dictionary.
97 
98  @returns Dictionary - Serialized CloudResponse object.
99  """
100  return { k:v for k,v in vars(self).items() if not k.startswith('_') or callable(v) }
101 
def make_payload
Abstract method.
Definition: Cloud.py:47
def __eq__
Equality method.
Definition: Cloud.py:37
def serialize
Serialize CloudRequest object to dictionary.
Definition: Cloud.py:63
def serialize
Serialize CloudResponse object to dictionary.
Definition: Cloud.py:95
def make_files
Abstract methor.
Definition: Cloud.py:55
def __eq__
Equality method.
Definition: Cloud.py:85