# Path: sevenbridges/meta/resource.py
# class Resource(metaclass=ResourceMeta):
#     """
#     Resource is base class for all resources, hiding implementation details
#     of magic of injecting instance of API and common operations (like generic
#     query).
#     """
#     _API = None
#     _URL = {}
# 
#     def __init__(self, api, *args, **kwargs):
#         self.api = api
# 
#     @classmethod
#     def _query(cls, **kwargs):
#         """
#         Generic query implementation that is used
#         by the resources.
#         """
#         from sevenbridges.models.link import Link
#         from sevenbridges.meta.collection import Collection
# 
#         api = kwargs.pop('api', cls._API)
#         url = kwargs.pop('url')
# 
#         # Check for valid limit value
#         if kwargs.get('limit') is not None and kwargs['limit'] <= 0:
#             kwargs['limit'] = RequestParameters.DEFAULT_BULK_LIMIT
# 
#         extra = {'resource': cls.__name__, 'query': kwargs}
#         logger.info('Querying %s resource', cls, extra=extra)
#         response = api.get(url=url, params=kwargs)
#         try:
#             data = response.json()
#         except JSONDecodeError:
#             raise NonJSONResponseError(
#                 status=response.status_code,
#                 message=str(response.text)
#             ) from None
# 
#         total = response.headers['x-total-matching-query']
# 
#         items = [cls(api=api, **item) for item in data['items']]
#         links = [Link(**link) for link in data['links']]
#         href = data['href']
#         return Collection(
#             resource=cls, href=href, total=total, items=items,
#             links=links, api=api
#         )
# 
#     @classmethod
#     def get(cls, id, api=None):
#         """
#         Fetches the resource from the server.
#         :param id: Resource identifier
#         :param api: sevenbridges Api instance.
#         :return: Resource object.
#         """
#         id = Transform.to_resource(id)
#         api = api if api else cls._API
#         if 'get' in cls._URL:
#             extra = {'resource': cls.__name__, 'query': {'id': id}}
#             logger.info('Fetching %s resource', cls, extra=extra)
#             resource = api.get(url=cls._URL['get'].format(id=id)).json()
#             return cls(api=api, **resource)
#         else:
#             raise SbgError('Unable to retrieve resource!')
# 
#     def delete(self):
#         """
#         Deletes the resource on the server.
#         """
#         if 'delete' in self._URL and hasattr(self, 'id'):
#             extra = {'resource': type(self).__name__, 'query': {
#                 'id': self.id}}
#             logger.info("Deleting %s resource.", self, extra=extra)
#             self._api.delete(url=self._URL['delete'].format(id=self.id))
#         else:
#             raise SbgError('Resource can not be deleted!')
# 
#     def reload(self):
#         """
#         Refreshes the resource with the data from the server.
#         """
#         try:
#             if hasattr(self, 'href'):
#                 data = self._api.get(self.href, append_base=False).json()
#                 resource = type(self)(api=self._api, **data)
#             elif hasattr(self, 'id') and hasattr(self, '_URL') and \
#                     'get' in self._URL:
#                 data = self._api.get(
#                     self._URL['get'].format(id=self.id)).json()
#                 resource = type(self)(api=self._api, **data)
#             else:
#                 raise SbgError(
#                     'Resource can not be refreshed, "id" property not set or '
#                     'retrieval for this resource is not available.'
#                 )
#             query = {'id': self.id} if hasattr(self, 'id') else {}
#             extra = {'resource': type(self).__name__, 'query': query}
#             logger.info('Reloading %s resource.', self, extra=extra)
#         except Exception as e:
#             raise SbgError(
#                 f'Resource can not be refreshed due to an error: {e}'
#             )
# 
#         self._data = resource._data
#         self._dirty = resource._dirty
#         self.update_old()
#         return self
# 
#     def update_old(self):
#         self._old = copy.deepcopy(self._data.data)
# 
#     def field(self, name):
#         """
#         Return field value if it's set
#         :param name: Field name
#         :return: Field value or None
#         """
#         return self._data.data.get(name, None)
# 
#     def _set(self, key, value):
#         """
#         Set property value in internal storage
#         :param key: Property name
#         :param value: Property value
#         """
#         self._data.data[key] = value
# 
# Path: sevenbridges/meta/fields.py
# class StringField(Field):
#     def __init__(self, read_only, name=None, max_length=None):
#         super().__init__(name=name, read_only=read_only)
#         self.max_length = max_length
# 
#     def validate(self, value):
#         value = super().validate(value)
#         if value and not isinstance(value, str):
#             raise ValidationError(
#                 f'{value} is not a valid value for {type(self).__name__}'
#             )
#         if self.max_length is not None and len(value) > self.max_length:
#             raise ValidationError(f'{self.name}: max length exceeded.')
#         return value


from sevenbridges.meta.resource import Resource
from sevenbridges.meta.fields import StringField


class FileStorage(Resource):
    """
    File storage resource contains information about the storage location
    of the file if the file is imported on or exported to an external volume.
    """
    type = StringField(read_only=True)

