Skip to content

Commit

Permalink
new: [Proposals] New get proposals index functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Jul 26, 2019
1 parent 0198c87 commit fa30d28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pymisp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,10 @@ def __query_proposal(self, path, id, attribute=None):
response = self._prepare_request('POST', url)
return self._check_response(response)

@deprecated(reason="Use ExpandedPyMISP.attribute_proposals", version='2.4.111')
def proposal_index(self, timestamp=0):
return self.__query_proposal('index', 'all:1/timestamp:{}'.format(timestamp))

@deprecated(reason="Use ExpandedPyMISP.get_attribute_proposal", version='2.4.111')
def proposal_view(self, event_id=None, proposal_id=None):
"""View a proposal"""
Expand Down
8 changes: 8 additions & 0 deletions pymisp/aping.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ def delete_attribute(self, attribute: Union[MISPAttribute, int, str, UUID]):
# ## END Attribute ###

# ## BEGIN Attribute Proposal ###
def attribute_proposals(self, timestamp: Union[int, str]=0, pythonify: bool=False):
attribute_proposal = self._prepare_request('GET', f'shadow_attributes/index/all:1/timestamp:{timestamp}')
attribute_proposal = self._check_response(attribute_proposal, expect_json=True)
if not (self.global_pythonify or pythonify) or 'errors' in attribute_proposal:
return attribute_proposal
a = MISPShadowAttribute()
a.from_dict(**attribute_proposal)
return a

def get_attribute_proposal(self, proposal: Union[MISPShadowAttribute, int, str, UUID], pythonify: bool=False):
proposal_id = self.__get_uuid_or_id_from_abstract_misp(proposal)
Expand Down

0 comments on commit fa30d28

Please sign in to comment.