Commit bcf9a68f authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Update stage drupal URL.

Add authentication to group reporting.
parent 9bc36f46
Pipeline #32976 passed with stages
in 2 minutes and 1 second
......@@ -17,7 +17,7 @@ importApiConfig: api-import-stage-config
ingressUri: 'stage.import.memobase.k8s.unibas.ch'
importApiUrl: 'https://stage.import.memobase.k8s.unibas.ch'
drupalApiUrl: 'https://mb-wf1.memobase.unibas.ch'
drupalApiUrl: 'https://memobase-customer-stage.outermedia.net'
topicConfigs: 'mb-di-config-stage'
topicDrupalExport: 'mb-gi-drupal-export-stage'
......
......@@ -4,6 +4,8 @@ from helpers.Error import ImportApiError
import requests
import json
from requests.auth import HTTPBasicAuth
class WriteTypeReportToDrupal(Resource):
......@@ -14,6 +16,9 @@ class WriteTypeReportToDrupal(Resource):
'Accept': 'application/vnd.api+json',
'X-API-Key': current_app.config['drupal-api-key']
}
user = current_app.config['drupal-user']
password = current_app.config['drupal-password']
self.auth = HTTPBasicAuth(user, password)
def post(self):
"""
......@@ -75,7 +80,7 @@ class WriteTypeReportToDrupal(Resource):
def get_drupal_uuid(self, memobase_id: str, node_type: str):
url = f'{self.base_url}/jsonapi/node/{node_type}?filter[field_memobase_id]={memobase_id}'
response = requests.get(url, headers=self.headers)
response = requests.get(url, headers=self.headers, auth=self.auth)
if response.ok:
try:
return response.json()['data'][0]['id']
......@@ -121,6 +126,7 @@ class WriteTypeReportToDrupal(Resource):
response = requests.patch(
url,
headers=self.headers,
auth=self.auth,
data=json.dumps(data)
)
except requests.exceptions.RequestException:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment