コード例 #1
0
def delete_invitation(*, client: HttpClient, email: str):
    """ DELETE /users/invitations """
    body = {"email": email}
    return client.request(method=HttpMethod.DELETE,
                          path="users/invitations",
                          body=body,
                          msg="Delete invitation")
コード例 #2
0
def get_service_bindings(*, client: HttpClient, service_id: str):
    """ GET /services/{service_id}/bindings """
    response = client.request(method=HttpMethod.GET,
                              path="services/{service_id}/bindings",
                              path_params={'service_id': service_id},
                              msg="Get service bindings")
    return response["resources"]
コード例 #3
0
def resend_invitation(*, client: HttpClient, email: str):
    """ POST /users/invitations/resend """
    body = {"email": email}
    return client.request(method=HttpMethod.POST,
                          path="users/invitations/resend",
                          body=body,
                          msg="Resend invitation")
コード例 #4
0
def get_app_bindings(*, client: HttpClient, app_id: str):
    """ GET /applications/{app_id}/bindings """
    response = client.request(method=HttpMethod.GET,
                              path="applications/{app_id}/bindings",
                              path_params={'app_id': app_id},
                              msg="Get application bindings")
    return response["resources"]
コード例 #5
0
def delete_user(*, client: HttpClient, user_email: str):
    """ DELETE /users """
    body = {"email": user_email}
    return client.request(method=HttpMethod.GET,
                          body=body,
                          path="users",
                          msg="Delete user")
コード例 #6
0
def change_password(*, client: HttpClient, current_password: str,
                    new_password: str):
    """ PUT /users/current/password """
    body = {"current_password": current_password, "new_password": new_password}
    return client.request(method=HttpMethod.PUT,
                          body=body,
                          path="users/current/password",
                          msg="Change password")
コード例 #7
0
def get_cli_resource(*, client: HttpClient, resource_id: str):
    """ GET /resources/cli/{resource_id} """
    return client.request(method=HttpMethod.GET,
                          path="resources/cli/{resource_id}",
                          path_params={'resource_id': resource_id},
                          msg="Get CLI resource",
                          raw_response=True,
                          log_response_content=False)
コード例 #8
0
def bind_svc(*, client: HttpClient, app_id, service_instance_id: str):
    """ POST applications/{app_id}/bindings """
    body = {'service_id': service_instance_id}
    return client.request(method=HttpMethod.POST,
                          path="applications/{app_id}/bindings",
                          path_params={'app_id': app_id},
                          body=body,
                          msg="Bind service and app")
コード例 #9
0
def delete_application(*, client: HttpClient, app_id: str):
    """ DELETE /applications/{app_id} """
    response = client.request(HttpMethod.DELETE,
                              path="applications/{app_id}",
                              path_params={'app_id': app_id},
                              msg="Delete application",
                              raw_response=True)
    assert response.status_code == HttpStatus.CODE_NO_CONTENT
コード例 #10
0
def delete_offering(*, client: HttpClient, offering_id):
    """ DELETE /offerings/{offering_id} """
    response = client.request(HttpMethod.DELETE,
                              path="offerings/{offering_id}",
                              path_params={'offering_id': offering_id},
                              raw_response=True)
    assert response.status_code == HttpStatus.CODE_ACCEPTED
    return response.json()
コード例 #11
0
def restart_application(*, client: HttpClient, app_id: str):
    """ PUT /applications/{app_id}/restart """
    response = client.request(HttpMethod.PUT,
                              path="applications/{app_id}/restart",
                              path_params={'app_id': app_id},
                              raw_response=True,
                              msg="Restart application")
    assert response.status_code == HttpStatus.CODE_ACCEPTED
    return response.json()
コード例 #12
0
def get_application_logs(*, client: HttpClient, app_id: str):
    """ GET /applications/{app_id}/logs """
    response = client.request(HttpMethod.GET,
                              path="applications/{app_id}/logs",
                              path_params={'app_id': app_id},
                              raw_response=True,
                              msg="Get application logs")
    assert response.status_code == HttpStatus.CODE_OK
    return response.json()
コード例 #13
0
def unbind_svc(*, client: HttpClient, app_id: str, service_instance_id: str):
    """ DELETE /applications/{app_id}/bindings/services/{service_instance_id} """
    return client.request(
        method=HttpMethod.DELETE,
        path="applications/{app_id}/bindings/services/{service_instance_id}",
        path_params={
            'app_id': app_id,
            'service_instance_id': service_instance_id
        },
        msg="Unbind service from app")
