예제 #1
0
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()
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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'])
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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()
예제 #8
0
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