Skip to content

Conversation

@achrafcei
Copy link
Contributor

  • Updated requires-python to allow Python 3.13.
  • Added support for Python 3.11 and 3.12 in classifiers.
  • Expanded __all__ in __init__.py to include new variable library functions.
  • Introduced _encode_b64 and _create_variable_library_definition functions in _functions.py updated with create and update variable libraries

Tested and validated :

Test example :

import sempy_labs.variable_library as vl

variables_with_valuesets = [
    {
        "name": "api_endpoint",
        "type": "String",
        "value": "https://api-dev.example.com/v1",
        "note": "API endpoint URL"
    },
    {
        "name": "timeout_seconds", 
        "type": "Number",
        "value": 30,
        "note": "Request timeout in seconds"
    },
    {
        "name": "max_connections_new",
        "type": "Number",
        "value": 100,
        "note": "Maximum number of database connections"
    },
    {
        "name": "retry_count",
        "type": "Number", 
        "value": 3
    }
]

value_sets_example = [
    {
        "name": "Production",
        "variableOverrides": [
            {"name": "api_endpoint", "value": "https://api.example.com/v1"}
        ]
    },
    {
        "name": "Staging",
        "variableOverrides": [
            {"name": "api_endpoint", "value": "https://api-staging.example.com/v1"}
        ]
    }
]
result = vl.create_variable_library(
    variable_library_name="DEVConfig",
    description="Configuration variables for development environment",
    variables=variables_with_valuesets,
    value_sets=value_sets_example,
    workspace="Temp-ws"
)
result = vl.update_variable_library_definition(
    variable_library="newname",
    variables=variables_with_valuesets,
    value_sets=value_sets_example,
    workspace="Temp-ws"
)
result = vl.update_variable_library(variable_library="newname", active_value_set="Production")

…ionality

- Updated `requires-python` to allow Python 3.13.
- Added support for Python 3.11 and 3.12 in classifiers.
- Expanded `__all__` in `__init__.py` to include new variable library functions.
- Introduced `_encode_b64` and `_create_variable_library_definition` functions in `_functions.py` updated with create and update variable libraries
Parameters
----------
variables : List[Dict], optional
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of 'optional', use default=None. You can see this is the standard across semantic link labs.

Returns
-------
str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no point in returning a string

status_codes=[200],
)

if response.status_code == 200:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please follow the convention for other such functions. no need for an if statement here. just print that the variable library was updated successfully. if an issue occurred, an error would be caught by _base_api.

lro_return_json=False,
)

if response.status_code == 200:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before, don't need these if statements.

@m-kovalsky
Copy link
Collaborator

While the update definition function is fine, it may be useful to have functions like 'set_variable' where one can add/update an existing variable definition. And along the same lines, set_value_set. That would make adding/updating a variable much easier than trying to do it via updating the entire definition.

@achrafcei
Copy link
Contributor Author

I'll update the code with the fixed and suggestions, thanks @m-kovalsky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants