Exemple #1
0
def listParameterValues(samweb, param):
    """ list the values for the given parameter
    arguments:
        param: parameter name
    """
    result = samweb.getURL('/values/parameters/%s?format=json' % escape_url_path(param))
    return convert_from_unicode(result.json())
Exemple #2
0
def getMultipleMetadata(samweb, filenameorids, locations=False, asJSON=False):
    """ Return a list of metadata dictionaries
    (This method does not return an error if a
    file does not exist; instead it returns no
    result for that file)
    arguments:
        list of file names or ids
        locations: if True include location information
        asJSON: return the undecoded JSON string instead of python objects
    """
    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)

    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    if locations: params["locations"] = 1
    response = samweb.getURL("/files/metadata", params=params)
    if asJSON:
        return response.text.rstrip()
    else:
        return convert_from_unicode(response.json())
Exemple #3
0
def descDefinitionDict(samweb, defname):
    """ Describe a dataset definition
    arguments:
        definition name
    """
    result = samweb.getURL(_descDefinitionURL(defname))
    return convert_from_unicode(result.json())
Exemple #4
0
def getMultipleMetadata(samweb, filenameorids, locations=False, asJSON=False):
    """ Return a list of metadata dictionaries
    (This method does not return an error if a
    file does not exist; instead it returns no
    result for that file)
    arguments:
        list of file names or ids
        locations: if True include location information
        asJSON: return the undecoded JSON string instead of python objects
    """
    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)
    
    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    if locations: params["locations"] = 1
    response = samweb.getURL("/files/metadata", params=params)
    if asJSON:
        return response.text.rstrip()
    else:
        return convert_from_unicode(response.json())
Exemple #5
0
def descDefinitionDict(samweb, defname):
    """ Describe a dataset definition
    arguments:
        definition name
    """
    result = samweb.getURL(_descDefinitionURL(defname))
    return convert_from_unicode(result.json())
Exemple #6
0
def listParameterValues(samweb, param):
    """ list the values for the given parameter
    arguments:
        param: parameter name
    """
    result = samweb.getURL('/values/parameters/%s?format=json' %
                           escape_url_path(param))
    return convert_from_unicode(result.json())
Exemple #7
0
def locateFile(samweb, filenameorid):
    """ return locations for this file
    arguments:
        name or id of file
    """
    url = _make_file_path(filenameorid) + '/locations'
    result = samweb.getURL(url)
    return convert_from_unicode(result.json())
Exemple #8
0
def getFileLineage(samweb, lineagetype, filenameorid):
    """ Return lineage information for a file
    arguments:
        lineagetype (ie "parents", "children")
        name or id of file
    """
    result = samweb.getURL(_make_file_path(filenameorid) + '/lineage/' + escape_url_component(lineagetype))
    return convert_from_unicode(result.json())
Exemple #9
0
def locateFile(samweb, filenameorid):
    """ return locations for this file
    arguments:
        name or id of file
    """
    url = _make_file_path(filenameorid) + '/locations'
    result = samweb.getURL(url)
    return convert_from_unicode(result.json())
Exemple #10
0
def listValues(samweb, vtype):
    """ list values from database. This method tries to be generic, so vtype is
    passed directly to the web server
    arguments:
        vtype: string with values to return (ie data_tiers, groups)
    """
    try:
        return convert_from_unicode(samweb.getURL('/values/%s' % escape_url_path(vtype)).json())
    except HTTPNotFound, ex:
        raise Error("Unknown value type '%s'" % vtype)
Exemple #11
0
def listFilesSummary(samweb, dimensions=None, defname=None):
    """ return summary of files matching either a dataset definition or a dimensions string
    arguments:
      dimensions: string (default None)
      defname: string definition name (default None)"""
    if defname is not None:
        result = samweb.getURL('/definitions/name/%s/files/summary' % escape_url_component(defname))
    else:
        result = samweb._callDimensions('/files/summary', dimensions)
    return convert_from_unicode(result.json())
