Skip to content

Commit

Permalink
Merge pull request #47 from Flared/mahinse/rename_retrieve_to_fetch
Browse files Browse the repository at this point in the history
Renamed the 'retrieve' terms in the app to 'fetch' for consistency
  • Loading branch information
TyMarc authored Nov 18, 2024
2 parents a124a1d + e5284db commit b4e1009
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 112 deletions.
24 changes: 12 additions & 12 deletions packages/configuration-screen/src/ConfigurationScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
appName,
createFlareIndex,
redirectToHomepage,
retrieveApiKey,
retrieveAvailableIndexNames,
retrieveCurrentIndexName,
retrieveIngestMetadataOnly,
retrieveTenantId,
retrieveUserTenants,
fetchApiKey,
fetchAvailableIndexNames,
fetchCurrentIndexName,
fetchIngestMetadataOnly,
fetchTenantId,
fetchUserTenants,
saveConfiguration,
} from './utils/setupConfiguration';
import { ConfigurationSteps, Tenant } from './models/flare';
Expand Down Expand Up @@ -78,7 +78,7 @@ const ConfigurationScreen: FC<{ theme: string }> = ({ theme }) => {

const handleSubmitApiKey = (): void => {
setIsLoading(true);
retrieveUserTenants(
fetchUserTenants(
apiKey,
(userTenants: Tenant[]) => {
if (tenantId === -1 && userTenants.length > 0) {
Expand Down Expand Up @@ -137,11 +137,11 @@ const ConfigurationScreen: FC<{ theme: string }> = ({ theme }) => {
}
createFlareIndex().then(() => {
Promise.all([
retrieveApiKey(),
retrieveTenantId(),
retrieveIngestMetadataOnly(),
retrieveCurrentIndexName(),
retrieveAvailableIndexNames(),
fetchApiKey(),
fetchTenantId(),
fetchIngestMetadataOnly(),
fetchCurrentIndexName(),
fetchAvailableIndexNames(),
]).then(([key, id, ingestMetadataOnly, index, availableIndexNames]) => {
setApiKey(key);
setTenantId(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function updateConfigurationFile(
stanzaName: string,
properties: Record<string, string>
): Promise<void> {
// Retrieve the accessor used to get a configuration file
// Fetch the accessor used to get a configuration file
let configurations = service.configurations({
// Name space information not provided
});
Expand All @@ -110,7 +110,7 @@ export async function updateConfigurationFile(
configurations = await promisify(configurations.fetch)();
}

// Retrieves the configuration file accessor
// Fetchs the configuration file accessor
let configurationFileAccessor = getConfigurationFile(configurations, configurationFilename);
configurationFileAccessor = await promisify(configurationFileAccessor.fetch)();

Expand All @@ -125,7 +125,7 @@ export async function updateConfigurationFile(
// Need to update the information after the creation of the stanza
configurationFileAccessor = await promisify(configurationFileAccessor.fetch)();

// Retrieves the configuration stanza accessor
// Fetchs the configuration stanza accessor
let configurationStanzaAccessor = getConfigurationFileStanza(
configurationFileAccessor,
stanzaName
Expand All @@ -146,17 +146,17 @@ export async function getConfigurationStanzaValue(
propertyName: string,
defaultValue: string
): Promise<string> {
// Retrieve the accessor used to get a configuration file
// Fetch the accessor used to get a configuration file
let configurations = service.configurations({
// Name space information not provided
});
configurations = await promisify(configurations.fetch)();

// Retrieves the configuration file accessor
// Fetchs the configuration file accessor
let configurationFileAccessor = getConfigurationFile(configurations, configurationFilename);
configurationFileAccessor = await promisify(configurationFileAccessor.fetch)();

// Retrieves the configuration stanza accessor
// Fetchs the configuration stanza accessor
let configurationStanzaAccessor = getConfigurationFileStanza(
configurationFileAccessor,
stanzaName
Expand Down
36 changes: 18 additions & 18 deletions packages/configuration-screen/src/utils/setupConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ function createService(): SplunkService {
return service;
}

function retrieveUserTenants(
function fetchUserTenants(
apiKey: string,
successCallback: (userTenants: Array<Tenant>) => void,
errorCallback: (errorMessage: string) => void
): void {
const service = createService();
const data = { apiKey };
service.post('/services/retrieve_user_tenants', data, (err, response) => {
service.post('/services/fetch_user_tenants', data, (err, response) => {
if (err) {
errorCallback(err.data);
} else if (response.status === 200) {
Expand Down Expand Up @@ -117,7 +117,7 @@ async function saveConfiguration(
await reloadApp(service);
}

async function retrievePassword(passwordKey: string): Promise<string> {
async function fetchPassword(passwordKey: string): Promise<string> {
const service = createService();
const storagePasswords = await promisify(service.storagePasswords().fetch)();
const passwordId = `${storageRealm}:${passwordKey}:`;
Expand All @@ -130,12 +130,12 @@ async function retrievePassword(passwordKey: string): Promise<string> {
return '';
}

async function retrieveApiKey(): Promise<string> {
return retrievePassword(PasswordKeys.API_KEY);
async function fetchApiKey(): Promise<string> {
return fetchPassword(PasswordKeys.API_KEY);
}

async function retrieveTenantId(): Promise<number> {
return retrievePassword(PasswordKeys.TENANT_ID).then((tenantId) => {
async function fetchTenantId(): Promise<number> {
return fetchPassword(PasswordKeys.TENANT_ID).then((tenantId) => {
if (tenantId !== '') {
return parseInt(tenantId, 10);
}
Expand All @@ -144,8 +144,8 @@ async function retrieveTenantId(): Promise<number> {
});
}

async function retrieveIngestMetadataOnly(): Promise<boolean> {
return retrievePassword(PasswordKeys.INGEST_METADATA_ONLY).then((isIngestingMetadataOnly) => {
async function fetchIngestMetadataOnly(): Promise<boolean> {
return fetchPassword(PasswordKeys.INGEST_METADATA_ONLY).then((isIngestingMetadataOnly) => {
if (isIngestingMetadataOnly !== '') {
return isIngestingMetadataOnly === 'true';
}
Expand All @@ -165,7 +165,7 @@ async function createFlareIndex(): Promise<void> {
'unknown'
)) === '1';
if (!isConfigured) {
const currentIndexNames = await retrieveAvailableIndexNames();
const currentIndexNames = await fetchAvailableIndexNames();
if (!currentIndexNames.find((indexName) => indexName === appName)) {
await service.indexes().create(appName, {});
}
Expand All @@ -183,7 +183,7 @@ async function saveIndexForIngestion(service: SplunkService, indexName: string):
);
}

async function retrieveAvailableIndexNames(): Promise<Array<string>> {
async function fetchAvailableIndexNames(): Promise<Array<string>> {
const service = createService();
const indexes = await promisify(service.indexes().fetch)();
const indexNames: string[] = [];
Expand All @@ -196,7 +196,7 @@ async function retrieveAvailableIndexNames(): Promise<Array<string>> {
return indexNames;
}

async function retrieveCurrentIndexName(): Promise<string> {
async function fetchCurrentIndexName(): Promise<string> {
const service = createService();
return getConfigurationStanzaValue(
service,
Expand All @@ -209,14 +209,14 @@ async function retrieveCurrentIndexName(): Promise<string> {

export {
saveConfiguration,
retrieveUserTenants,
retrieveApiKey,
retrieveTenantId,
retrieveIngestMetadataOnly,
fetchUserTenants,
fetchApiKey,
fetchTenantId,
fetchIngestMetadataOnly,
redirectToHomepage,
getRedirectUrl,
getFlareDataUrl,
createFlareIndex,
retrieveAvailableIndexNames,
retrieveCurrentIndexName,
fetchAvailableIndexNames,
fetchCurrentIndexName,
};
8 changes: 4 additions & 4 deletions packages/flare/bin/cron_job_ingest_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main(logger: Logger, app: client.Application) -> None:
ingest_metadata_only = get_ingest_metadata_only(app=app)

save_last_fetched(app=app)
events_retrieved_count = 0
events_fetchd_count = 0
for event, next_token in fetch_feed(
logger=logger,
app=app,
Expand All @@ -57,9 +57,9 @@ def main(logger: Logger, app: client.Application) -> None:

print(json.dumps(event), flush=True)

events_retrieved_count += 1
events_fetchd_count += 1

logger.info(f"Retrieved {events_retrieved_count} events")
logger.info(f"Fetchd {events_fetchd_count} events")


def get_storage_password_value(
Expand Down Expand Up @@ -231,7 +231,7 @@ def fetch_feed(
next = get_next(app=app, tenant_id=tenant_id)
start_date = get_start_date(app=app)
logger.info(f"Fetching {tenant_id=}, {next=}, {start_date=}")
for event_next in flare_api.retrieve_feed_events(
for event_next in flare_api.fetch_feed_events(
next=next, start_date=start_date, ingest_metadata_only=ingest_metadata_only
):
yield event_next
Expand Down
12 changes: 6 additions & 6 deletions packages/flare/bin/flare.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def __init__(self, *, api_key: str, tenant_id: Optional[int] = None) -> None:
)
self.logger = Logger(class_name=__file__)

def retrieve_feed_events(
def fetch_feed_events(
self,
*,
next: Optional[str] = None,
start_date: Optional[date] = None,
ingest_metadata_only: bool,
) -> Iterator[tuple[dict, str]]:
for response in self._retrieve_event_feed_metadata(
for response in self._fetch_event_feed_metadata(
next=next,
start_date=start_date,
):
Expand All @@ -60,13 +60,13 @@ def retrieve_feed_events(
next_token = event_feed["next"]
for event in event_feed["items"]:
if not ingest_metadata_only:
event = self._retrieve_full_event_from_uid(
event = self._fetch_full_event_from_uid(
uid=event["metadata"]["uid"]
)
time.sleep(1)
yield (event, next_token)

def _retrieve_event_feed_metadata(
def _fetch_event_feed_metadata(
self,
*,
next: Optional[str] = None,
Expand All @@ -92,13 +92,13 @@ def _retrieve_event_feed_metadata(
# Rate limiting.
time.sleep(1)

def _retrieve_full_event_from_uid(self, *, uid: str) -> dict:
def _fetch_full_event_from_uid(self, *, uid: str) -> dict:
event_response = self.flare_client.get(url=f"/firework/v2/activities/{uid}")
event = event_response.json()["activity"]
self.logger.debug(event)
return event

def retrieve_tenants(self) -> requests.Response:
def fetch_tenants(self) -> requests.Response:
return self.flare_client.get(
url="/firework/v2/me/tenants",
)
2 changes: 1 addition & 1 deletion packages/flare/bin/flare_external_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def handle_POST(self) -> None:

if "apiKey" in params:
flare_api = FlareAPI(api_key=params["apiKey"][0])
user_tenants_response = flare_api.retrieve_tenants()
user_tenants_response = flare_api.fetch_tenants()
tenants_response = user_tenants_response.json()
logger.debug(tenants_response)
self.response.setHeader("Content-Type", "application/json")
Expand Down
4 changes: 2 additions & 2 deletions packages/flare/src/main/resources/splunk/default/restmap.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[script:flare_external_requests_user_tenants]
match=/retrieve_user_tenants
match=/fetch_user_tenants
handler=flare_external_requests.FlareUserTenants
python.version = python3
python.version = python3
4 changes: 2 additions & 2 deletions packages/flare/src/main/resources/splunk/default/web.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[expose:flare_external_requests_user_tenants]
pattern=retrieve_user_tenants
methods=POST
pattern=fetch_user_tenants
methods=POST
Loading

0 comments on commit b4e1009

Please sign in to comment.