mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Update Python client
Just so that nobody else has to do it. Implements: - [x] https://github.com/alphagov/notifications-python-client/pull/29 Which is a breaking change requiring the renaming of method arguments.
This commit is contained in:
@@ -9,15 +9,15 @@ KEY_TYPE_TEST = 'test'
|
|||||||
|
|
||||||
|
|
||||||
class ApiKeyApiClient(BaseAPIClient):
|
class ApiKeyApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def get_api_keys(self, service_id, key_id=None):
|
def get_api_keys(self, service_id, key_id=None):
|
||||||
if key_id:
|
if key_id:
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ from notifications_python_client.base import BaseAPIClient
|
|||||||
|
|
||||||
|
|
||||||
class EventsApiClient(BaseAPIClient):
|
class EventsApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def create_event(self, event_type, event_data):
|
def create_event(self, event_type, event_data):
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ from app.notify_client.models import InvitedUser
|
|||||||
|
|
||||||
|
|
||||||
class InviteApiClient(BaseAPIClient):
|
class InviteApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def create_invite(self, invite_from_id, service_id, email_address, permissions):
|
def create_invite(self, invite_from_id, service_id, email_address, permissions):
|
||||||
data = {
|
data = {
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ from app.notify_client import _attach_current_user
|
|||||||
|
|
||||||
|
|
||||||
class JobApiClient(BaseAPIClient):
|
class JobApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __convert_statistics(job):
|
def __convert_statistics(job):
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ from notifications_python_client.base import BaseAPIClient
|
|||||||
|
|
||||||
|
|
||||||
class NotificationApiClient(BaseAPIClient):
|
class NotificationApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def get_all_notifications(self, page=None):
|
def get_all_notifications(self, page=None):
|
||||||
params = {}
|
params = {}
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ from notifications_python_client.base import BaseAPIClient
|
|||||||
|
|
||||||
class OrganisationsClient(BaseAPIClient):
|
class OrganisationsClient(BaseAPIClient):
|
||||||
|
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(
|
super(self.__class__, self).__init__(
|
||||||
base_url=base_url or 'base_url',
|
base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret'
|
api_key=api_key or 'api_key'
|
||||||
)
|
)
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def get_organisation(self, id):
|
def get_organisation(self, id):
|
||||||
return self.get(url='/organisation/{}'.format(id))
|
return self.get(url='/organisation/{}'.format(id))
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ from app.notify_client import _attach_current_user
|
|||||||
|
|
||||||
|
|
||||||
class ProviderClient(BaseAPIClient):
|
class ProviderClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(
|
super(self.__class__, self).__init__(
|
||||||
base_url=base_url or 'base_url',
|
base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret'
|
api_key=api_key or 'api_key'
|
||||||
)
|
)
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def get_all_providers(self):
|
def get_all_providers(self):
|
||||||
return self.get(
|
return self.get(
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ class ServiceAPIClient(NotificationsAPIClient):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ServiceAPIClient, self).__init__("api_url",
|
super(ServiceAPIClient, self).__init__("api_url",
|
||||||
"client",
|
"client",
|
||||||
"secret")
|
"api_key")
|
||||||
|
|
||||||
def init_app(self, application):
|
def init_app(self, application):
|
||||||
self.base_url = application.config['API_HOST_NAME']
|
self.base_url = application.config['API_HOST_NAME']
|
||||||
self.client_id = application.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = application.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = application.config['ADMIN_CLIENT_SECRET']
|
self.api_key = application.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def create_service(self, service_name, active, message_limit, restricted, user_id, email_from):
|
def create_service(self, service_name, active, message_limit, restricted, user_id, email_from):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ from notifications_python_client.base import BaseAPIClient
|
|||||||
|
|
||||||
|
|
||||||
class StatusApiClient(BaseAPIClient):
|
class StatusApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def get_status(self, *params):
|
def get_status(self, *params):
|
||||||
return self.get(url='/_status', *params)
|
return self.get(url='/_status', *params)
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ from notifications_python_client.base import BaseAPIClient
|
|||||||
|
|
||||||
|
|
||||||
class TemplateStatisticsApiClient(BaseAPIClient):
|
class TemplateStatisticsApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
|
|
||||||
def get_template_statistics_for_service(self, service_id, limit_days=None):
|
def get_template_statistics_for_service(self, service_id, limit_days=None):
|
||||||
params = {}
|
params = {}
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ from app.notify_client.models import User
|
|||||||
|
|
||||||
|
|
||||||
class UserApiClient(BaseAPIClient):
|
class UserApiClient(BaseAPIClient):
|
||||||
def __init__(self, base_url=None, client_id=None, secret=None):
|
def __init__(self, base_url=None, service_id=None, api_key=None):
|
||||||
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
|
||||||
client_id=client_id or 'client_id',
|
service_id=service_id or 'service_id',
|
||||||
secret=secret or 'secret')
|
api_key=api_key or 'api_key')
|
||||||
|
|
||||||
def init_app(self, app):
|
def init_app(self, app):
|
||||||
self.base_url = app.config['API_HOST_NAME']
|
self.base_url = app.config['API_HOST_NAME']
|
||||||
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
||||||
self.secret = app.config['ADMIN_CLIENT_SECRET']
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
||||||
self.max_failed_login_count = app.config["MAX_FAILED_LOGIN_COUNT"]
|
self.max_failed_login_count = app.config["MAX_FAILED_LOGIN_COUNT"]
|
||||||
|
|
||||||
def register_user(self, name, email_address, mobile_number, password):
|
def register_user(self, name, email_address, mobile_number, password):
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ pyexcel-xlsx==0.1.0
|
|||||||
pyexcel-ods3==0.1.1
|
pyexcel-ods3==0.1.1
|
||||||
pytz==2016.4
|
pytz==2016.4
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-python-client.git@1.0.0#egg=notifications-python-client==1.0.0
|
git+https://github.com/alphagov/notifications-python-client.git@1.3.0#egg=notifications-python-client==1.3.0
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@9.0.0#egg=notifications-utils==9.0.0
|
git+https://github.com/alphagov/notifications-utils.git@9.0.0#egg=notifications-utils==9.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user