Select Git revision
fizzbuzz.py
Forked from
GitLab Basics / FizzBuzz
Source project has a limited visibility.
create_asset.py 1.61 KiB
import os
import json
import requests
def invoke_create_asset(dataProductId:str,dataProductName:str, dataProductFormatType:str,dataProductDescription:str,openAPI:str,header_authorization:str):
provider_host = os.getenv("PROVIDER_HOST")
provider_management_port = os.getenv("PROVIDER_MANAGEMENT_PORT")
url = f"http://{provider_host}:{provider_management_port}/management/v3/assets"
payload = json.dumps(generate_asset_metadata(dataProductId,dataProductName,dataProductFormatType,dataProductDescription,openAPI))
"""headers = {
'Content-Type': 'application/json',
'X-API-Key': header_authorization
}"""
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(f"Create asset response={response.text}")
return response
def generate_asset_metadata(assetId:str,dataProductName:str,dataProductFormatType:str, dataProductDescription:str,openAPI:str):
asset_metadata = {
"@context": {
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"dqv": "http://www.w3.org/ns/dqv#"
},
"@id": assetId,
"properties": {
"name": dataProductName,
"contenttype": dataProductFormatType,
},
"dataAddress": {
"type": "HttpData",
"name": dataProductDescription,
"baseUrl": openAPI,
"proxyQueryParams": "true",
"proxyPath": "true",
"proxyMethod": "true",
"proxyBody": "true"
}
}
return asset_metadata