DS_PROJECT, err))

    ENV_VAR_NAME = 'tst_env_var'

    print("Adding the environment variable in the project")
    res, err = dsapi.DSAddEnvVar(hproj, ENV_VAR_NAME,
                                 dsapi.DSA_ENVVAR_TYPE_STRING,
                                 'Environment variable created with the API',
                                 'value_123')
    if err:
        raise Exception(
            "Can't add the environment variable in the project: {}".format(
                err))

    print("Editing the environment variable in the project")
    res, err = dsapi.DSSetEnvVar(hproj, ENV_VAR_NAME, 'value_new_321')
    if err:
        raise Exception(
            "Can't edit the environment variable in the project: {}".format(
                err))

    print(
        "Getting a list of environment variables and their values in the project"
    )
    res, err = dsapi.DSListEnvVars(hproj)
    if err:
        raise Exception(
            "Can't get a list of environment variables in the project: {}".
            format(err))
    print("Environment variables: {}".format(res))
Esempio n. 2
0
    if err:
        raise Exception("Can't open the project {}: {}".format(DS_PROJECT, err))

    ENV_VAR_NAME = 'tst_api_env_var'
    ENV_VAR_VALUE = 'tst_api_env_var_val'

    print("Adding the environment variable in the project")
    _, err = dsapi.DSAddEnvVar(hproj, ENV_VAR_NAME, dsapi.DSA_ENVVAR_TYPE_STRING,
                               'Environment variable created with the API', ENV_VAR_VALUE)
    if err:
        raise Exception("Can't add the environment variable in the project: {}".format(err))

    ENV_VAR_VALUE = 'tst_api_env_var_val_edit'

    print("Editing the environment variable in the project")
    _, err = dsapi.DSSetEnvVar(hproj, ENV_VAR_NAME, ENV_VAR_VALUE)
    if err:
        raise Exception("Can't edit the environment variable in the project: {}".format(err))

    print("Getting a list of environment variables and their values in the project")
    res, err = dsapi.DSListEnvVars(hproj)
    if err:
        raise Exception("Can't get a list of environment variables in the project: {}".format(err))
    print("Environment variables: {}".format(res))

    print("Deleting the environment variable in the project")
    res, err = dsapi.DSDeleteEnvVar(hproj, ENV_VAR_NAME)
    if err:
        raise Exception("Can't delete the environment variable in the project: {}".format(err))

    print("Closing the project")