Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move fidesapi -> fidesctl/api #885

Merged
merged 11 commits into from
Jul 14, 2022
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fidesapi/src/main/resources/application.conf
fidesctl/api/src/main/resources/application.conf
docs/fides/docs/api/openapi.json
docs/fides/docs/schemas/config_schema.json
fidesapi/build/static
fidesctl/api/build/static

## generic files to ignore
*~
Expand Down
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ The types of changes are:
### Changed

* Updated the `datamap` endpoint to return human-readable column names as the first response item [#779](https://github.com/ethyca/fides/pull/779)
* Remove the `obscure` requirement from the `generate` endpoint [#819](https://github.com/ethyca/fides/pull/819)
* Moved all files from `fidesapi` to `fidesctl/api` [#885](https://github.com/ethyca/fides/pull/885)
* Webserver dependencies now come as a standard part of the package [#881](https://github.com/ethyca/fides/pull/881)
* Initial configuration wizard UI view
* Refactored step & form results management to use Redux Toolkit slice.
Expand All @@ -48,10 +50,6 @@ The types of changes are:
* Datasets without the `third_country_transfer` will not cause the editing dataset form to not render.
* Fixed a build issue causing an `unknown` version of `fidesctl` to be installed in published Docker images [#836](https://github.com/ethyca/fides/pull/836)

### Changed

* Remove the `obscure` requirement from the `generate` endpoint [#819](https://github.com/ethyca/fides/pull/819)

## [1.7.0](https://github.com/ethyca/fides/compare/1.6.1...1.7.0) - 2022-06-23

### Added
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ENV PYTHONUNBUFFERED=TRUE
ENV RUNNING_IN_DOCKER=TRUE

# Make a static files directory
RUN mkdir -p src/fidesapi/build/static
RUN mkdir -p src/fidesctl/api/build/static

EXPOSE 8080
CMD ["fidesctl", "webserver"]
Expand All @@ -116,4 +116,4 @@ RUN python setup.py sdist
RUN pip install dist/fidesctl-*.tar.gz

# Copy frontend build over
COPY --from=frontend /fides/clients/admin-ui/out/ /fides/src/fidesapi/build/static/
COPY --from=frontend /fides/clients/admin-ui/out/ /fides/src/fidesctl/api/build/static/
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
include LICENSE
include README.md
ThomasLaPiana marked this conversation as resolved.
Show resolved Hide resolved
include requirements.txt
include dev-requirements.txt
include versioneer.py
include src/fidesapi/alembic.ini
include src/fidesctl/_version.py
include src/fidesctl/api/alembic.ini
include src/fidesctl/templates/fides_datamap_template.xlsx
2 changes: 1 addition & 1 deletion clients/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"analyze:server": "cross-env BUNDLE_ANALYZE=server next build",
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
"export": "next build && next export",
"copy-export": "rsync -a --delete out/ ../../src/fidesapi/build/static/",
"copy-export": "rsync -a --delete out/ ../../src/fidesctl/api/build/static/",
"prod-export": "npm run export && npm run copy-export",
"cy:open": "cypress open",
"cy:run": "cypress run",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
fidesctl:
image: ethyca/fidesctl:local
command: uvicorn --host 0.0.0.0 --port 8080 --reload fidesapi.main:app
command: uvicorn --host 0.0.0.0 --port 8080 --reload fidesctl.api.main:app
healthcheck:
test:
[
Expand Down
8 changes: 5 additions & 3 deletions docs/fides/docs/development/database_migration.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Database Migration

---

Changes to fidesctl could require a change to the database model. This includes scenarios where you want to persist a new field or replace an existing field. Changes made to the fidesctl database are done through alembic migration scripts. Migrations can be found in the following direcotry: `fidesctl/src/fidesapi/migrations/versions`
Changes to fidesctl could require a change to the database model. This includes scenarios where you want to persist a new field or replace an existing field. Changes made to the fidesctl database are done through alembic migration scripts. Migrations can be found in the following direcotry: `fidesctl/src/fidesctl/api/migrations/versions`

To create a new migration we use the `alembic revision` command:

```bash
cd fidesctl/src/fidesapi
cd fidesctl/src/fidesctl/api
alembic revision --autogenerate -m "migration message"
```

The autogenerated script should be verified and could require some manual changes. Migrations will run on the fidesctl server startup.
The autogenerated script should be verified and could require some manual changes. Migrations will run on the fidesctl server startup.
9 changes: 5 additions & 4 deletions generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
import json
import sys

from fidesapi.main import app
from fidesctl.api.main import app


def generate_openapi(outfile_dir: str) -> None:
"Write out an openapi.json file for the API."

outfile_name = "api/openapi.json"
outfile_path = f"{outfile_dir}/{outfile_name}"
print(f"Generating OpenAPI JSON from fidesapi and writing to '{outfile_path}'...")
print(f"Generating OpenAPI JSON from the API and writing to '{outfile_path}'...")
with open(outfile_path, "w") as outfile:
json.dump(app.openapi(), outfile, indent=2)
print(f"Exported OpenAPI JSON from fidesapi to '{outfile_path}'")
print(f"Exported OpenAPI JSON from the API to '{outfile_path}'")


if __name__ == "__main__":
outfile_dir = sys.argv[1]
generate_openapi(outfile_dir)
generate_openapi(outfile_dir)
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
python_requires=">=3.8, <4",
package_dir={"": "src"},
packages=find_packages(where="src"),
package_data={"fidesapi": ["alembic.ini"]},
include_package_data=True,
author="Ethyca, Inc.",
author_email="[email protected]",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.future import select

from fidesapi.database.session import async_session
from fidesapi.sql_models import SqlAlchemyBase
from fidesapi.utils import errors
from fidesctl.api.database.session import async_session
from fidesctl.api.sql_models import SqlAlchemyBase
from fidesctl.api.utils import errors


# CRUD Functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from sqlalchemy import create_engine
from sqlalchemy_utils.functions import create_database, database_exists

from fidesapi.sql_models import SqlAlchemyBase, sql_model_map
from fidesapi.utils.errors import (
from fidesctl.api.sql_models import SqlAlchemyBase, sql_model_map
from fidesctl.api.utils.errors import (
AlreadyExistsError,
QueryError,
get_full_exception_name,
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions src/fidesapi/main.py → src/fidesctl/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from uvicorn import Config, Server

import fidesctl
from fidesapi import view
from fidesapi.database import database
from fidesapi.database.database import get_db_health
from fidesapi.routes import crud, datamap, generate, validate, visualize
from fidesapi.routes.util import API_PREFIX, WEBAPP_DIRECTORY, WEBAPP_INDEX
from fidesapi.utils.errors import get_full_exception_name
from fidesapi.utils.logger import setup as setup_logging
from fidesctl.api import view
from fidesctl.api.database import database
from fidesctl.api.database.database import get_db_health
from fidesctl.api.routes import crud, datamap, generate, validate, visualize
from fidesctl.api.routes.util import API_PREFIX, WEBAPP_DIRECTORY, WEBAPP_INDEX
from fidesctl.api.utils.errors import get_full_exception_name
from fidesctl.api.utils.logger import setup as setup_logging
from fidesctl.core.config import FidesctlConfig, get_config

app = FastAPI(title="fidesctl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from alembic import context
from sqlalchemy import engine_from_config, pool

from fidesapi.utils.logger import setup as setup_fidesapi_logger
from fidesctl.api.utils.logger import setup as setup_fidesapi_logger
from fidesctl.core.config import get_config

# this is the Alembic Config object, which provides
Expand All @@ -24,7 +24,7 @@
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from fidesapi.sql_models import SqlAlchemyBase
from fidesctl.api.sql_models import SqlAlchemyBase

target_metadata = SqlAlchemyBase.metadata

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from alembic import op
from sqlalchemy import Column, DateTime, text

from fidesapi.sql_models import sql_model_map
from fidesctl.api.sql_models import sql_model_map

# revision identifiers, used by Alembic.
revision = "7c851d8a102a"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
from fastapi import APIRouter, Response, status
from fideslang import model_map

from fidesapi.database.crud import (
from fidesctl.api.database.crud import (
create_resource,
delete_resource,
get_resource,
list_resource,
update_resource,
upsert_resources,
)
from fidesapi.routes.util import API_PREFIX, get_resource_type
from fidesapi.sql_models import sql_model_map
from fidesctl.api.routes.util import API_PREFIX, get_resource_type
from fidesctl.api.sql_models import sql_model_map

# CRUD Endpoints
routers = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from loguru import logger as log
from pandas import DataFrame

from fidesapi.routes.crud import get_resource, list_resource
from fidesapi.routes.util import API_PREFIX
from fidesapi.sql_models import sql_model_map
from fidesapi.utils.errors import DatabaseUnavailableError, NotFoundError
from fidesctl.api.routes.crud import get_resource, list_resource
from fidesctl.api.routes.util import API_PREFIX
from fidesctl.api.sql_models import sql_model_map
from fidesctl.api.utils.errors import DatabaseUnavailableError, NotFoundError
from fidesctl.core.export import build_joined_dataframe
from fidesctl.core.export_helpers import DATAMAP_COLUMNS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from loguru import logger as log
from pydantic import BaseModel, root_validator

from fidesapi.routes.crud import get_resource
from fidesapi.routes.util import (
from fidesctl.api.routes.crud import get_resource
from fidesctl.api.routes.util import (
API_PREFIX,
route_requires_aws_connector,
route_requires_okta_connector,
)
from fidesapi.sql_models import sql_model_map
from fidesctl.api.sql_models import sql_model_map
from fidesctl.connectors.models import (
AWSConfig,
ConnectorAuthFailureException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fidesctl.core.utils import API_PREFIX as _API_PREFIX

API_PREFIX = _API_PREFIX
WEBAPP_DIRECTORY = Path("src/fidesapi/build/static")
WEBAPP_DIRECTORY = Path("src/fidesctl/api/build/static")
WEBAPP_INDEX = WEBAPP_DIRECTORY / "index.html"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fastapi import APIRouter, Response, status
from pydantic import BaseModel

from fidesapi.routes.util import (
from fidesctl.api.routes.util import (
API_PREFIX,
route_requires_aws_connector,
route_requires_okta_connector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from fastapi.responses import HTMLResponse
from fideslang import model_map

from fidesapi.routes.crud import list_resource
from fidesapi.routes.util import API_PREFIX, get_resource_type
from fidesapi.sql_models import sql_model_map
from fidesctl.api.routes.crud import list_resource
from fidesctl.api.routes.util import API_PREFIX, get_resource_type
from fidesctl.api.sql_models import sql_model_map
from fidesctl.core import visualize

# pylint: disable=redefined-outer-name,cell-var-from-loop
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Defines the logging format to be used throughout the fidesapi server code.
Defines the logging format to be used throughout the API server code.
"""
# pylint: disable=eval-used,no-member

Expand All @@ -13,7 +13,7 @@

class FidesAPIHandler(logging.Handler):
"""
The logging.Handler used by the fidesapi logger.
The logging.Handler used by the api logger.
"""

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions src/fidesapi/view.py → src/fidesctl/api/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from fastapi import APIRouter
from fastapi.responses import HTMLResponse

from fidesapi.routes.crud import list_resource
from fidesapi.sql_models import Evaluation
from fidesctl.api.routes.crud import list_resource
from fidesctl.api.sql_models import Evaluation

router = APIRouter(
tags=["View"],
Expand Down
2 changes: 1 addition & 1 deletion src/fidesctl/cli/commands/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ def webserver(ctx: click.Context) -> None:
Starts the fidesctl API server using Uvicorn on port 8080.
"""
# This has to be here to avoid a circular dependency
from fidesapi.main import start_webserver
from fidesctl.api.main import start_webserver

start_webserver()
2 changes: 1 addition & 1 deletion src/fidesctl/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
echo_red = partial(click.secho, fg="red", bold=True)
echo_green = partial(click.secho, fg="green", bold=True)

# This duplicates a constant in `fidesapi/routes/utils.py`
# This duplicates a constant in `fidesctl/api/routes/utils.py`
# To avoid import errors
API_PREFIX = "/api/v1"

Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_datamap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from starlette.testclient import TestClient

from fidesapi.routes.util import API_PREFIX
from fidesctl.api.routes.util import API_PREFIX
from fidesctl.core.config import FidesctlConfig


Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pytest
from starlette.testclient import TestClient

from fidesapi.routes.generate import GenerateResponse
from fidesapi.routes.util import API_PREFIX
from fidesctl.api.routes.generate import GenerateResponse
from fidesctl.api.routes.util import API_PREFIX
from fidesctl.core.config import FidesctlConfig

EXTERNAL_CONFIG_BODY = {
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pytest
from starlette.testclient import TestClient

from fidesapi.routes.util import API_PREFIX
from fidesapi.routes.validate import ValidateResponse
from fidesctl.api.routes.util import API_PREFIX
from fidesctl.api.routes.validate import ValidateResponse
from fidesctl.core.config import FidesctlConfig

EXTERNAL_CONFIG_BODY = {
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_webserver() -> None:
This is specifically meant to catch when the webserver command breaks,
without spinning up an additional instance.
"""
from fidesapi.main import start_webserver # pylint: disable=unused-import
from fidesctl.api.main import start_webserver # pylint: disable=unused-import

assert True

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from fideslang import models
from starlette.testclient import TestClient

from fidesapi import main
from fidesctl.api import main
from fidesctl.core import api
from fidesctl.core.config import FidesctlConfig, get_config

Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pytest import MonkeyPatch
from starlette.testclient import TestClient

from fidesapi import main
from fidesctl.api import main
from fidesctl.core import api as _api
from fidesctl.core.config import FidesctlConfig
from fidesctl.core.utils import API_PREFIX
Expand Down