from flareio import FlareApiClient
from flareio.ratelimit import Limiter
api_client = FlareApiClient.from_env()
limiter_default = Limiter.from_seconds(0.25)
# 1. Create an Identifier
identifier_resp = api_client.post(
"/firework/v2/assets/",
json={
"name": "scatterholt.com",
"type": "domain",
"search_types": [
"forum_post",
],
"data": {"type": "domain", "fqdn": "scatterholt.com"},
"risks": [1, 2, 3, 4, 5],
},
)
identifier = identifier_resp.json()["asset"]
identifier_id = identifier["id"]
# Rate limiting (default).
limiter_default.tick()
# 2. Create a Matching Policy
matching_policy_resp = api_client.post(
"/firework/v4/matching_policies",
json={
"name": "Terms to ignore",
"type": "EXCLUDED_KEYWORDS",
"value": {"keywords": ["term1", "term2", "term3"]},
},
)
matching_policy = matching_policy_resp.json()
matching_policy_name = matching_policy["name"]
matching_policy_uuid = matching_policy["uuid"]
# Rate limiting (default).
limiter_default.tick()
# 3. Assign the matching policy to the identifier
api_client.post(
f"/firework/v4/matching_policies/{matching_policy_uuid}/assignments",
json={"identifier_ids": [identifier_id], "clean_past_events": False},
)
print(
f"Created identifier {identifier_id} with matching policy '{matching_policy_name}' assigned to it"
)