def update_registry(userId, registry, registrydata, validate=True): global localconfig, headers if localconfig == None: localconfig = anchore_engine.configuration.localconfig.get_config() ret = {} if type(userId) == tuple: userId, pw = userId else: pw = "" auth = (userId, pw) base_url = anchore_engine.clients.common.get_service_endpoint( userId, 'catalog') url = "{}/system/registries/{}?validate={}".format(base_url, registry, validate) payload = registrydata ret = http.anchy_put(url, data=json.dumps(payload), auth=auth, headers=headers, verify=localconfig['internal_ssl_verify']) return (ret)
def update_subscription(userId, subscriptiondata, subscription_type=None, subscription_key=None, subscription_id=None): global localconfig, headers if localconfig == None: localconfig = anchore_engine.configuration.localconfig.get_config() ret = {} if type(userId) == tuple: userId, pw = userId else: pw = "" auth = (userId, pw) if subscription_key and subscription_type: subscription_id = hashlib.md5('+'.join( [userId, subscription_key, subscription_type])).hexdigest() base_url = anchore_engine.clients.common.get_service_endpoint( userId, 'catalog') url = base_url + "/subscriptions/" + subscription_id ret = http.anchy_put(url, data=json.dumps(subscriptiondata), auth=auth, headers=headers, verify=localconfig['internal_ssl_verify']) return (ret)
def update_policy(userId, policyId, policy_record={}): global localconfig, headers if localconfig == None: localconfig = anchore_engine.configuration.localconfig.get_config() ret = {} if type(userId) == tuple: userId, pw = userId else: pw = "" auth = (userId, pw) base_url = anchore_engine.clients.common.get_service_endpoint( userId, 'catalog') url = base_url + "/policies/" + policyId payload = policy_record ret = http.anchy_put(url, data=json.dumps(payload), auth=auth, headers=headers, verify=localconfig['internal_ssl_verify']) return (ret)
def update_image(userId, imageDigest, image_record={}): global localconfig, headers if localconfig is None: localconfig = anchore_engine.configuration.localconfig.get_config() ret = {} if type(userId) == tuple: userId, pw = userId else: pw = "" auth = (userId, pw) base_url = anchore_engine.clients.common.get_service_endpoint( userId, 'catalog') url = base_url + "/image/" + imageDigest payload = {} payload.update(image_record) ret = http.anchy_put(url, data=json.dumps(payload), auth=auth, headers=headers, verify=localconfig['internal_ssl_verify']) return (ret)
def update_policy(userId, policyId, policy_record={}): global localconfig, headers if localconfig == None: localconfig = anchore_engine.configuration.localconfig.get_config() ret = {} if type(userId) == tuple: userId, pw = userId else: pw = "" auth = (userId, pw) base_url = get_catalog_endpoint() url = base_url + "/policies" payload = policy_record ret = http.anchy_put(url, data=json.dumps(payload), auth=auth, headers=headers, verify=localconfig['internal_ssl_verify']) #(httpcode, jsondata, rawdata) = http.fput(url, data=json.dumps(payload), auth=auth, headers=headers, verify=localconfig['internal_ssl_verify']) #if httpcode == 200 and jsondata != None: # ret = jsondata #else: # #raise Exception("failed put: httpcode="+str(httpcode)+" rawdata="+str(rawdata)) # e = Exception("failed put url="+str(url)) # e.__dict__.update({'httpcode':httpcode, 'anchore_error_raw':str(rawdata), 'anchore_error_json':jsondata}) # raise e return(ret)
def update_registry(userId, registry, registrydata): global localconfig, headers if localconfig == None: localconfig = anchore_engine.configuration.localconfig.get_config() ret = {} if type(userId) == tuple: userId, pw = userId else: pw = "" auth = (userId, pw) base_url = get_catalog_endpoint() url = base_url + "/system/registries/" + registry payload = registrydata ret = http.anchy_put(url, data=json.dumps(payload), auth=auth, headers=headers, verify=localconfig['internal_ssl_verify']) return (ret)