Exemple #1
0
    def __init__(self,
                 address=defaults.default_mms_address,
                 user=defaults.default_mms_username,
                 password=defaults.default_mms_password,
                 cache_element_details_locally=True):
        if (address.endswith('/')):
            self.address = address
        else:
            self.address = address + '/'

        configuration = mms_python_client.Configuration()
        configuration.host = address
        configuration.username = user
        configuration.password = password

        core_api_client_mms = mms_python_client.ApiClient(configuration)
        for api_field_name, api_class_name in _mms_client_api_classes.items():
            if api_class_name in dir(
                    mms_python_client
            ):  # there might be api classes presently missing / disabled
                api_class = getattr(mms_python_client, api_class_name)
                api_object = api_class(core_api_client_mms)
                setattr(self, api_field_name, api_object)
        # get_elements_in_batch

        self.helpers = MMSHelpers(self, cache_element_details_locally)
Exemple #2
0
def get_notebook(url, project, id, token):
    configuration = mms_client.Configuration()
    configuration.host = url
    configuration.access_token = token
    api_instance = mms_client.NotebooksControllerApi(mms_client.ApiClient(configuration))
    try:
        api_response = api_instance.get_notebook(project, 'master', id)
        return api_response.notebooks[0]
    except ApiException as e:
        print("Exception when calling NotebooksControllerApi->get_notebook: %s\n" % e)
Exemple #3
0
def get_mms_token(url, username, password):
    configuration = mms_client.Configuration()
    configuration.host = url
    jwt_authentication_request = mms_client.JwtAuthenticationRequest()
    jwt_authentication_request.username = username
    jwt_authentication_request.password = password
    try:
        api_instance = mms_client.AuthenticationControllerApi(mms_client.ApiClient(configuration))
        api_response = api_instance.create_authentication_token(jwt_authentication_request=jwt_authentication_request)
        return api_response.token
    except ApiException as e:
        print("Exception when calling create_authentication_token: %s\n" % e)
Exemple #4
0
def save_notebook(url, project, notebook, token):
    configuration = mms_client.Configuration()
    configuration.host = url
    configuration.access_token = token
    api_instance = mms_client.NotebooksControllerApi(mms_client.ApiClient(configuration))
    try:
        r = mms_client.NotebooksRequest()
        r.notebooks = [notebook]
        api_response = api_instance.create_or_update_notebooks(project, 'master', notebooks_request=r)
        return api_response.notebooks[0]
    except ApiException as e:
        print("Exception when calling NotebooksControllerApi->create_or_update_notebooks: %s\n" % e)
Exemple #5
0
def get_notebooks(url, project, token):
    configuration = mms_client.Configuration()
    configuration.host = url
    configuration.access_token = token
    api_instance = mms_client.NotebooksControllerApi(mms_client.ApiClient(configuration))
    try:
        api_response = api_instance.get_all_notebooks(project, 'master')
        ret = {}
        for i in api_response.notebooks:
            ret[i['id']] = i
        return ret
    except ApiException as e:
        print("Exception when calling NotebooksControllerApi->get_all_notebooks: %s\n" % e)