How to use the anchorecli.clients.common.make_client_result function in anchorecli

To help you get started, we’ve selected a few anchorecli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
if version:
        query_params['version'] = version
    if package_type:
        query_params['package_type'] = package_type
    
    if query_params:
        url = "{}&{}".format(url, urlencode(query_params))

    set_account_header(config)

    try:
        _logger.debug("GET url="+str(url))
        _logger.debug("GET insecure="+str(config['ssl_verify']))

        r = requests.get(url, params=params, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
if policyId:
        url = '/'.join([base_url, "policies", policyId])
    else:
        return(False)

    if detail:
        url = url + "?detail=True"
    else:
        url = url + "?detail=False"

    set_account_header(config)

    try:
        _logger.debug("GET url="+str(url))
        r = requests.get(url, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
        
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
# api_version_query_support = (0, 1, 6)

    ret = {}
    params = {}
    # api_version = detect_api_version(config)

    base_url = re.sub("/$", "", base_url)
    url = '/'.join([base_url, "events", event_id])
    set_account_header(config)

    try:
        _logger.debug("DELETE url="+str(url))
        _logger.debug("DELETE insecure="+str(config['ssl_verify']))

        r = requests.delete(url, params=params, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
def system_feeds_sync(config, flush=False):
    userId = config['user']
    password = config['pass']
    base_url = config['url']

    ret = {}

    base_url = re.sub("/$", "", base_url)
    url = '/'.join([base_url, "system/feeds?flush={}".format(flush)])
    set_account_header(config)
    try:
        _logger.debug("POST url="+str(url))
        _logger.debug("POST insecure="+str(config['ssl_verify']))
        r = requests.post(url, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
if severity:
        query_params['severity'] = severity
    if vendor_only:
        query_params['vendor_only'] = vendor_only
    
    if query_params:
        url = "{}&{}".format(url, urlencode(query_params))

    set_account_header(config)

    try:
        _logger.debug("GET url="+str(url))
        _logger.debug("GET insecure="+str(config['ssl_verify']))

        r = requests.get(url, params=params, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
userId = config['user']
    password = config['pass']
    base_url = config['url']

    ret = {}

    base_url = re.sub("/$", "", base_url)
    url = '/'.join([base_url, "policies", policyId])

    payload = policy_record
    set_account_header(config)

    try:
        _logger.debug("PUT url="+str(url))
        r = requests.put(url, data=json.dumps(payload), auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
if ret['success']:
                    events += ret['payload']['results']
                    ret['payload']['results'] = events
                else:
                    break

                if ret['payload']['next_page'] is False:
                    break
        else:
            _logger.debug("GET url=" + str(url))
            _logger.debug("GET params=" + str(params))
            _logger.debug("GET insecure=" + str(config['ssl_verify']))

            r = requests.get(url, params=params, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
            ret = anchorecli.clients.common.make_client_result(r, raw=False)

    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
if not imageDigest:
        raise Exception("must specify a valid imageDigest to delete")

    base_url = re.sub("/$", "", base_url)
    url = '/'.join([base_url, "images", imageDigest])

    if force:
        url = url+"?force=True"

    set_account_header(config)

    try:
        _logger.debug("DELETE url="+str(url))
        r = requests.delete(url, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
base_url = re.sub("/$", "", base_url)
    url = '/'.join([base_url, "subscriptions"])
    set_account_header(config)

    if subscription_key or subscription_type:
        url = url + "?"
        if subscription_key:
            url = url + "subscription_key="+subscription_key+"&"
        if subscription_type:
            url = url + "subscription_type="+subscription_type+"&"

    try:
        _logger.debug("GET url="+str(url))
        r = requests.get(url, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)
github anchore / anchore-cli / anchorecli / clients / apiexternal.py View on Github external
base_url = config['url']

    ret = {}

    base_url = re.sub("/$", "", base_url)
    set_account_header(config)

    if account_name:
        url = '/'.join([base_url, "accounts", quote(account_name, "")])
    else:
        url = '/'.join([base_url, "account"])

    try:
        _logger.debug("GET url="+str(url))
        r = requests.get(url, auth=(userId, password), verify=config['ssl_verify'], headers=header_overrides)
        ret = anchorecli.clients.common.make_client_result(r, raw=False)
    except Exception as err:
        raise err

    return(ret)