blunt rename of org (#620)

This commit is contained in:
Steven Reilly
2023-07-12 12:09:44 -04:00
committed by GitHub
parent 5fe81bc040
commit 13d0e46b52
107 changed files with 1471 additions and 1471 deletions

View File

@@ -15,37 +15,37 @@ class OrgInviteApiClient(NotifyAdminAPIClient):
'invite_link_host': self.admin_url,
}
data = _attach_current_user(data)
resp = self.post(url='/organisation/{}/invite'.format(org_id), data=data)
resp = self.post(url='/organization/{}/invite'.format(org_id), data=data)
return resp['data']
def get_invites_for_organisation(self, org_id):
endpoint = '/organisation/{}/invite'.format(org_id)
def get_invites_for_organization(self, org_id):
endpoint = '/organization/{}/invite'.format(org_id)
resp = self.get(endpoint)
return resp['data']
def get_invited_user_for_org(self, org_id, invited_org_user_id):
return self.get(
f'/organisation/{org_id}/invite/{invited_org_user_id}'
f'/organization/{org_id}/invite/{invited_org_user_id}'
)['data']
def get_invited_user(self, invited_user_id):
return self.get(
f'/invite/organisation/{invited_user_id}'
f'/invite/organization/{invited_user_id}'
)['data']
def check_token(self, token):
resp = self.get(url='/invite/organisation/check/{}'.format(token))
resp = self.get(url='/invite/organization/check/{}'.format(token))
return resp['data']
def cancel_invited_user(self, org_id, invited_user_id):
data = {'status': 'cancelled'}
data = _attach_current_user(data)
self.post(url='/organisation/{0}/invite/{1}'.format(org_id, invited_user_id),
self.post(url='/organization/{0}/invite/{1}'.format(org_id, invited_user_id),
data=data)
def accept_invite(self, org_id, invited_user_id):
data = {'status': 'accepted'}
self.post(url='/organisation/{0}/invite/{1}'.format(org_id, invited_user_id),
self.post(url='/organization/{0}/invite/{1}'.format(org_id, invited_user_id),
data=data)

View File

@@ -1,88 +0,0 @@
from itertools import chain
from notifications_python_client.errors import HTTPError
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient, cache
class OrganisationsClient(NotifyAdminAPIClient):
@cache.set('organisations')
def get_organisations(self):
return self.get(url='/organisations')
@cache.set('domains')
def get_domains(self):
return list(chain.from_iterable(
organisation['domains']
for organisation in self.get_organisations()
))
def get_organisation(self, org_id):
return self.get(url='/organisations/{}'.format(org_id))
@cache.set('organisation-{org_id}-name')
def get_organisation_name(self, org_id):
return self.get_organisation(org_id)['name']
def get_organisation_by_domain(self, domain):
try:
return self.get(
url='/organisations/by-domain?domain={}'.format(domain),
)
except HTTPError as error:
if error.status_code == 404:
return None
raise error
@cache.delete('organisations')
def create_organisation(self, name, organisation_type):
return self.post(
url="/organisations",
data={
"name": name,
"organisation_type": organisation_type,
}
)
@cache.delete('domains')
@cache.delete('organisations')
def update_organisation(self, org_id, cached_service_ids=None, **kwargs):
api_response = self.post(url="/organisations/{}".format(org_id), data=kwargs)
if cached_service_ids:
redis_client.delete(*map('service-{}'.format, cached_service_ids))
if 'name' in kwargs:
redis_client.delete(f'organisation-{org_id}-name')
return api_response
@cache.delete('service-{service_id}')
@cache.delete('live-service-and-organisation-counts')
@cache.delete('organisations')
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))
@cache.delete('user-{user_id}')
def remove_user_from_organisation(self, org_id, user_id):
return self.delete(f'/organisations/{org_id}/users/{user_id}')
def get_services_and_usage(self, org_id, year):
return self.get(
url=f"/organisations/{org_id}/services-with-usage",
params={"year": str(year)}
)
organisations_client = OrganisationsClient()

View File

@@ -0,0 +1,88 @@
from itertools import chain
from notifications_python_client.errors import HTTPError
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient, cache
class OrganizationsClient(NotifyAdminAPIClient):
@cache.set('organizations')
def get_organizations(self):
return self.get(url='/organizations')
@cache.set('domains')
def get_domains(self):
return list(chain.from_iterable(
organization['domains']
for organization in self.get_organizations()
))
def get_organization(self, org_id):
return self.get(url='/organizations/{}'.format(org_id))
@cache.set('organization-{org_id}-name')
def get_organization_name(self, org_id):
return self.get_organization(org_id)['name']
def get_organization_by_domain(self, domain):
try:
return self.get(
url='/organizations/by-domain?domain={}'.format(domain),
)
except HTTPError as error:
if error.status_code == 404:
return None
raise error
@cache.delete('organizations')
def create_organization(self, name, organization_type):
return self.post(
url="/organizations",
data={
"name": name,
"organization_type": organization_type,
}
)
@cache.delete('domains')
@cache.delete('organizations')
def update_organization(self, org_id, cached_service_ids=None, **kwargs):
api_response = self.post(url="/organizations/{}".format(org_id), data=kwargs)
if cached_service_ids:
redis_client.delete(*map('service-{}'.format, cached_service_ids))
if 'name' in kwargs:
redis_client.delete(f'organization-{org_id}-name')
return api_response
@cache.delete('service-{service_id}')
@cache.delete('live-service-and-organization-counts')
@cache.delete('organizations')
def update_service_organization(self, service_id, org_id):
data = {
'service_id': service_id
}
return self.post(
url="/organizations/{}/service".format(org_id),
data=data
)
def get_organization_services(self, org_id):
return self.get(url="/organizations/{}/services".format(org_id))
@cache.delete('user-{user_id}')
def remove_user_from_organization(self, org_id, user_id):
return self.delete(f'/organizations/{org_id}/users/{user_id}')
def get_services_and_usage(self, org_id, year):
return self.get(
url=f"/organizations/{org_id}/services-with-usage",
params={"year": str(year)}
)
organizations_client = OrganizationsClient()

View File

@@ -14,7 +14,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
def create_service(
self,
service_name,
organisation_type,
organization_type,
message_limit,
restricted,
user_id,
@@ -25,7 +25,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
"""
data = {
"name": service_name,
"organisation_type": organisation_type,
"organization_type": organization_type,
"active": True,
"message_limit": message_limit,
"user_id": user_id,
@@ -94,7 +94,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
'message_limit',
'name',
'notes',
'organisation_type',
'organization_type',
'permissions',
'prefix_sms',
'purchase_order_number',
@@ -114,7 +114,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
endpoint = "/service/{0}".format(service_id)
return self.post(endpoint, data)
@cache.delete('live-service-and-organisation-counts')
@cache.delete('live-service-and-organization-counts')
def update_status(self, service_id, live):
return self.update_service(
service_id,
@@ -123,7 +123,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
go_live_at=str(datetime.utcnow()) if live else None
)
@cache.delete('live-service-and-organisation-counts')
@cache.delete('live-service-and-organization-counts')
def update_count_as_live(self, service_id, count_as_live):
return self.update_service(
service_id,

View File

@@ -6,13 +6,13 @@ class StatusApiClient(NotifyAdminAPIClient):
def get_status(self, *params):
return self.get(url='/_status', *params)
@cache.set('live-service-and-organisation-counts', ttl_in_seconds=3600)
def get_count_of_live_services_and_organisations(self):
return self.get(url='/_status/live-service-and-organisation-counts')
@cache.set('live-service-and-organization-counts', ttl_in_seconds=3600)
def get_count_of_live_services_and_organizations(self):
return self.get(url='/_status/live-service-and-organization-counts')
@cache.set('live-service-and-organisation-counts', ttl_in_seconds=3600)
def get_count_of_live_services_and_organisations_cached(self):
return self.get(url='/_status/live-service-and-organisation-counts')
@cache.set('live-service-and-organization-counts', ttl_in_seconds=3600)
def get_count_of_live_services_and_organizations_cached(self):
return self.get(url='/_status/live-service-and-organization-counts')
status_api_client = StatusApiClient()

View File

@@ -150,8 +150,8 @@ class UserApiClient(NotifyAdminAPIClient):
endpoint = '/service/{}/users'.format(service_id)
return self.get(endpoint)['data']
def get_users_for_organisation(self, org_id):
endpoint = '/organisations/{}/users'.format(org_id)
def get_users_for_organization(self, org_id):
endpoint = '/organizations/{}/users'.format(org_id)
return self.get(endpoint)['data']
@cache.delete('service-{service_id}')
@@ -168,8 +168,8 @@ class UserApiClient(NotifyAdminAPIClient):
self.post(endpoint, data=data)
@cache.delete('user-{user_id}')
def add_user_to_organisation(self, org_id, user_id):
resp = self.post('/organisations/{}/users/{}'.format(org_id, user_id), data={})
def add_user_to_organization(self, org_id, user_id):
resp = self.post('/organizations/{}/users/{}'.format(org_id, user_id), data={})
return resp['data']
@cache.delete('service-{service_id}-template-folders')
@@ -211,8 +211,8 @@ class UserApiClient(NotifyAdminAPIClient):
data = {'email': new_email}
self.post(endpoint, data)
def get_organisations_and_services_for_user(self, user_id):
endpoint = '/user/{}/organisations-and-services'.format(user_id)
def get_organizations_and_services_for_user(self, user_id):
endpoint = '/user/{}/organizations-and-services'.format(user_id)
return self.get(endpoint)
def get_webauthn_credentials_for_user(self, user_id):