def get_deployments(): params = { } headers = {"Authorization": base.get_auth_token()} r = requests.get(f"{base.CLUSTER_URL}/cmd/deployment", params, headers=headers) return r.json()
def create_package(username, alias): data = {"username": username, "alias": alias} headers = {"Authorization": base.get_auth_token()} r = requests.post(f"{base.HUB_URL}/cmd/package", json=data, headers=headers) return r.content
def undeploy(id): params = { } headers = {"Authorization": base.get_auth_token()} r = requests.delete(f"{base.CLUSTER_URL}/cmd/deployment/{id}", headers = headers) #r = requests.delete(f"{base.CLUSTER_URL}/deployment/{id}", params) return r.content
def me(): headers = {"Authorization": base.get_auth_token()} r = requests.get(f"{base.HUB_URL}/user/me", headers=headers) r.raise_for_status() print(r.content) return get_user_by_id(r.json()['id'])
def deploy(manifest): data = { "manifest": manifest } headers = {"Authorization": base.get_auth_token()} r = requests.post ( f"{base.CLUSTER_URL}/cmd/deployment", json = data, headers = headers ) print("Deployed : ", r.json()) return r.content
def trigger(id, payload): params = { } data = { "payload": payload } headers = {"Authorization": base.get_auth_token()} r = requests.post ( f"{base.CLUSTER_URL}/cmd/deployment/{id}/trigger", json = data, headers = headers ) print("Triggered: ", r.json()) return r.content
def upload_package_image(username, alias, file): params = { # "tag": tag, # "hash": hash } mfst = image.load_manifest('./batik.yaml') data = {"manifest": json.dumps(mfst)} encoder = MultipartEncoder({ "manifest": json.dumps(mfst), 'file': (f'{alias}.tar.xz', file, "application/octet-stream") }) callback = create_callback(encoder) monitor = MultipartEncoderMonitor(encoder, callback) r = requests.post( f"{base.HUB_URL}/cmd/package/{username}/{alias}/upload", #files = monitor, #files = { # "file": file #}, data=monitor, headers={ "Authorization": base.get_auth_token(), "Prefer": "respond-async", "Content-Type": encoder.content_type }) print(r.content) return r.json()
def download(id, manifest): params = { } data = { "manifest": manifest } headers = {"Authorization": base.get_auth_token()} dep = requests.get(f"{base.CLUSTER_URL}/cmd/deployment/{id}", params, header=headers) r = requests.post ( f"{base.CLUSTER_URL}/cmd/deployment/{id}/download", json = data, headers = headers ) print("Triggered: ", r.json()) return r.content