# Path: tuskar/api/controllers/v1/types/base.py
# class Base(wsme.types.Base):
# 
#     def __init__(self, **kwargs):
#         self.fields = list(kwargs)
#         for k, v in kwargs.iteritems():
#             setattr(self, k, v)
# 
#     @classmethod
#     def from_db_model(cls, m):
#         return cls(**m.as_dict())
# 
#     @classmethod
#     def from_db_and_links(cls, m, links):
#         return cls(links=links, **(m.as_dict()))
# 
#     def as_dict(self):
#         return dict((k, getattr(self, k))
#                     for k in self.fields
#                     if hasattr(self, k) and
#                     getattr(self, k) != wsme.Unset)
# 
#     def get_id(self):
#         """Returns the ID of this resource as specified in the self link."""
# 
#         # FIXME(mtaylor) We should use a more robust method for parsing the URL
#         if not isinstance(self.id, wtypes.UnsetType):
#             return self.id
#         elif not isinstance(self.links, wtypes.UnsetType):
#             return self.links[0].href.split("/")[-1]
#         else:
#             raise wsme.exc.ClientSideError(_("No ID or URL Set for Resource"))
# 
# Path: tuskar/api/controllers/v1/types/link.py
# class Link(Base):
#     """A link representation."""
# 
#     href = wtypes.text
#     "The url of a link."
# 
#     rel = wtypes.text
#     "The name of a link."
# 
#     @classmethod
#     def build(self, rel_name, url, type, type_arg):
#         return Link(href=('%s/v1/%s/%s') % (url, type, type_arg), rel=rel_name)
# 
#     @classmethod
#     def build_ironic_link(self, rel_name, resource_id):
#         return Link(href=('%s/%s') % (CONF.ironic_url, resource_id),
#                     rel=rel_name)
# 
# Path: tuskar/api/controllers/v1/types/capacity.py
# class Capacity(Base):
#     """A capacity representation."""
# 
#     name = wtypes.text
#     value = wtypes.text
#     unit = wtypes.text


import pecan
import wsme
from wsme import types as wtypes
from tuskar.api.controllers.v1.types.base import Base
from tuskar.api.controllers.v1.types.link import Link
from tuskar.api.controllers.v1.types.capacity import Capacity
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

class Flavor(Base):
    """A representation of Flavor in HTTP body."""
    #FIXME - I want id to be UUID - String
    id = wsme.wsattr(int, mandatory=True)
    name = wsme.wsattr(wtypes.text, mandatory=False)
    max_vms = wsme.wsattr(int, mandatory=False)
    capacities = [Capacity]

# Path: tuskar/api/controllers/v1/types/base.py
# class Base(wsme.types.Base):
# 
#     def __init__(self, **kwargs):
#         self.fields = list(kwargs)
#         for k, v in kwargs.iteritems():
#             setattr(self, k, v)
# 
#     @classmethod
#     def from_db_model(cls, m):
#         return cls(**m.as_dict())
# 
#     @classmethod
#     def from_db_and_links(cls, m, links):
#         return cls(links=links, **(m.as_dict()))
# 
#     def as_dict(self):
#         return dict((k, getattr(self, k))
#                     for k in self.fields
#                     if hasattr(self, k) and
#                     getattr(self, k) != wsme.Unset)
# 
#     def get_id(self):
#         """Returns the ID of this resource as specified in the self link."""
# 
#         # FIXME(mtaylor) We should use a more robust method for parsing the URL
#         if not isinstance(self.id, wtypes.UnsetType):
#             return self.id
#         elif not isinstance(self.links, wtypes.UnsetType):
#             return self.links[0].href.split("/")[-1]
#         else:
#             raise wsme.exc.ClientSideError(_("No ID or URL Set for Resource"))
# 
# Path: tuskar/api/controllers/v1/types/link.py
# class Link(Base):
#     """A link representation."""
# 
#     href = wtypes.text
#     "The url of a link."
# 
#     rel = wtypes.text
#     "The name of a link."
# 
#     @classmethod
#     def build(self, rel_name, url, type, type_arg):
#         return Link(href=('%s/v1/%s/%s') % (url, type, type_arg), rel=rel_name)
# 
#     @classmethod
#     def build_ironic_link(self, rel_name, resource_id):
#         return Link(href=('%s/%s') % (CONF.ironic_url, resource_id),
#                     rel=rel_name)
# 
# Path: tuskar/api/controllers/v1/types/capacity.py
# class Capacity(Base):
#     """A capacity representation."""
# 
#     name = wtypes.text
#     value = wtypes.text
#     unit = wtypes.text


# Path: tuskar/api/controllers/v1/types/flavor.py
import pecan
import wsme
from wsme import types as wtypes
from tuskar.api.controllers.v1.types.base import Base
from tuskar.api.controllers.v1.types.link import Link
from tuskar.api.controllers.v1.types.capacity import Capacity

# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

class Flavor(Base):
    """A representation of Flavor in HTTP body."""
    #FIXME - I want id to be UUID - String
    id = wsme.wsattr(int, mandatory=True)
    name = wsme.wsattr(wtypes.text, mandatory=False)
    max_vms = wsme.wsattr(int, mandatory=False)
    capacities = [Capacity]

    links = [Link]