# %%
from ibm_watson import DiscoveryV2
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
# %%
apikey='APIKEY'
version='VERSION'
service_url='SERVICE_URL'
authenticator = IAMAuthenticator(apikey=apikey)
discovery = DiscoveryV2(version=version, authenticator=authenticator)
discovery.set_service_url(service_url=service_url)
# %%
name = 'NAME'
type = 'TYPE'
response = discovery.create_project(name=name, type=type).get_result()
print(response)
# %%
response = discovery.list_projects().get_result()
print(response)
# %%
name = 'NAME'
rs = [project for project in response['projects'] if project['name'] == name]
print(rs)
# %%
for r in rs:
print(r)
response = discovery.delete_project(project_id=r['project_id'])
# %%
https://cloud.ibm.com/apidocs/discovery-data?code=python#listprojects
https://cloud.ibm.com/apidocs/discovery-data?code=python#deleteproject