Exemple #12
0
def getMetadata(samweb, filenameorid, locations=False):
    """ Return metadata as a dictionary 
    arguments:
        name or id of file
        locations: if True, also return file locations
    """
    params = {}
    if locations: params['locations'] = True
    response = samweb.getURL(_make_file_path(filenameorid) + '/metadata', params=params)
    return convert_from_unicode(response.json())
Exemple #13
0
def getFileLineage(samweb, lineagetype, filenameorid):
    """ Return lineage information for a file
    arguments:
        lineagetype (ie "parents", "children")
        name or id of file
    """
    result = samweb.getURL(
        _make_file_path(filenameorid) + '/lineage/' +
        escape_url_component(lineagetype))
    return convert_from_unicode(result.json())
Exemple #14
0
def listFilesSummary(samweb, dimensions=None, defname=None):
    """ return summary of files matching either a dataset definition or a dimensions string
    arguments:
      dimensions: string (default None)
      defname: string definition name (default None)"""
    if defname is not None:
        result = samweb.getURL('/definitions/name/%s/files/summary' %
                               escape_url_component(defname))
    else:
        result = samweb._callDimensions('/files/summary', dimensions)
    return convert_from_unicode(result.json())
Exemple #15
0
def listValues(samweb, vtype):
    """ list values from database. This method tries to be generic, so vtype is
    passed directly to the web server
    arguments:
        vtype: string with values to return (ie data_tiers, groups)
    """
    try:
        return convert_from_unicode(
            samweb.getURL('/values/%s' % escape_url_path(vtype)).json())
    except HTTPNotFound, ex:
        raise Error("Unknown value type '%s'" % vtype)
Exemple #16
0
def getMetadata(samweb, filenameorid, locations=False):
    """ Return metadata as a dictionary 
    arguments:
        name or id of file
        locations: if True, also return file locations
    """
    params = {}
    if locations: params['locations'] = True
    response = samweb.getURL(_make_file_path(filenameorid) + '/metadata',
                             params=params)
    return convert_from_unicode(response.json())
Exemple #17
0
def getFileAccessUrls(samweb, filenameorid, schema, locationfilter=None):
    """ return urls by which this file may be accessed
    arguments:
        name or id of file
        schema
        locationfilter (default None)
    """
    params = { "schema": schema }
    if locationfilter:
        params["location"] = locationfilter
    response = samweb.getURL(_make_file_path(filenameorid) + '/locations/url', params=params)
    return convert_from_unicode(response.json())
Exemple #18
0
def getFileAccessUrls(samweb, filenameorid, schema, locationfilter=None):
    """ return urls by which this file may be accessed
    arguments:
        name or id of file
        schema
        locationfilter (default None)
    """
    params = {"schema": schema}
    if locationfilter:
        params["location"] = locationfilter
    response = samweb.getURL(_make_file_path(filenameorid) + '/locations/url',
                             params=params)
    return convert_from_unicode(response.json())
Exemple #19
0
def projectRecoveryDimension(samweb, projectnameorurl, useFileStatus=None, useProcessStatus=None):
    """Get the dimensions to create a recovery dataset
    arguments:
        projectnameorurl : name or url of the project
        useFileStatus : use the status of the last file seen by a process (default unset)
        useProcessStatus : use the status of the process (default unset)
    """
    if not "://" in projectnameorurl:
        projectnameorurl = "/projects/name/%s" % escape_url_path(projectnameorurl)
    params = {"format": "plain"}
    if useFileStatus is not None:
        params["useFiles"] = useFileStatus
    if useProcessStatus is not None:
        params["useProcess"] = useProcessStatus
    return convert_from_unicode(samweb.getURL(projectnameorurl + "/recovery_dimensions", params=params).text.rstrip())
Exemple #20
0
def locateFiles(samweb, filenameorids):
    """ return the locations of multiple files
    The return value is a dictionary of { file_name_or_id : location } pairs
    """

    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)

    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    response = samweb.getURL("/files/locations", params=params)
    return convert_from_unicode(response.json())
