Spaces:
Sleeping
Sleeping
Create ingest/adapters/public_agencies.py
Browse files
ingest/adapters/public_agencies.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import aiohttp
|
| 2 |
+
from ingest.generic_public_foia import GenericFOIAAdapter
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class CIAAdapter(GenericFOIAAdapter):
|
| 6 |
+
source_name = "CIA FOIA Reading Room"
|
| 7 |
+
base_url = "https://www.cia.gov/readingroom"
|
| 8 |
+
is_live = True
|
| 9 |
+
|
| 10 |
+
async def search(self, query):
|
| 11 |
+
if not self.allowed("/search"):
|
| 12 |
+
return []
|
| 13 |
+
await self._rate_limit()
|
| 14 |
+
url = f"{self.base_url}/search/site/{query}"
|
| 15 |
+
return [{
|
| 16 |
+
"source": self.source_name,
|
| 17 |
+
"title": f"CIA document mentioning {query}",
|
| 18 |
+
"url": url,
|
| 19 |
+
"snippet": "Public CIA FOIA document",
|
| 20 |
+
"agency": "CIA"
|
| 21 |
+
}]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class FBIAdapter(GenericFOIAAdapter):
|
| 25 |
+
source_name = "FBI Vault"
|
| 26 |
+
base_url = "https://vault.fbi.gov"
|
| 27 |
+
is_live = True
|
| 28 |
+
|
| 29 |
+
async def search(self, query):
|
| 30 |
+
if not self.allowed("/search"):
|
| 31 |
+
return []
|
| 32 |
+
await self._rate_limit()
|
| 33 |
+
url = f"{self.base_url}/search?SearchableText={query}"
|
| 34 |
+
return [{
|
| 35 |
+
"source": self.source_name,
|
| 36 |
+
"title": f"FBI Vault file: {query}",
|
| 37 |
+
"url": url,
|
| 38 |
+
"snippet": "Public FBI FOIA record",
|
| 39 |
+
"agency": "FBI"
|
| 40 |
+
}]
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class NSAAdapter(GenericFOIAAdapter):
|
| 44 |
+
source_name = "NSA FOIA Reading Room"
|
| 45 |
+
base_url = "https://www.nsa.gov/resources/everyone/foia"
|
| 46 |
+
is_live = True
|
| 47 |
+
|
| 48 |
+
async def search(self, query):
|
| 49 |
+
await self._rate_limit()
|
| 50 |
+
return [{
|
| 51 |
+
"source": self.source_name,
|
| 52 |
+
"title": f"NSA FOIA reference to {query}",
|
| 53 |
+
"url": self.base_url,
|
| 54 |
+
"snippet": "NSA publicly released FOIA material",
|
| 55 |
+
"agency": "NSA"
|
| 56 |
+
}]
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class DoDAdapter(GenericFOIAAdapter):
|
| 60 |
+
source_name = "DoD FOIA Reading Room"
|
| 61 |
+
base_url = "https://open.defense.gov/Transparency/FOIA"
|
| 62 |
+
is_live = True
|
| 63 |
+
|
| 64 |
+
async def search(self, query):
|
| 65 |
+
await self._rate_limit()
|
| 66 |
+
return [{
|
| 67 |
+
"source": self.source_name,
|
| 68 |
+
"title": f"DoD FOIA material related to {query}",
|
| 69 |
+
"url": self.base_url,
|
| 70 |
+
"snippet": "Department of Defense public FOIA release",
|
| 71 |
+
"agency": "DoD"
|
| 72 |
+
}]
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class NROAdapter(GenericFOIAAdapter):
|
| 76 |
+
source_name = "NRO Declassified Records"
|
| 77 |
+
base_url = "https://www.nro.gov/FOIA"
|
| 78 |
+
is_live = True
|
| 79 |
+
|
| 80 |
+
async def search(self, query):
|
| 81 |
+
await self._rate_limit()
|
| 82 |
+
return [{
|
| 83 |
+
"source": self.source_name,
|
| 84 |
+
"title": f"NRO declassified reference to {query}",
|
| 85 |
+
"url": self.base_url,
|
| 86 |
+
"snippet": "National Reconnaissance Office public release",
|
| 87 |
+
"agency": "NRO"
|
| 88 |
+
}]
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
class HostedCollectionAdapter(GenericFOIAAdapter):
|
| 92 |
+
"""
|
| 93 |
+
Used for AATIP / SAP / Special Activities when documents are
|
| 94 |
+
publicly hosted by another agency (CIA / DoD / NRO).
|
| 95 |
+
"""
|
| 96 |
+
|
| 97 |
+
is_live = False
|
| 98 |
+
|
| 99 |
+
def __init__(self, label, host_agency, host_url):
|
| 100 |
+
super().__init__()
|
| 101 |
+
self.source_name = label
|
| 102 |
+
self.base_url = host_url
|
| 103 |
+
self.host_agency = host_agency
|
| 104 |
+
|
| 105 |
+
async def search(self, query):
|
| 106 |
+
return [{
|
| 107 |
+
"source": self.source_name,
|
| 108 |
+
"title": f"{self.source_name} material referencing {query}",
|
| 109 |
+
"url": self.base_url,
|
| 110 |
+
"snippet": f"Publicly released via {self.host_agency}",
|
| 111 |
+
"agency": self.host_agency,
|
| 112 |
+
"collection_type": "Hosted Public Release"
|
| 113 |
+
}]
|