from deriva.core import DerivaServer, get_credential

"""
Explanation: Deriva Ermrest Catalog Examples
This notebook gives examples of creating and connecting to ERMrest catalogs.
End of explanation
"""


scheme = 'https'
hostname = 'dev.isrd.isi.edu'
catalog_number = 1

"""
Explanation: Fill in your desired scheme, hostname and catalog number.
End of explanation
"""


#credential = None
credential = get_credential(hostname)

"""
Explanation: Use DERIVA-Auth to get a credential or use None if your catalog allows anonymous access.
End of explanation
"""


server = DerivaServer(scheme, hostname, credential)

"""
Explanation: Get a handle representing your server.
End of explanation
"""


catalog = server.connect_ermrest(catalog_number)
pb = catalog.getPathBuilder()
list(pb.schemas)

"""
Explanation: Connect to a catalog, and list its schemas.
End of explanation
"""


new_catalog = server.create_ermrest_catalog()
new_catalog_pb = new_catalog.getPathBuilder()
list(new_catalog_pb.schemas)

"""
Explanation: Create a new catalog.
End of explanation
"""


