add route and compose rabbit url
Some checks failed
Build and Publish / build-release (push) Has been cancelled

This commit is contained in:
2026-04-15 13:36:00 -05:00
parent 7164f07d3a
commit d98c219398
3 changed files with 19 additions and 53 deletions

View File

@@ -181,54 +181,6 @@ defmodule PolicyServiceWeb.PolicyController do
end
end
# ---------------------------------------------------------------------------
# GET /api/policies/:application_id/solicitation-url
# ---------------------------------------------------------------------------
operation(:solicitation_url,
summary: "Get fresh presigned download URL for solicitation PDF",
parameters: [
application_id: [in: :path, type: :string, required: true],
version: [in: :query, type: :integer, required: false]
],
responses: [
ok: {"Presigned URL", "application/json", S.SolicitationUrlResponse},
not_found: {"Not found", "application/json", S.ErrorResponse}
]
)
def solicitation_url(conn, %{"application_id" => application_id} = params) do
org_id = conn.assigns[:org_id] || "test"
version = String.to_integer(params["version"] || "1")
case PolicyQueries.get_by_application_id(org_id, application_id) do
{:error, :not_found} ->
conn |> put_status(:not_found) |> json(%{error: "policy not found"})
{:ok, %{solicitation_id: nil}} ->
conn |> put_status(:not_found) |> json(%{error: "no solicitation yet"})
{:ok, policy} ->
url =
"#{solicitation_service_url()}/api/solicitations/#{policy.solicitation_id}/download-url"
case Req.get(url,
params: [org_id: org_id, application_id: application_id, version: version]
) do
{:ok, %{status: 200, body: body}} ->
conn |> put_status(:ok) |> json(body)
{:ok, %{status: status, body: body}} ->
conn
|> put_status(:bad_gateway)
|> json(%{error: "solicitation service returned #{status}: #{inspect(body)}"})
{:error, reason} ->
conn |> put_status(:bad_gateway) |> json(%{error: inspect(reason)})
end
end
end
# ---------------------------------------------------------------------------
# Serializers
# ---------------------------------------------------------------------------
@@ -371,8 +323,4 @@ defmodule PolicyServiceWeb.PolicyController do
end
defp parse_providers(_), do: {:error, :invalid_providers}
defp solicitation_service_url do
Application.get_env(:policy_service, :solicitation_service_url, "http://localhost:8081")
end
end

View File

@@ -21,7 +21,6 @@ defmodule PolicyServiceWeb.Router do
get "/policies/:application_id", PolicyController, :show
post "/policies", PolicyController, :create
post "/policies/:application_id/accept", PolicyController, :accept
get "/policies/:application_id/solicitation-url", PolicyController, :solicitation_url
end
end

View File

@@ -87,6 +87,25 @@ service:
protocol: HTTP
route:
main:
parentRefs:
- name: workload-dev-external-gateway
group: gateway.networking.k8s.io
kind: Gateway
sectionName: https-api
hostnames:
- dev.api.corredorconect.com
rules:
- matches:
- path:
type: PathPrefix
value: /policy
backendRefs:
- name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}'
port: 8080
rawResources:
rabbitmq-user:
enabled: true