in datascan/bulk-creation-scripts/datascan.py [0:0]
def createDatascan(gcp_project_id, location_id, datascan_id, datascan):
"""
Method to create a datascan
"""
try:
# Create a client
client = dataplex_v1.DataScanServiceClient()
# Initialize request argument
request = dataplex_v1.CreateDataScanRequest(
parent=f"projects/{gcp_project_id}/locations/{location_id}",
data_scan=datascan,
data_scan_id=datascan_id,
)
print(f'Creating Datascan: {datascan_id}')
# Make the request
operation = client.create_data_scan(request=request)
response = operation.result()
return response
except Exception as error:
print(f'Error: Failed to create {datascan_id}. ')
print(error)
return None