updated
This commit is contained in:
parent
162b75a876
commit
63b43c2263
32
main.py
32
main.py
|
@ -16,6 +16,9 @@ pdf_filename = 'file-example_PDF_1MB.pdf'
|
|||
image_filenames = ['arco-di-san-vito.jpg', 'piazza_esquilino.jpg']
|
||||
shapefile_filename = 'area_di_scavo.shp'
|
||||
|
||||
# The UCD ID
|
||||
UCD_ID = 'esquilino'
|
||||
|
||||
# The KC client UMA TOKEN
|
||||
service_Client_ID = ''
|
||||
service_Client_Secret = ''
|
||||
|
@ -27,15 +30,17 @@ IAM_URL = 'https://accounts.d4science.org/auth/realms/d4science/protocol/openid-
|
|||
# The Geoportal Service endpoint
|
||||
geoportal_service_endpoint = 'https://geoportal-cms.int.d4science.net//geoportal-service/srv'
|
||||
|
||||
# The UCD ID
|
||||
UCD_ID = 'esquilino'
|
||||
|
||||
|
||||
# Request Authorization (UMA) TOKEN to D4Science IAM for service_Client_ID/service_Client_Secret
|
||||
def request_UMA_Token():
|
||||
itr = IAM_Token_Client(IAM_URL, service_Client_ID, service_Client_Secret)
|
||||
service_uma_token = itr.getUmaToken(gcube_context)
|
||||
# print("Uma token is: %s" % service_uma_token)
|
||||
return "Bearer " + service_uma_token
|
||||
return service_uma_token
|
||||
|
||||
|
||||
# Init UMA Token
|
||||
uma_token_field = "Bearer " + request_UMA_Token()
|
||||
|
||||
|
||||
class Geoportal_Client_Esquilino():
|
||||
|
@ -126,7 +131,7 @@ class Geoportal_Client_Esquilino():
|
|||
payload = ""
|
||||
headers = {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': request_UMA_Token()
|
||||
'Authorization': uma_token_field
|
||||
}
|
||||
print("calling: " + request_url)
|
||||
return requests.request("GET", request_url, headers=headers, data=payload)
|
||||
|
@ -137,7 +142,7 @@ class Geoportal_Client_Esquilino():
|
|||
payload = ""
|
||||
headers = {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': request_UMA_Token()
|
||||
'Authorization': uma_token_field
|
||||
}
|
||||
print("calling: " + request_url)
|
||||
return requests.request("GET", request_url, headers=headers, data=payload)
|
||||
|
@ -147,7 +152,7 @@ class Geoportal_Client_Esquilino():
|
|||
request_url = geoportal_service_endpoint + "/projects/" + ucd_id
|
||||
headers = {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': request_UMA_Token()
|
||||
'Authorization': uma_token_field
|
||||
}
|
||||
print("calling: " + request_url)
|
||||
print("json_data: " + str(json_data))
|
||||
|
@ -158,7 +163,7 @@ class Geoportal_Client_Esquilino():
|
|||
request_url = geoportal_service_endpoint + "/projects/" + ucd_id + "/registerFiles/" + project_id
|
||||
headers = {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': request_UMA_Token()
|
||||
'Authorization': uma_token_field
|
||||
}
|
||||
print("calling: " + request_url)
|
||||
print("json_data: " + str(json_data))
|
||||
|
@ -169,7 +174,7 @@ class Geoportal_Client_Esquilino():
|
|||
request_url = geoportal_service_endpoint + "/projects/" + ucd_id + "/step/" + project_id
|
||||
headers = {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': request_UMA_Token()
|
||||
'Authorization': uma_token_field
|
||||
}
|
||||
print("calling: " + request_url)
|
||||
print("json_data: " + str(json_data))
|
||||
|
@ -225,11 +230,10 @@ def main():
|
|||
response = gce.perform_step(UCD_ID, project_id, step_publish)
|
||||
print("Response code is %s" % response.status_code)
|
||||
|
||||
# project_id = ""
|
||||
# print("\n\nRead a Project for ucd "+UCD_ID+" and project "+project_id)
|
||||
# response = gce.get_project(UCD_ID, project_id)
|
||||
# print("Response code is %s" % response.status_code)
|
||||
# print("\n\nCreate a Project response %s" % response.json())
|
||||
print("\n\nRead the Project for ucd " + UCD_ID + " and project " + project_id)
|
||||
response = gce.get_project(UCD_ID, project_id)
|
||||
print("Response code is %s" % response.status_code)
|
||||
print("\n\nRead Project response %s" % response.json())
|
||||
|
||||
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue