mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
fix: rename class to differentiate lighthouse providers
This commit is contained in:
@@ -933,10 +933,10 @@ class TenantApiKeyFilter(FilterSet):
|
||||
|
||||
class LighthouseProviderConfigFilter(FilterSet):
|
||||
provider_type = ChoiceFilter(
|
||||
choices=LighthouseProviderConfiguration.ProviderChoices.choices
|
||||
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices
|
||||
)
|
||||
provider_type__in = ChoiceInFilter(
|
||||
choices=LighthouseProviderConfiguration.ProviderChoices.choices,
|
||||
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices,
|
||||
field_name="provider_type",
|
||||
lookup_expr="in",
|
||||
)
|
||||
@@ -952,11 +952,11 @@ class LighthouseProviderConfigFilter(FilterSet):
|
||||
|
||||
class LighthouseProviderModelsFilter(FilterSet):
|
||||
provider_type = ChoiceFilter(
|
||||
choices=LighthouseProviderConfiguration.ProviderChoices.choices,
|
||||
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices,
|
||||
field_name="provider_configuration__provider_type",
|
||||
)
|
||||
provider_type__in = ChoiceInFilter(
|
||||
choices=LighthouseProviderConfiguration.ProviderChoices.choices,
|
||||
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices,
|
||||
field_name="provider_configuration__provider_type",
|
||||
lookup_expr="in",
|
||||
)
|
||||
|
||||
@@ -1967,7 +1967,7 @@ class LighthouseProviderConfiguration(RowLevelSecurityProtectedModel):
|
||||
One configuration per provider type per tenant.
|
||||
"""
|
||||
|
||||
class ProviderChoices(models.TextChoices):
|
||||
class LLMProviderChoices(models.TextChoices):
|
||||
OPENAI = "openai", _("OpenAI")
|
||||
|
||||
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
|
||||
@@ -1976,7 +1976,7 @@ class LighthouseProviderConfiguration(RowLevelSecurityProtectedModel):
|
||||
|
||||
provider_type = models.CharField(
|
||||
max_length=50,
|
||||
choices=ProviderChoices.choices,
|
||||
choices=LLMProviderChoices.choices,
|
||||
help_text="LLM provider name",
|
||||
)
|
||||
|
||||
|
||||
@@ -3080,7 +3080,7 @@ class LighthouseProviderConfigCreateSerializer(RLSSerializer, BaseWriteSerialize
|
||||
provider_type = attrs.get("provider_type")
|
||||
credentials = attrs.get("credentials") or {}
|
||||
|
||||
if provider_type == LighthouseProviderConfiguration.ProviderChoices.OPENAI:
|
||||
if provider_type == LighthouseProviderConfiguration.LLMProviderChoices.OPENAI:
|
||||
try:
|
||||
OpenAICredentialsSerializer(data=credentials).is_valid(
|
||||
raise_exception=True
|
||||
@@ -3136,7 +3136,8 @@ class LighthouseProviderConfigUpdateSerializer(BaseWriteSerializer):
|
||||
|
||||
if (
|
||||
credentials is not None
|
||||
and provider_type == LighthouseProviderConfiguration.ProviderChoices.OPENAI
|
||||
and provider_type
|
||||
== LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
|
||||
):
|
||||
try:
|
||||
OpenAICredentialsSerializer(data=credentials).is_valid(
|
||||
@@ -3211,7 +3212,7 @@ class LighthouseTenantConfigCreateSerializer(RLSSerializer, BaseWriteSerializer)
|
||||
default_models = attrs.get("default_models", {})
|
||||
|
||||
if default_provider:
|
||||
supported = set(LighthouseProviderConfiguration.ProviderChoices.values)
|
||||
supported = set(LighthouseProviderConfiguration.LLMProviderChoices.values)
|
||||
if default_provider not in supported:
|
||||
raise ValidationError(
|
||||
{"default_provider": f"Unsupported provider '{default_provider}'."}
|
||||
@@ -3289,7 +3290,7 @@ class LighthouseTenantConfigUpdateSerializer(BaseWriteSerializer):
|
||||
)
|
||||
|
||||
if default_provider:
|
||||
supported = set(LighthouseProviderConfiguration.ProviderChoices.values)
|
||||
supported = set(LighthouseProviderConfiguration.LLMProviderChoices.values)
|
||||
if default_provider not in supported:
|
||||
raise ValidationError(
|
||||
{"default_provider": f"Unsupported provider '{default_provider}'."}
|
||||
|
||||
@@ -4282,7 +4282,7 @@ class LighthouseProviderConfigViewSet(BaseRLSViewSet):
|
||||
instance = self.get_object()
|
||||
if (
|
||||
instance.provider_type
|
||||
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
|
||||
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
|
||||
):
|
||||
return Response(
|
||||
data={
|
||||
@@ -4325,7 +4325,7 @@ class LighthouseProviderConfigViewSet(BaseRLSViewSet):
|
||||
instance = self.get_object()
|
||||
if (
|
||||
instance.provider_type
|
||||
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
|
||||
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
|
||||
):
|
||||
return Response(
|
||||
data={
|
||||
|
||||
@@ -58,7 +58,7 @@ def check_lighthouse_provider_connection(provider_config_id: str) -> Dict:
|
||||
# TODO: Add support for other providers
|
||||
if (
|
||||
provider_cfg.provider_type
|
||||
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
|
||||
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
|
||||
):
|
||||
return {"connected": False, "error": "Unsupported provider type"}
|
||||
|
||||
@@ -107,7 +107,7 @@ def refresh_lighthouse_provider_models(provider_config_id: str) -> Dict:
|
||||
|
||||
if (
|
||||
provider_cfg.provider_type
|
||||
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
|
||||
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
|
||||
):
|
||||
return {
|
||||
"created": 0,
|
||||
|
||||
Reference in New Issue
Block a user