Skip to content

Commit

Permalink
avoid circular deps caused within api.api.v1 (#3692)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsachs authored Jun 30, 2023
1 parent f63a843 commit 1594e81
Show file tree
Hide file tree
Showing 80 changed files with 322 additions and 324 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The types of changes are:
- Render linebreaks in the Fides.js overlay descriptions, etc. [#3665](https://github.com/ethyca/fides/pull/3665)
- Broken link to Fides docs site on the About Fides page in Admin UI [#3643](https://github.com/ethyca/fides/pull/3643)
- Add Systems Applicable Filter to Privacy Experience List [#3654](https://github.com/ethyca/fides/pull/3654)
- Reorganized some `api.api.v1` code to avoid circular dependencies on `quickstart` [#3692](https://github.com/ethyca/fides/pull/3692)

### Developer Experience

Expand Down
2 changes: 1 addition & 1 deletion docs/fides/docs/development/development_tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ If you're looking for a general getting started guide, please see the [Overview]

### API URLs

We define API URLs for specific API versions as constants within `fides.api.api.v1.urn_registry` (where `v1` can be substituted for that particular API version), then import those URLs into their specific API views. Since we are on the first version, there is no clear precedent set for overriding URLs between versions yet. The most likely change is that we'll override the `APIRouter` class instantiation with a different base path (ie. `/api/v2` instead of `/api/v1`). For example:
We define API URLs for specific API versions as constants within `fides.common.api.v1.urn_registry` (where `v1` can be substituted for that particular API version), then import those URLs into their specific API views. Since we are on the first version, there is no clear precedent set for overriding URLs between versions yet. The most likely change is that we'll override the `APIRouter` class instantiation with a different base path (ie. `/api/v2` instead of `/api/v1`). For example:

```sh
PRIVACY_REQUEST = "/privacy-request"
Expand Down
2 changes: 1 addition & 1 deletion scripts/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import yaml
from loguru import logger

from fides.api.api.v1 import urn_registry as ops_urls
from fides.api.models.connectionconfig import ConnectionType
from fides.api.models.policy import ActionType
from fides.common.api.scope_registry import SCOPE_REGISTRY
from fides.common.api.v1 import urn_registry as ops_urls
from fides.config import get_config

CONFIG = get_config()
Expand Down
2 changes: 1 addition & 1 deletion src/fides/api/api/v1/endpoints/config_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from starlette.status import HTTP_200_OK

from fides.api.api import deps
from fides.api.api.v1 import urn_registry as urls
from fides.api.models.application_config import ApplicationConfig
from fides.api.oauth.utils import verify_oauth_client
from fides.api.schemas.application_config import (
ApplicationConfig as ApplicationConfigSchema,
)
from fides.api.util.api_router import APIRouter
from fides.common.api import scope_registry as scopes
from fides.common.api.v1 import urn_registry as urls
from fides.config import censor_config
from fides.config import get_config as get_app_config

Expand Down
16 changes: 8 additions & 8 deletions src/fides/api/api/v1/endpoints/connection_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,14 @@
from starlette.status import HTTP_200_OK, HTTP_204_NO_CONTENT, HTTP_404_NOT_FOUND

from fides.api.api import deps
from fides.api.api.v1.urn_registry import (
CONNECTION_BY_KEY,
CONNECTION_SECRETS,
CONNECTION_TEST,
CONNECTIONS,
V1_URL_PREFIX,
)
from fides.api.common_exceptions import ClientUnsuccessfulException, ConnectionException
from fides.api.models.connectionconfig import (
ConnectionConfig,
ConnectionTestStatus,
ConnectionType,
)
from fides.api.models.datasetconfig import DatasetConfig
from fides.api.models.sql_models import ( # type: ignore[attr-defined]
from fides.api.models.sql_models import ( # type: ignore[attr-defined]
Dataset as CtlDataset,
)
from fides.api.oauth.utils import verify_oauth_client
Expand Down Expand Up @@ -58,6 +51,13 @@
CONNECTION_DELETE,
CONNECTION_READ,
)
from fides.common.api.v1.urn_registry import (
CONNECTION_BY_KEY,
CONNECTION_SECRETS,
CONNECTION_TEST,
CONNECTIONS,
V1_URL_PREFIX,
)

router = APIRouter(tags=["Connections"], prefix=V1_URL_PREFIX)

Expand Down
10 changes: 5 additions & 5 deletions src/fides/api/api/v1/endpoints/connection_type_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
from fastapi_pagination.bases import AbstractPage
from starlette.status import HTTP_404_NOT_FOUND

from fides.api.api.v1.urn_registry import (
CONNECTION_TYPE_SECRETS,
CONNECTION_TYPES,
V1_URL_PREFIX,
)
from fides.api.common_exceptions import NoSuchConnectionTypeSecretSchemaError
from fides.api.oauth.utils import verify_oauth_client
from fides.api.schemas.connection_configuration.connection_config import (
Expand All @@ -24,6 +19,11 @@
get_connection_types,
)
from fides.common.api.scope_registry import CONNECTION_TYPE_READ
from fides.common.api.v1.urn_registry import (
CONNECTION_TYPE_SECRETS,
CONNECTION_TYPES,
V1_URL_PREFIX,
)

router = APIRouter(tags=["Connection Types"], prefix=V1_URL_PREFIX)

Expand Down
16 changes: 8 additions & 8 deletions src/fides/api/api/v1/endpoints/consent_request_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@
from fides.api.api.v1.endpoints.privacy_request_endpoints import (
create_privacy_request_func,
)
from fides.api.api.v1.endpoints.utils import validate_start_and_end_filters
from fides.api.api.v1.urn_registry import (
CONSENT_REQUEST,
CONSENT_REQUEST_PREFERENCES,
CONSENT_REQUEST_PREFERENCES_WITH_ID,
CONSENT_REQUEST_VERIFY,
V1_URL_PREFIX,
)
from fides.api.common_exceptions import (
FunctionalityNotConfigured,
IdentityVerificationException,
Expand Down Expand Up @@ -66,8 +58,16 @@
from fides.api.util.consent_util import (
get_or_create_fides_user_device_id_provided_identity,
)
from fides.api.util.endpoint_utils import validate_start_and_end_filters
from fides.api.util.logger import Pii
from fides.common.api.scope_registry import CONSENT_READ
from fides.common.api.v1.urn_registry import (
CONSENT_REQUEST,
CONSENT_REQUEST_PREFERENCES,
CONSENT_REQUEST_PREFERENCES_WITH_ID,
CONSENT_REQUEST_VERIFY,
V1_URL_PREFIX,
)
from fides.config import CONFIG
from fides.config.config_proxy import ConfigProxy

Expand Down
22 changes: 11 additions & 11 deletions src/fides/api/api/v1/endpoints/dataset_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@
)

from fides.api.api import deps
from fides.api.api.v1.urn_registry import (
CONNECTION_DATASETS,
DATASET_BY_KEY,
DATASET_CONFIGS,
DATASET_VALIDATE,
DATASETCONFIG_BY_KEY,
DATASETS,
V1_URL_PREFIX,
YAML_DATASETS,
)
from fides.api.common_exceptions import (
SaaSConfigNotFoundException,
TraversalError,
Expand All @@ -47,7 +37,7 @@
convert_dataset_to_graph,
to_graph_field,
)
from fides.api.models.sql_models import ( # type: ignore[attr-defined]
from fides.api.models.sql_models import ( # type: ignore[attr-defined]
Dataset as CtlDataset,
)
from fides.api.oauth.utils import verify_oauth_client
Expand All @@ -68,6 +58,16 @@
DATASET_DELETE,
DATASET_READ,
)
from fides.common.api.v1.urn_registry import (
CONNECTION_DATASETS,
DATASET_BY_KEY,
DATASET_CONFIGS,
DATASET_VALIDATE,
DATASETCONFIG_BY_KEY,
DATASETS,
V1_URL_PREFIX,
YAML_DATASETS,
)

X_YAML = "application/x-yaml"

Expand Down
2 changes: 1 addition & 1 deletion src/fides/api/api/v1/endpoints/drp_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from fides.api import common_exceptions
from fides.api.api import deps
from fides.api.api.v1 import urn_registry as urls
from fides.api.api.v1.endpoints.privacy_request_endpoints import (
get_privacy_request_or_error,
)
Expand Down Expand Up @@ -47,6 +46,7 @@
from fides.api.util.cache import FidesopsRedis
from fides.api.util.logger import Pii
from fides.common.api import scope_registry as scopes
from fides.common.api.v1 import urn_registry as urls
from fides.config import CONFIG
from fides.config.config_proxy import ConfigProxy

Expand Down
12 changes: 6 additions & 6 deletions src/fides/api/api/v1/endpoints/encryption_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
from fastapi import Security
from loguru import logger

from fides.api.api.v1.urn_registry import (
DECRYPT_AES,
ENCRYPT_AES,
ENCRYPTION_KEY,
V1_URL_PREFIX,
)
from fides.api.cryptography import cryptographic_util
from fides.api.cryptography.cryptographic_util import b64_str_to_bytes, bytes_to_b64_str
from fides.api.oauth.utils import verify_oauth_client
Expand All @@ -26,6 +20,12 @@
encrypt_verify_secret_length as aes_gcm_encrypt,
)
from fides.common.api.scope_registry import ENCRYPTION_EXEC
from fides.common.api.v1.urn_registry import (
DECRYPT_AES,
ENCRYPT_AES,
ENCRYPTION_KEY,
V1_URL_PREFIX,
)
from fides.config import CONFIG

router = APIRouter(tags=["Encryption"], prefix=V1_URL_PREFIX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from sqlalchemy.orm import Session

from fides.api.api import deps
from fides.api.api.v1 import urn_registry as urls
from fides.api.models.messaging import MessagingConfig
from fides.api.schemas.identity_verification import IdentityVerificationConfigResponse
from fides.api.util.api_router import APIRouter
from fides.common.api.v1 import urn_registry as urls
from fides.config.config_proxy import ConfigProxy

router = APIRouter(tags=["Identity Verification"], prefix=urls.V1_URL_PREFIX)
Expand Down
10 changes: 5 additions & 5 deletions src/fides/api/api/v1/endpoints/manual_webhook_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@

from fides.api.api import deps
from fides.api.api.v1.endpoints.dataset_endpoints import _get_connection_config
from fides.api.api.v1.urn_registry import (
ACCESS_MANUAL_WEBHOOK,
ACCESS_MANUAL_WEBHOOKS,
V1_URL_PREFIX,
)
from fides.api.models.connectionconfig import ConnectionConfig, ConnectionType
from fides.api.models.manual_webhook import AccessManualWebhook
from fides.api.oauth.utils import verify_oauth_client
Expand All @@ -35,6 +30,11 @@
WEBHOOK_DELETE,
WEBHOOK_READ,
)
from fides.common.api.v1.urn_registry import (
ACCESS_MANUAL_WEBHOOK,
ACCESS_MANUAL_WEBHOOKS,
V1_URL_PREFIX,
)

router = APIRouter(tags=["Manual Webhooks"], prefix=V1_URL_PREFIX)

Expand Down
2 changes: 1 addition & 1 deletion src/fides/api/api/v1/endpoints/masking_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from loguru import logger
from starlette.status import HTTP_400_BAD_REQUEST, HTTP_404_NOT_FOUND

from fides.api.api.v1.urn_registry import MASKING, MASKING_STRATEGY, V1_URL_PREFIX
from fides.api.common_exceptions import NoSuchStrategyException, ValidationError
from fides.api.oauth.utils import verify_oauth_client_prod
from fides.api.schemas.masking.masking_api import MaskingAPIRequest, MaskingAPIResponse
Expand All @@ -15,6 +14,7 @@
from fides.api.service.masking.strategy.masking_strategy import MaskingStrategy
from fides.api.util.api_router import APIRouter
from fides.common.api.scope_registry import MASKING_EXEC, MASKING_READ
from fides.common.api.v1.urn_registry import MASKING, MASKING_STRATEGY, V1_URL_PREFIX

router = APIRouter(tags=["Masking"], prefix=V1_URL_PREFIX)

Expand Down
24 changes: 12 additions & 12 deletions src/fides/api/api/v1/endpoints/messaging_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@
)

from fides.api.api import deps
from fides.api.api.v1.urn_registry import (
MESSAGING_ACTIVE_DEFAULT,
MESSAGING_BY_KEY,
MESSAGING_CONFIG,
MESSAGING_DEFAULT,
MESSAGING_DEFAULT_BY_TYPE,
MESSAGING_DEFAULT_SECRETS,
MESSAGING_SECRETS,
MESSAGING_STATUS,
MESSAGING_TEST,
V1_URL_PREFIX,
)
from fides.api.common_exceptions import (
MessageDispatchException,
MessagingConfigNotFoundException,
Expand Down Expand Up @@ -69,6 +57,18 @@
MESSAGING_DELETE,
MESSAGING_READ,
)
from fides.common.api.v1.urn_registry import (
MESSAGING_ACTIVE_DEFAULT,
MESSAGING_BY_KEY,
MESSAGING_CONFIG,
MESSAGING_DEFAULT,
MESSAGING_DEFAULT_BY_TYPE,
MESSAGING_DEFAULT_SECRETS,
MESSAGING_SECRETS,
MESSAGING_STATUS,
MESSAGING_TEST,
V1_URL_PREFIX,
)
from fides.config.config_proxy import ConfigProxy

router = APIRouter(tags=["Messaging"], prefix=V1_URL_PREFIX)
Expand Down
20 changes: 10 additions & 10 deletions src/fides/api/api/v1/endpoints/oauth_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
from fides.api.api.v1.endpoints.saas_config_endpoints import (
verify_oauth_connection_config,
)
from fides.api.api.v1.urn_registry import (
CLIENT,
CLIENT_BY_ID,
CLIENT_SCOPE,
OAUTH_CALLBACK,
ROLE,
SCOPE,
TOKEN,
V1_URL_PREFIX,
)
from fides.api.common_exceptions import (
AuthenticationFailure,
FidesopsException,
Expand Down Expand Up @@ -52,6 +42,16 @@
SCOPE_REGISTRY,
ScopeRegistryEnum,
)
from fides.common.api.v1.urn_registry import (
CLIENT,
CLIENT_BY_ID,
CLIENT_SCOPE,
OAUTH_CALLBACK,
ROLE,
SCOPE,
TOKEN,
V1_URL_PREFIX,
)
from fides.config import CONFIG

router = APIRouter(tags=["OAuth"], prefix=V1_URL_PREFIX)
Expand Down
2 changes: 1 addition & 1 deletion src/fides/api/api/v1/endpoints/policy_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
)

from fides.api.api import deps
from fides.api.api.v1 import urn_registry as urls
from fides.api.common_exceptions import (
DataCategoryNotSupported,
DrpActionValidationError,
Expand All @@ -38,6 +37,7 @@
from fides.api.util.api_router import APIRouter
from fides.api.util.logger import Pii
from fides.common.api import scope_registry
from fides.common.api.v1 import urn_registry as urls

router = APIRouter(tags=["DSR Policy"], prefix=urls.V1_URL_PREFIX)

Expand Down
2 changes: 1 addition & 1 deletion src/fides/api/api/v1/endpoints/policy_webhook_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from starlette.status import HTTP_200_OK, HTTP_400_BAD_REQUEST, HTTP_404_NOT_FOUND

from fides.api.api import deps
from fides.api.api.v1 import urn_registry as urls
from fides.api.api.v1.endpoints.connection_endpoints import (
get_connection_config_or_error,
)
Expand All @@ -30,6 +29,7 @@
from fides.api.schemas.policy_webhooks import PolicyWebhookDeleteResponse
from fides.api.util.api_router import APIRouter
from fides.common.api import scope_registry as scopes
from fides.common.api.v1 import urn_registry as urls

router = APIRouter(tags=["DSR Policy Webhooks"], prefix=urls.V1_URL_PREFIX)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
)

from fides.api.api import deps
from fides.api.api.v1 import urn_registry as urls
from fides.api.api.v1.endpoints.utils import human_friendly_list, transform_fields
from fides.api.models.privacy_experience import (
ComponentType,
PrivacyExperience,
Expand All @@ -37,8 +35,10 @@
PRIVACY_EXPERIENCE_ESCAPE_FIELDS,
UNESCAPE_SAFESTR_HEADER,
)
from fides.api.util.endpoint_utils import human_friendly_list, transform_fields
from fides.common.api import scope_registry
from fides.common.api.scope_registry import PRIVACY_EXPERIENCE_UPDATE
from fides.common.api.v1 import urn_registry as urls

router = APIRouter(tags=["Privacy Experience Config"], prefix=urls.V1_URL_PREFIX)

Expand Down
Loading

0 comments on commit 1594e81

Please sign in to comment.