コード例 #14
0
def scale_application(*, client: HttpClient, app_id: str, replicas):
    """ PUT /applications/{app_id}/scale """
    body = {"replicas": replicas}
    response = client.request(HttpMethod.PUT,
                              path="applications/{app_id}/scale",
                              path_params={'app_id': app_id},
                              body=body,
                              raw_response=True,
                              msg="Scale application")
    return response.json()
コード例 #15
0
def get_metrics_platform(*,
                         client: HttpClient,
                         time_from: str = None,
                         time_to: str = None):
    """ GET /metrics/platform """
    body = {"from": time_from, "to": time_to}
    return client.request(method=HttpMethod.GET,
                          path="metrics/platform",
                          body=body,
                          msg="Get platform metrics")
コード例 #16
0
def expose_service(*,
                   client: HttpClient,
                   service_id: str,
                   should_expose: bool = True):
    """ PUT /services/{service_id}/expose """
    body = {"exposed": should_expose}
    return client.request(method=HttpMethod.PUT,
                          path="services/{service_id}/expose",
                          path_params={'service_id': service_id},
                          msg="Expose service instance",
                          body=body)
コード例 #17
0
def unbind_svc_from_service(*, client: HttpClient, service_id: str,
                            service_id_to_unbound: str):
    """ DELETE /services/{service_id}/bindings/services/{service_id_to_unbound} """
    return client.request(
        method=HttpMethod.DELETE,
        path="services/{service_id}/bindings/services/{service_id_to_unbound}",
        path_params={
            'service_id': service_id,
            'service_id_to_unbound': service_id_to_unbound
        },
        msg="Unbind service from service")
コード例 #18
0
def get_metrics_single(*,
                       client: HttpClient,
                       metric_name: str,
                       time_from: str = None,
                       time_to: str = None):
    """ GET /metrics/single """
    body = {"metric": metric_name, "from": time_from, "to": time_to}
    return client.request(method=HttpMethod.GET,
                          path="metrics/single",
                          body=body,
                          msg="Get single metric")
コード例 #19
0
def get_metrics_organizations(*,
                              client: HttpClient,
                              org_id: str,
                              time_from: str = None,
                              time_to: str = None):
    """ GET /metrics/organizations/{org_id} """
    body = {"from": time_from, "to": time_to}
    return client.request(method=HttpMethod.GET,
                          path="metrics/organizations/{org_id}",
                          path_params={'org_id': org_id},
                          body=body,
                          msg="Get organization metrics")
コード例 #20
0
def unbind_app_from_service(*, client: HttpClient, service_id: str,
                            application_id_to_unbound: str):
    """ DELETE /services/{service_id}/bindings/applications/{application_id_to_unbound} """
    return client.request(
        method=HttpMethod.DELETE,
        path=
        "services/{service_id}/bindings/applications/{application_id_to_unbound}",
        path_params={
            'service_id': service_id,
            'application_id_to_unbound': application_id_to_unbound
        },
        msg="Unbind app from service")
コード例 #21
0
def get_applications(*, client: HttpClient, org_id: str = None):
    """ GET /applications """
    query_params = {}
    if org_id is not None:
        query_params["org_id"] = org_id

    response = client.request(HttpMethod.GET,
                              path="applications",
                              params=query_params,
                              raw_response=True,
                              msg="List applications")
    assert response.status_code == HttpStatus.CODE_OK
    return response.json()
コード例 #22
0
def get_platform_info(*, client: HttpClient) -> dict:
    """GET /platform_info

    Attempts to retrieve the platform info

    Args:
        client: HttpClient to use

    Return:
        Platform info as a dictionary
    """
    return client.request(method=HttpMethod.GET,
                          path="platform_info",
                          msg="Get platform info")
コード例 #23
0
def get_platform_components(*, client: HttpClient) -> dict:
    """GET /platform_components

    Attempts to retrieve the platform components

    Args:
        client: HttpClient to use

    Return:
        Platform components as a dictionary
    """
    return client.request(method=HttpMethod.GET,
                          path="platform_components",
                          msg="Get platform components")
