예제 #1
0
    def __call__(self, *args, **kwargs):
        if len(args) == 1:
            identifier = str(args[0])

        if kwargs is None:
            raise exceptions.BadRequest(
                details=
                'An attribute should be given (e.g. qualifiedName="/my/hdfs/path")'
            )

        self._is_inflated = False
        self._filter = {}
        self._models = []
        url_path_filter = ''
        if kwargs:
            prefix = self.model_class.data_key
            for (key, value) in kwargs.items():
                if self.model_class.use_key_prefix:
                    key = '/'.join([prefix, key])
                if not isinstance(value, six.string_types):
                    value = json.dumps(value)
                self._filter[key] = value
            filter_list = [
                '{}={}'.format(k, v) for k, v in self._filter.items()
            ]
            url_path_filter = '?' + '&'.join(filter_list)
        return self.model_class(
            self,
            href='/'.join([self.url, identifier]) + url_path_filter,
            data={self.model_class.primary_key: identifier})
예제 #2
0
 def update(self, attribute):
     if attribute not in self.entity['attributes']:
         raise exceptions.BadRequest(method=self.update,
                                     details='The attribute {} does not exist for {}'.format(attribute,
                                                                                             self.entity['typeName']))
     self.load(self.client.put(self.url + '?name={}'.format(attribute),
                               data=self.entity['attributes'][attribute]))
     return self._data
예제 #3
0
 def update(self, attribute):
     if attribute not in self.entity['attributes']:
         raise exceptions.BadRequest(method=self.update,
                                     details='The attribute {} does not exist for {}'.format(attribute,
                                                                                             self.entity[
                                                                                                 'typeName']))
     LOG.debug(f"Trying to update the attribute '{attribute}' of {self.entity['typeName']} "
               f"with the value {self.entity['attributes'][attribute]}")
     self.load(self.client.put(self.url + '?name={}'.format(attribute),
                               data=self.entity['attributes'][attribute]))
     return self._data
예제 #4
0
 def __call__(self, *args, **kwargs):
     """
     """
     if 'data' not in kwargs:
         raise exceptions.BadRequest(method=self.__call__, details='This class should be called with the argument "data="')
     self._models = []
     self._is_inflated = True
     model = self.model_class(self,
                              href=self.url,
                              data=kwargs.get('data'))
     self._models.append(model)
     return self