Exemple #21
0
def locateFiles(samweb, filenameorids):
    """ return the locations of multiple files
    The return value is a dictionary of { file_name_or_id : location } pairs
    """

    file_names = []
    file_ids = []
    for filenameorid in filenameorids:
        try:
            file_ids.append(long(filenameorid))
        except ValueError:
            file_names.append(filenameorid)

    params = {}
    if file_names: params["file_name"] = file_names
    if file_ids: params["file_id"] = file_ids
    response = samweb.getURL("/files/locations", params=params)
    return convert_from_unicode(response.json())
Exemple #22
0
def projectRecoveryDimension(samweb,
                             projectnameorurl,
                             useFileStatus=None,
                             useProcessStatus=None):
    """Get the dimensions to create a recovery dataset
    arguments:
        projectnameorurl : name or url of the project
        useFileStatus : use the status of the last file seen by a process (default unset)
        useProcessStatus : use the status of the process (default unset)
    """
    if not '://' in projectnameorurl:
        projectnameorurl = "/projects/name/%s" % escape_url_path(
            projectnameorurl)
    params = {"format": "plain"}
    if useFileStatus is not None: params['useFiles'] = useFileStatus
    if useProcessStatus is not None: params['useProcess'] = useProcessStatus
    return convert_from_unicode(
        samweb.getURL(projectnameorurl + "/recovery_dimensions",
                      params=params).text.rstrip())
Exemple #23
0
def listParameters(samweb):
    """ list defined parameters """
    return convert_from_unicode(samweb.getURL('/values/parameters').json())
Exemple #24
0
def projectSummary(samweb, projecturl):
    if not "://" in projecturl:
        projecturl = "/projects/name/%s" % escape_url_path(projecturl)
    return convert_from_unicode(samweb.getURL(projecturl + "/summary").json())
Exemple #25
0
def listDataDisks(samweb):
    """ list defined data disks """
    return convert_from_unicode(samweb.getURL('/values/data_disks').json())
Exemple #26
0
def projectSummary(samweb, projecturl):
    if not '://' in projecturl:
        projecturl = '/projects/name/%s' % escape_url_path(projecturl)
    return convert_from_unicode(samweb.getURL(projecturl + "/summary").json())
Exemple #27
0
def listApplications(samweb, **queryCriteria):
    result = samweb.getURL('/values/applications', queryCriteria)
    return convert_from_unicode(result.json())
Exemple #28
0
def getAvailableDimensions(samweb):
    """ List the available dimensions """
    result = samweb.getURL('/files/list/dimensions?format=json&descriptions=1')
    return convert_from_unicode(result.json())
Exemple #29
0
def listApplications(samweb, **queryCriteria):
    result = samweb.getURL('/values/applications', queryCriteria)
    return convert_from_unicode(result.json())
Exemple #30
0
def getAvailableValues(samweb):
    """ get the available names that can be used with listValues, addValues """
    return convert_from_unicode(samweb.getURL('/values?list=generic').json())
Exemple #31
0
def describeUser(samweb, username):
    result = samweb._describeUser(username)
    return convert_from_unicode(result.json())
Exemple #32
0
def listUsers(samweb):
    result = samweb.getURL('/users')
    return convert_from_unicode(result.json())
Exemple #33
0
def describeUser(samweb, username):
    result = samweb._describeUser(username)
    return convert_from_unicode(result.json())
Exemple #34
0
def getAvailableDimensions(samweb):
    """ List the available dimensions """
    result = samweb.getURL('/files/list/dimensions?format=json&descriptions=1')
    return convert_from_unicode(result.json())
Exemple #35
0
def listParameters(samweb):
    """ list defined parameters """
    return convert_from_unicode(samweb.getURL('/values/parameters').json())
Exemple #36
0
def listUsers(samweb):
    result = samweb.getURL('/users')
    return convert_from_unicode(result.json())
Exemple #37
0
def listDataDisks(samweb):
    """ list defined data disks """
    return convert_from_unicode(samweb.getURL('/values/data_disks').json())
Exemple #38
0
def getAvailableValues(samweb):
    """ get the available names that can be used with listValues, addValues """
    return convert_from_unicode(samweb.getURL('/values?list=generic').json())