コード例 #24
0
def restart_service(*, client: HttpClient, srv_id: str):
    """ PUT /services/{srv_id}/restart
    Attempts to restart service instance

    Args:
        client: HttpClient to use
        srv_id: id of the service instance to restart
    """
    response = client.request(HttpMethod.PUT,
                              path="services/{srv_id}/restart",
                              path_params={'srv_id': srv_id},
                              raw_response=True,
                              msg="Restart service instance")
    assert response.status_code == HttpStatus.CODE_ACCEPTED
    return response.json()
コード例 #25
0
def create_application_with_manifest(*, client: HttpClient, file_path: str,
                                     manifest: dict):
    """ POST /applications """
    manifest_str = json.dumps(manifest)
    files = {
        "blob": (file_path, open(file_path, 'rb'), "multipart/form-data"),
        "manifest": (file_path, StringIO(manifest_str), "multipart/form-data")
    }
    response = client.request(HttpMethod.POST,
                              path="applications",
                              files=files,
                              raw_response=True,
                              msg="Create an application")
    assert response.status_code == HttpStatus.CODE_ACCEPTED
    return response.json()
コード例 #26
0
def create_offering_from_binary(*, jar_path: str, manifest_path: str,
                                offering_path, client: HttpClient):
    """ POST /offerings/binary """
    files = {
        "blob": (jar_path, open(jar_path, 'rb'), "multipart/form-data"),
        "manifest": (manifest_path, open(manifest_path,
                                         'rb'), "multipart/form-data"),
        "offering": (offering_path, open(offering_path,
                                         'rb'), "multipart/form-data"),
    }
    response = client.request(HttpMethod.POST,
                              path="offerings/binary",
                              files=files,
                              raw_response=True,
                              msg="Create an offering")
    assert response.status_code == HttpStatus.CODE_ACCEPTED
    return response.json()
コード例 #27
0
 def open_and_read(client: HttpClient, path):
     params = WebhdfsTools.get_params(WebhdfsOperation.open.value)
     response = client.request(method=HttpMethod.GET,
                               params=params,
                               path=path)
     if response.status_code == HttpStatus.CODE_TEMPORARY_REDIRECT:
         return WebhdfsSession.redirection_handler(
             WebhdfsTools.create_client,
             WebhdfsTools.TEST_PORT,
             WebhdfsTools.VIA_HOST_USERNAME,
             WebhdfsTools.PATH_TO_KEY,
             WebhdfsTools.VIA_HOSTNAME,
             WebhdfsTools.TEST_HOST,
             method=HttpMethod.GET,
             params=params,
             redirection_location=response.headers._store["location"][1],
             hdfs_path=path)
     return response
コード例 #28
0
def bind_service(*,
                 client: HttpClient,
                 service_id: str,
                 application_id_to_bound=None,
                 service_id_to_bound=None):
    """ POST /services/{service_id}/bindings """
    body = {}
    if application_id_to_bound is not None:
        body["application_id"] = application_id_to_bound
    if service_id_to_bound is not None:
        body["service_id"] = service_id_to_bound

    response = client.request(method=HttpMethod.POST,
                              path="services/{service_id}/bindings",
                              path_params={'service_id': service_id},
                              body=body,
                              raw_response=True,
                              msg="Bind service or application to service")
    return response
コード例 #29
0
def get_services(*,
                 client: HttpClient,
                 name: str = None,
                 offering_id: str = None,
                 plan_name: str = None,
                 limit: int = None,
                 skip: int = None):
    """ GET /services """
    query_params = {
        "offering_id": offering_id,
        "plan_name": plan_name,
        "name": name,
        "limit": limit,
        "skip": skip
    }
    query_params = {k: v for k, v in query_params.items() if v is not None}
    return client.request(method=HttpMethod.GET,
                          path="services",
                          params=query_params,
                          msg="List service instances")
コード例 #30
0
def create_offering(*, client: HttpClient, template_body: dict,
                    service_name: str, description: str, bindable: bool,
                    tags: list, plans: list):
    """ POST /offerings """
    body = {
        "template": {
            "body": template_body,
            "hooks": None
        },
        "services": [{
            "name": service_name,
            "description": description,
            "bindable": bindable,
            "tags": tags,
            "plans": plans,
            "metadata": []
        }]
    }
    response = client.request(HttpMethod.POST,
                              path="offerings",
                              body=body,
                              raw_response=True)
    assert response.status_code == HttpStatus.CODE_ACCEPTED
    return response.json()