# Path: sevenbridges/meta/resource.py
# class Resource(metaclass=ResourceMeta):
#     """
#     Resource is base class for all resources, hiding implementation details
#     of magic of injecting instance of API and common operations (like generic
#     query).
#     """
#     _API = None
#     _URL = {}
# 
#     def __init__(self, api, *args, **kwargs):
#         self.api = api
# 
#     @classmethod
#     def _query(cls, **kwargs):
#         """
#         Generic query implementation that is used
#         by the resources.
#         """
#         from sevenbridges.models.link import Link
#         from sevenbridges.meta.collection import Collection
# 
#         api = kwargs.pop('api', cls._API)
#         url = kwargs.pop('url')
# 
#         # Check for valid limit value
#         if kwargs.get('limit') is not None and kwargs['limit'] <= 0:
#             kwargs['limit'] = RequestParameters.DEFAULT_BULK_LIMIT
# 
#         extra = {'resource': cls.__name__, 'query': kwargs}
#         logger.info('Querying %s resource', cls, extra=extra)
#         response = api.get(url=url, params=kwargs)
#         try:
#             data = response.json()
#         except JSONDecodeError:
#             raise NonJSONResponseError(
#                 status=response.status_code,
#                 message=str(response.text)
#             ) from None
# 
#         total = response.headers['x-total-matching-query']
# 
#         items = [cls(api=api, **item) for item in data['items']]
#         links = [Link(**link) for link in data['links']]
#         href = data['href']
#         return Collection(
#             resource=cls, href=href, total=total, items=items,
#             links=links, api=api
#         )
# 
#     @classmethod
#     def get(cls, id, api=None):
#         """
#         Fetches the resource from the server.
#         :param id: Resource identifier
#         :param api: sevenbridges Api instance.
#         :return: Resource object.
#         """
#         id = Transform.to_resource(id)
#         api = api if api else cls._API
#         if 'get' in cls._URL:
#             extra = {'resource': cls.__name__, 'query': {'id': id}}
#             logger.info('Fetching %s resource', cls, extra=extra)
#             resource = api.get(url=cls._URL['get'].format(id=id)).json()
#             return cls(api=api, **resource)
#         else:
#             raise SbgError('Unable to retrieve resource!')
# 
#     def delete(self):
#         """
#         Deletes the resource on the server.
#         """
#         if 'delete' in self._URL and hasattr(self, 'id'):
#             extra = {'resource': type(self).__name__, 'query': {
#                 'id': self.id}}
#             logger.info("Deleting %s resource.", self, extra=extra)
#             self._api.delete(url=self._URL['delete'].format(id=self.id))
#         else:
#             raise SbgError('Resource can not be deleted!')
# 
#     def reload(self):
#         """
#         Refreshes the resource with the data from the server.
#         """
#         try:
#             if hasattr(self, 'href'):
#                 data = self._api.get(self.href, append_base=False).json()
#                 resource = type(self)(api=self._api, **data)
#             elif hasattr(self, 'id') and hasattr(self, '_URL') and \
#                     'get' in self._URL:
#                 data = self._api.get(
#                     self._URL['get'].format(id=self.id)).json()
#                 resource = type(self)(api=self._api, **data)
#             else:
#                 raise SbgError(
#                     'Resource can not be refreshed, "id" property not set or '
#                     'retrieval for this resource is not available.'
#                 )
#             query = {'id': self.id} if hasattr(self, 'id') else {}
#             extra = {'resource': type(self).__name__, 'query': query}
#             logger.info('Reloading %s resource.', self, extra=extra)
#         except Exception as e:
#             raise SbgError(
#                 f'Resource can not be refreshed due to an error: {e}'
#             )
# 
#         self._data = resource._data
#         self._dirty = resource._dirty
#         self.update_old()
#         return self
# 
#     def update_old(self):
#         self._old = copy.deepcopy(self._data.data)
# 
#     def field(self, name):
#         """
#         Return field value if it's set
#         :param name: Field name
#         :return: Field value or None
#         """
#         return self._data.data.get(name, None)
# 
#     def _set(self, key, value):
#         """
#         Set property value in internal storage
#         :param key: Property name
#         :param value: Property value
#         """
#         self._data.data[key] = value
# 
# Path: sevenbridges/meta/fields.py
# class StringField(Field):
#     def __init__(self, read_only, name=None, max_length=None):
#         super().__init__(name=name, read_only=read_only)
#         self.max_length = max_length
# 
#     def validate(self, value):
#         value = super().validate(value)
#         if value and not isinstance(value, str):
#             raise ValidationError(
#                 f'{value} is not a valid value for {type(self).__name__}'
#             )
#         if self.max_length is not None and len(value) > self.max_length:
#             raise ValidationError(f'{self.name}: max length exceeded.')
#         return value


# Path: sevenbridges/models/compound/files/file_storage.py
from sevenbridges.meta.resource import Resource
from sevenbridges.meta.fields import StringField



class FileStorage(Resource):
    """
    File storage resource contains information about the storage location
    of the file if the file is imported on or exported to an external volume.
    """
    type = StringField(read_only=True)

    volume = StringField(read_only=True)