Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Import Process
Import API
Commits
896f8562
Commit
896f8562
authored
May 08, 2021
by
Matthias
Browse files
add endpoint for clearing drupal cache
parent
47824aa7
Changes
7
Hide whitespace changes
Inline
Side-by-side
helm-charts/helm-values/api-import-prod.yml
View file @
896f8562
...
...
@@ -23,3 +23,5 @@ topicDrupalExport: 'mb-gi-drupal-export-prod'
tfvReportingTopicName
:
"
mb-di-reporting-prod"
tfvTopicName
:
"
mb-di-data-transform-prod"
clearCacheUrl
:
"
/de/memobase/ingestapi/clear_cache"
\ No newline at end of file
helm-charts/helm-values/api-import-stage.yml
View file @
896f8562
...
...
@@ -23,3 +23,5 @@ topicDrupalExport: 'mb-gi-drupal-export-stage'
tfvReportingTopicName
:
"
mb-di-reporting-stage"
tfvTopicName
:
"
mb-di-data-transform-stage"
clearCacheUrl
:
"
/de/memobase/ingestapi/clear_cache"
\ No newline at end of file
helm-charts/helm-values/api-import-test.yml
View file @
896f8562
...
...
@@ -23,3 +23,5 @@ topicDrupalExport: 'mb-gi-drupal-export-prod'
tfvReportingTopicName
:
"
mb-di-reporting-prod"
tfvTopicName
:
"
mb-di-data-transform-prod"
clearCacheUrl
:
"
/de/memobase/ingestapi/clear_cache"
\ No newline at end of file
helm-charts/templates/configmap.yml
View file @
896f8562
...
...
@@ -12,4 +12,5 @@ data:
DRUPAL_API_URL
:
{{
.Values.drupalApiUrl
}}
TOPIC_CONFIGS
:
{{
.Values.topicConfigs
}}
TOPIC_DRUPAL_EXPORT
:
{{
.Values.topicDrupalExport
}}
CLEAR_CACHE_URL
:
{{
.Values.clearCacheUrl
}}
LOG_LEVEL
:
"
{{
.Values.logLevel
}}"
import_api_app/__init__.py
View file @
896f8562
...
...
@@ -12,6 +12,7 @@ from import_api_app.resources.WriteTypeReportToDrupal import WriteTypeReportToDr
# from import_api_app.resources.ReadJobOptionsFromDrupal import ReadJobOptionsFromDrupal
from
import_api_app.resources.MonitorDrupalJsonApiInstitution
import
MonitorDrupalJsonApiInstitution
from
import_api_app.resources.MonitorDrupalJsonApiRecordSet
import
MonitorDrupalJsonApiRecordSet
from
import_api_app.resources.ClearCache
import
ClearCache
from
import_api_app.resources.ImportProcessStart
import
ImportProcessStart
from
import_api_app.resources.FetchMappingFile
import
FetchMappingFile
from
import_api_app.resources.DeleteRecord
import
DeleteRecord
...
...
@@ -116,6 +117,7 @@ def create_app(test_config=None):
'/v1/drupal/delete/institution/<session_id>'
,
'/v1/drupal/delete/institution/<session_id>/<dryrun>'
)
api
.
add_resource
(
ClearCache
,
'/v1/drupal/clearcache'
)
# TODO : maybe take that to a configuration (development vs pod running in
# k8s cluster)
...
...
import_api_app/main.py
View file @
896f8562
...
...
@@ -9,4 +9,4 @@ if __name__ == "__main__":
logging
.
basicConfig
(
format
=
'%(levelname)-8s [%(filename)s:%(lineno)d] %(message)s'
,
level
=
numeric_level
)
app
=
create_app
()
app
.
run
(
host
=
'0.0.0.0'
,
debug
=
Fals
e
)
app
.
run
(
host
=
'0.0.0.0'
,
debug
=
Tru
e
)
import_api_app/resources/ClearCache.py
0 → 100644
View file @
896f8562
from
flask_restful
import
Resource
,
current_app
import
requests
import
traceback
class
ClearCache
(
Resource
):
def
get
(
self
):
"""
Tell drupal to clear the import-process-cache
---
tags:
- clear drupal cache
responses:
200:
description: Success, the call to drupal could be executed
500:
description: Failure tha call to drupal could neo be executed
"""
uri
=
current_app
.
config
[
'drupal-api-url'
]
+
current_app
.
config
[
'CLEAR_CACHE_URL'
]
headers
=
{
'X-API-Key'
:
current_app
.
config
[
'drupal-api-key'
]}
try
:
response
=
requests
.
get
(
uri
,
headers
=
headers
)
except
Exception
as
ex
:
msg
=
'Exception while calling '
+
uri
+
': '
+
str
(
ex
)
+
'
\n
'
+
\
traceback
.
format_exc
()
current_app
.
logger
.
error
(
msg
)
return
{
'response'
:
response
.
content
.
decode
(
"utf-8"
),
},
500
if
response
.
status_code
!=
200
:
current_app
.
logger
.
debug
(
'there was an unexpected behaviour calling '
+
uri
)
current_app
.
logger
.
debug
(
'statuscode: '
+
response
.
status_code
+
' content: '
+
response
.
content
.
decode
(
'utf-8'
))
return
{
'content'
:
response
.
content
.
decode
(
"utf-8"
),
},
response
.
status_code
else
:
current_app
.
logger
.
debug
(
'successfully called '
+
uri
)
return
{
'content'
:
response
.
content
.
decode
(
"utf-8"
),
},
400
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment