-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Set base url for segment (#4684)
- Loading branch information
Showing
7 changed files
with
54 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DEFAULT_BASE_URL = "api.segment.io/" | ||
DUBLIN_BASE_URL = "events.eu1.segmentapis.com/" |
23 changes: 23 additions & 0 deletions
23
api/integrations/segment/migrations/0005_set_base_url_to_default.py
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.apps.registry import Apps | ||
from django.db import migrations | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
|
||
from integrations.segment import constants | ||
|
||
|
||
def set_base_url(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: | ||
SegmentConfiguration = apps.get_model("segment", "SegmentConfiguration") | ||
SegmentConfiguration.objects.filter(base_url__isnull=True).update( | ||
base_url=constants.DEFAULT_BASE_URL, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("segment", "0004_segmentconfiguration_deleted_at"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_base_url, reverse_code=migrations.RunPython.noop), | ||
] |
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,10 +1,23 @@ | ||
from rest_framework import serializers | ||
|
||
from integrations.common.serializers import ( | ||
BaseEnvironmentIntegrationModelSerializer, | ||
) | ||
from integrations.segment import constants | ||
from integrations.segment.models import SegmentConfiguration | ||
|
||
|
||
class SegmentConfigurationSerializer(BaseEnvironmentIntegrationModelSerializer): | ||
|
||
base_url = serializers.ChoiceField( | ||
choices=[ | ||
constants.DEFAULT_BASE_URL, | ||
constants.DUBLIN_BASE_URL, | ||
], | ||
required=False, | ||
default="api.segment.io/", | ||
) | ||
|
||
class Meta: | ||
model = SegmentConfiguration | ||
fields = ("id", "api_key") | ||
fields = ("id", "api_key", "base_url") |
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