# %%
from ibm_watson import DiscoveryV2
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
import json
# %%
apikey='APIKEY'
version='VERSION'
authenticator = IAMAuthenticator(apikey=apikey)
discovery = DiscoveryV2(version=version, authenticator=authenticator)
# %%
service_url='SERVICE_URL'
discovery.set_service_url(service_url=service_url)
# %%
response = discovery.list_projects().get_result()
print(response)
# %%
projects = response['projects']
for project in projects:
print(project)
# %%
name = 'PROJECT_NAME'
projects = [project for project in projects if project['name'] == name]
print(projects)
# %%
if len(projects) != 0:
for project in projects:
response = discovery.delete_project(project_id=project['project_id']).get_result()
print(response)
# %%
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme