mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-24 11:11:15 -04: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.
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
|
|
|
|
|
class OrganisationsClient(NotifyAdminAPIClient):
|
|
|
|
def __init__(self):
|
|
super().__init__("a" * 73, "b")
|
|
|
|
def get_organisations(self):
|
|
return self.get(url='/organisations')
|
|
|
|
def get_organisation(self, org_id):
|
|
return self.get(url='/organisations/{}'.format(org_id))
|
|
|
|
def create_organisation(self, name):
|
|
data = {
|
|
"name": name
|
|
}
|
|
return self.post(url="/organisations", data=data)
|
|
|
|
def update_organisation(self, org_id, name):
|
|
data = {
|
|
"name": name
|
|
}
|
|
return self.post(url="/organisations/{}".format(org_id), data=data)
|
|
|
|
def get_service_organisation(self, service_id):
|
|
return self.get(url="/service/{}/organisation".format(service_id))
|
|
|
|
def update_service_organisation(self, service_id, org_id):
|
|
data = {
|
|
'service_id': service_id
|
|
}
|
|
return self.post(
|
|
url="/organisations/{}/service".format(org_id),
|
|
data=data
|
|
)
|
|
|
|
def get_organisation_services(self, org_id):
|
|
return self.get(url="/organisations/{}/services".format(org_id))
|
|
|
|
def remove_user_from_organisation(self, org_id, user_id):
|
|
endpoint = '/organisations/{}/users/{}'.format(
|
|
org_id=org_id,
|
|
user_id=user_id)
|
|
data = _attach_current_user({})
|
|
return self.delete(endpoint, data)
|