-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* modify api_key_exists to return True * remove unused imports pylint * include env var usage option, handle published url, clean up comments * readme updates * revert server_url change, pylint updates after removing disabled checks * Code cleanup * Use the standard port 8080 Personal/development environments should be configured by overriding the server port with the `FIDESLOG__SERVER_PORT` environment variable. * Use the previously configured ENV variable names Also updates the expected GH secret names * Remove `ETHYCA_` prefix from secret names Secret names cannot be upated in the GH UI, they must be replaced. This is easier. * Ignore reused validators in pylint checks * Remove requirement for the API Key completely, update readme, improve route testing * remove api key authorization from the SDK * Include Snowflake secrets in pytest GH action * Minor README changes * Globally disable line-too-long * Organize imports * Log event creation errors to server logs * Code cleanup * Remove last remaining API key reference * Restore no-self-use pylint exception * add opt_out_copy to sdk utils Co-authored-by: Phil Salant <PSalant@gmail.com>
- Loading branch information
1 parent
a47b24f
commit 1fb830a
Showing
24 changed files
with
300 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export SNOWFLAKE_DB_USER=$SNOWFLAKE_DB_USER | ||
export SNOWFLAKE_DB_PASSWORD=$SNOWFLAKE_DB_PASSWORD | ||
|
||
export FIDESLOG__DATABASE_ACCOUNT=$SNOWFLAKE_ACCOUNT | ||
export FIDESLOG__DATABASE_PASSWORD=$SNOWFLAKE_DB_PASSWORD | ||
export FIDESLOG__DATABASE_USER=$SNOWFLAKE_DB_USER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,44 @@ | ||
import logging | ||
import json | ||
from json import dumps | ||
from logging import getLogger | ||
|
||
from sqlalchemy import select | ||
from sqlalchemy.orm import Session | ||
from sqlalchemy.exc import DBAPIError | ||
from sqlalchemy.orm import Session | ||
|
||
# from fidesapi.database.session import async_session ## future to do after working sync | ||
|
||
from fideslog.api.database.models import AnalyticsEvent as AnalyticsEventORM | ||
from fideslog.api.models.analytics_event import AnalyticsEvent | ||
|
||
from fideslog.api.database.models import AnalyticsEvent as AnalyticsEventORM | ||
from fideslog.api.database.models import APIKey | ||
log = getLogger(__name__) | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
# TODO: Finish this | ||
def create_event(database: Session, event: AnalyticsEvent) -> None: | ||
"""Create a new analytics event.""" | ||
|
||
try: | ||
log.debug("Creating resource") | ||
event_record = AnalyticsEventORM( | ||
client_id=event.client_id, | ||
product_name=event.product_name, | ||
production_version=event.production_version, | ||
os=event.os, | ||
docker=event.docker, | ||
resource_counts=json.dumps(event.resource_counts.dict()) | ||
if event.resource_counts | ||
else None, | ||
event=event.event, | ||
command=event.command, | ||
flags=", ".join(event.flags) if event.flags else None, | ||
endpoint=event.endpoint, | ||
status_code=event.status_code, | ||
error=event.error, | ||
local_host=event.local_host, | ||
extra_data=json.dumps(event.extra_data) if event.extra_data else None, | ||
event_created_at=event.event_created_at, | ||
extra_data = dumps(event.extra_data) if event.extra_data else None | ||
flags = ", ".join(event.flags) if event.flags else None | ||
resource_counts = ( | ||
dumps(event.resource_counts.dict()) if event.resource_counts else None | ||
) | ||
database.add( | ||
AnalyticsEventORM( | ||
client_id=event.client_id, | ||
command=event.command, | ||
docker=event.docker, | ||
endpoint=event.endpoint, | ||
error=event.error, | ||
event=event.event, | ||
event_created_at=event.event_created_at, | ||
extra_data=extra_data, | ||
flags=flags, | ||
local_host=event.local_host, | ||
os=event.os, | ||
product_name=event.product_name, | ||
production_version=event.production_version, | ||
resource_counts=resource_counts, | ||
status_code=event.status_code, | ||
) | ||
) | ||
database.add(event_record) | ||
database.commit() | ||
except DBAPIError: | ||
log.error("Insert Failed") | ||
|
||
|
||
def api_key_exists(database: Session, token: str) -> bool: | ||
""" | ||
Return whether the provided token exists in the database. | ||
""" | ||
|
||
return ( | ||
database.execute( | ||
select(APIKey).where(APIKey.api_key == token).limit(1), | ||
).first() | ||
is not None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.