def add_indicator(self, data, indicator_type=None): """ filter api results by indicator """ # validation indicator if not SharedMethods.validate_indicator(self.tc._indicators_regex, data): raise AttributeError(ErrorCodes.e5010.value.format(data)) # get indicator uri attribute if indicator_type is None: indicator_type = SharedMethods.get_resource_type( self.tc._indicators_regex, data) indicator_uri_attribute = ApiProperties.api_properties[ indicator_type.name]['uri_attribute'] prop = self._resource_properties['indicator'] ro = RequestObject() ro.set_description('api filter by indicator id {0}'.format(data)) ro.set_owner_allowed(prop['owner_allowed']) # TODO: Check this logic if self._resource_type == ResourceType.INDICATORS: ro.set_request_uri( prop['uri'], [indicator_uri_attribute, SharedMethods.urlsafe(data)]) else: ro.set_request_uri(prop['uri'], [SharedMethods.urlsafe(data)]) ro.set_resource_pagination(prop['pagination']) ro.set_resource_type(indicator_type) self._add_request_objects(ro)
def add_indicator(self, data, indicator_type = None): """ filter api results by indicator """ # validation indicator if not SharedMethods.validate_indicator(self.tc._indicators_regex, data): raise AttributeError(ErrorCodes.e5010.value.format(data)) # get indicator uri attribute if indicator_type is None: indicator_type = SharedMethods.get_resource_type(self.tc._indicators_regex, data) indicator_uri_attribute = ApiProperties.api_properties[indicator_type.name]['uri_attribute'] prop = self._resource_properties['indicator'] ro = RequestObject() ro.set_description('api filter by indicator id {0}'.format(data)) ro.set_owner_allowed(prop['owner_allowed']) # TODO: Check this logic if self._resource_type == ResourceType.INDICATORS: ro.set_request_uri(prop['uri'], [indicator_uri_attribute, SharedMethods.urlsafe(data)]) else: ro.set_request_uri(prop['uri'], [SharedMethods.urlsafe(data)]) ro.set_resource_pagination(prop['pagination']) ro.set_resource_type(indicator_type) self._add_request_objects(ro)
def add_tag(self, data): """ """ if not isinstance(data, str): raise AttributeError(ErrorCodes.e4070.value.format(data)) prop = self._resource_properties['tags'] ro = RequestObject() ro.set_description('api filter by tag "{0}"'.format(data)) ro.set_owner_allowed(prop['owner_allowed']) ro.set_resource_pagination(prop['pagination']) ro.set_request_uri(prop['uri'], [SharedMethods.urlsafe(data)]) ro.set_resource_type(self._resource_type) self._add_request_objects(ro)
def add_security_label(self, data): """ filter api results by security label """ # validation of data input if not isinstance(data, str): raise AttributeError(ErrorCodes.e4050.value.format(data)) prop = self._resource_properties['security_labels'] ro = RequestObject() ro.set_description('api filter by security label "{0}"'.format(data)) ro.set_owner_allowed(prop['owner_allowed']) ro.set_resource_pagination(prop['pagination']) ro.set_request_uri(prop['uri'], [SharedMethods.urlsafe(data)]) ro.set_resource_type(self._resource_type) self._add_request_objects(ro)
def add_indicator(self, data): """ """ # validation indicator if not SharedMethods.validate_indicator(data): raise AttributeError(ErrorCodes.e5010.value.format(data)) # get indicator uri attribute indicator_type = SharedMethods.get_resource_type(data) indicator_uri_attribute = ApiProperties.api_properties[indicator_type.name]['uri_attribute'] prop = self._resource_properties['indicators'] ro = RequestObject() ro.set_description('api filter by indicator id {0}'.format(data)) ro.set_owner_allowed(prop['owner_allowed']) ro.set_request_uri(prop['uri'], [indicator_uri_attribute, SharedMethods.urlsafe(data)]) ro.set_resource_pagination(prop['pagination']) ro.set_resource_type(self._resource_type) self._add_request_objects(ro)
def add_indicator(self, data): """ """ # validation indicator if not SharedMethods.validate_indicator(self.tc._indicators_regex, data): raise AttributeError(ErrorCodes.e5010.value.format(data)) # get indicator uri attribute indicator_type = SharedMethods.get_resource_type(self.tc._indicators_regex, data) indicator_uri_attribute = ApiProperties.api_properties[indicator_type.name]['uri_attribute'] prop = self._resource_properties['indicators'] ro = RequestObject() ro.set_description('api filter by indicator id {0}'.format(data)) ro.set_owner_allowed(prop['owner_allowed']) ro.set_request_uri(prop['uri'], [indicator_uri_attribute, SharedMethods.urlsafe(data)]) ro.set_resource_pagination(prop['pagination']) ro.set_resource_type(self._resource_type) self._add_request_objects(ro)