def add_security_label(self, security_label_name): """ retrieve attributes for this indicator """ prop = self._resource_properties['add_security_label'] ro = RequestObject() ro.set_description( 'deleting security label {0} for attribute {1} of object {2}'. format(security_label_name, self.id, self._container.id)) ro.set_http_method(prop['http_method']) ro.set_owner_allowed(prop['owner_allowed']) resource_uri = self._container._resource_properties['id']['uri'] try: resource_uri = resource_uri.format(self._container.indicator) except AttributeError: resource_uri = resource_uri.format(self._container.id) ro.set_request_uri(prop['uri'].format(resource_uri, self.id, security_label_name)) ro.set_resource_pagination(prop['pagination']) callback = lambda status: self.__failed_add_security_label( security_label_name) ro.set_failure_callback(callback) self._container._resource_container.add_commit_queue( self._container.id, ro) security_label = SecurityLabelObject() security_label.set_name(security_label_name) self.__add_security_label(security_label)
def add_attribute(self, attr_type, attr_value, attr_displayed='true'): """ add an attribute to a group """ prop = self._resource_properties['attribute_add'] ro = RequestObject() ro.set_body(json.dumps({ 'type': attr_type, 'value': attr_value, 'displayed': attr_displayed})) ro.set_description('add attribute type "{0}" with value "{1}" to "{2}"'.format( attr_type, attr_value, self._name)) ro.set_http_method(prop['http_method']) ro.set_owner_allowed(prop['owner_allowed']) ro.set_request_uri(prop['uri'].format(self._id)) ro.set_resource_pagination(prop['pagination']) ro.set_resource_type(self._resource_type) callback = lambda status: self.__add_attribute_failure(attr_type, attr_value) ro.set_failure_callback(callback) self._resource_container.add_commit_queue(self.id, ro) attribute = AttributeObject(self) attribute.set_type(attr_type) attribute.set_value(attr_value) attribute.set_displayed(attr_displayed) self._resource_obj.add_attribute(attribute)