def identifier_create(args):
    """
    Create a new identifier
    """
    client = identifiers_client(config)
    args = clear_internal_args(vars(args))
    return client.create_identifier(**args)
Beispiel #2
0
def mint_identifier(task):
    """Mint a new identifier and return it."""
    identifiers_namespace = '1EGOGHSs9RAtq'
    identifier = None
    logging.debug("Creating identifier")
    try:
        client = identifiers_client(config)
        serv_location = "https://%s%s" % ("dlhub.org/servables/",
                                          task['dlhub']['id'])
        # safe encode the location
        serv_location = urllib.parse.quote_plus(serv_location, safe='')
        # can't be too safe!
        serv_location = urllib.parse.quote_plus(serv_location, safe='')
        # Create the petrel link
        serv_location = f'https://petreldata.net/dlhub/detail/{serv_location}'
        visible_to = ['public']

        dataset_identifier = client.create_identifier(
            namespace=identifiers_namespace,
            location=[serv_location],
            metadata={
                'uuid': task['dlhub']['id'],
                'shorthand_name': task['dlhub']['shorthand_name']
            },
            landing_page=serv_location,
            visible_to=visible_to)

        res = dataset_identifier.data
        identifier = res['identifier']
        logging.debug(f"Created identifier: {identifier}")
    except Exception as e:
        logging.error(e)
    return identifier
def identifier_update(args):
    """
    Update the state of an identifier
    """
    client = identifiers_client(config)
    identifier_id = args.identifier
    args = clear_internal_args(vars(args))

    return client.update_identifier(identifier_id, **args)
Beispiel #4
0
def identifier_create(args):
    """
    Create a new identifier
    """
    client = identifiers_client(config)
    args = clear_internal_args(vars(args))
    args = set_checksum_args(args)
    if args.get('locations'):
        args['location'] = args.pop('locations')
    return client.create_identifier(**args)
Beispiel #5
0
def identifier_update(args):
    """
    Update the state of an identifier
    """
    client = identifiers_client(config)
    identifier_id = args.identifier
    args = clear_internal_args(vars(args))
    args = set_checksum_args(args)
    if args.get('locations'):
        args['location'] = args.pop('locations')
    return client.update_identifier(identifier_id, **args)
Beispiel #6
0
def namespace_create(args):
    """
    Create a new namespace
    """
    client = identifiers_client(config)
    args = clear_internal_args(vars(args))
    # Convenience helper: If user doesn't specify a member
    # group, just use the same group as for admins.
    # This means all members will be admins.
    if 'creators' not in args:
        args['creators'] = args['admins']
    return client.create_namespace(**args)
Beispiel #7
0
def namespace_update(args):
    """
    Update the properties of an existing namespace
    """
    client = identifiers_client(config)
    args = clear_internal_args(vars(args))

    # Convenience helper: If user doesn't specify a member
    # group, just use the same group as for admins.
    # This means all members will be admins.
    if 'creators' not in args:
        args['creators'] = args['admins']
    namespace_id = args.pop('namespace_id')
    return client.update_namespace(namespace_id, **args)
Beispiel #8
0
def identifier_from_checksum(args):
    client = identifiers_client(config)
    return client.get_identifier_from_checksum(args.checksum, args.function)
Beispiel #9
0
def identifier_display(args):
    """
    Display the state of an identifier
    """
    client = identifiers_client(config)
    return client.get_identifier(args.identifier)
Beispiel #10
0
def namespace_delete(args):
    """
    Remove an existing namespace
    """
    client = identifiers_client(config)
    return client.delete_namespace(args.namespace_id)
Beispiel #11
0
def namespace_display(args):
    """
    Display a namespace
    """
    client = identifiers_client(config)
    return client.get_namespace(args.namespace_id)