mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 20:01:01 -05:00
Currently requests to the API made from the admin app are going from PaaS admin app to the nginx router ELB, which then routes them back to the api app on PaaS. This makes sense for external requests, but for requests made from the admin app we could skip nginx and go directly to the api PaaS host, which should reduce load on the nginx instances and potentially reduce latency of the api requests. API apps on PaaS are checking the X-Custom-Forwarder header (which is set by nginx on proxy_pass requests) to only allow requests going through the proxy. This adds the custom header to the API client requests, so that they can pass that header check without going through nginx.
30 lines
826 B
Python
30 lines
826 B
Python
|
|
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
|
|
|
|
|
class ProviderClient(NotifyAdminAPIClient):
|
|
def __init__(self):
|
|
super().__init__("a" * 73, "b")
|
|
|
|
def get_all_providers(self):
|
|
return self.get(
|
|
url='/provider-details'
|
|
)
|
|
|
|
def get_provider_by_id(self, provider_id):
|
|
return self.get(
|
|
url='/provider-details/{}'.format(provider_id)
|
|
)
|
|
|
|
def get_provider_versions(self, provider_id):
|
|
return self.get(
|
|
url='/provider-details/{}/versions'.format(provider_id)
|
|
)
|
|
|
|
def update_provider(self, provider_id, priority):
|
|
data = {
|
|
"priority": priority
|
|
}
|
|
data = _attach_current_user(data)
|
|
return self.post(url='/provider-details/{}'.format(provider_id), data=data)
|