From c8731ee48f49716316f31111b6328a6a170b0d91 Mon Sep 17 00:00:00 2001 From: Richard Dzurus Date: Wed, 7 May 2025 18:32:00 +0200 Subject: [PATCH 1/2] secret -> secrecy - updated python client --- polyapi/typedefs.py | 6 +++++- polyapi/variables.py | 7 ++++--- pyproject.toml | 2 +- tests/test_variables.py | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/polyapi/typedefs.py b/polyapi/typedefs.py index 3a6d84a..c036a1c 100644 --- a/polyapi/typedefs.py +++ b/polyapi/typedefs.py @@ -40,11 +40,15 @@ class SpecificationDto(TypedDict): language: str +# New enum for variable secrecy levels +Secrecy = Literal['SECRET', 'OBSCURED', 'NONE'] + + class VariableSpecification(TypedDict): environmentId: str value: Any valueType: PropertyType - secret: bool + secrecy: Secrecy class VariableSpecDto(TypedDict): diff --git a/polyapi/variables.py b/polyapi/variables.py index 95f7d2f..673a195 100644 --- a/polyapi/variables.py +++ b/polyapi/variables.py @@ -2,11 +2,11 @@ from typing import List from polyapi.schema import map_primitive_types -from polyapi.typedefs import PropertyType, VariableSpecDto +from polyapi.typedefs import PropertyType, VariableSpecDto, Secrecy from polyapi.utils import add_import_to_init, init_the_init -# GET is only included if the variable is not a secret +# GET is only included if the variable is not SECRET GET_TEMPLATE = """ @staticmethod def get() -> {variable_type}: @@ -76,9 +76,10 @@ def generate_variables(variables: List[VariableSpecDto]): def render_variable(variable: VariableSpecDto): variable_type = _get_variable_type(variable["variable"]["valueType"]) + # Only include get() method if secrecy is not SECRET get_method = ( "" - if variable["variable"]["secret"] + if variable["variable"]["secrecy"] == "SECRET" else GET_TEMPLATE.format( variable_id=variable["id"], variable_type=variable_type ) diff --git a/pyproject.toml b/pyproject.toml index 0df59df..e5da7b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"] [project] name = "polyapi-python" -version = "0.3.4.dev2" +version = "0.3.4.dev3" description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers" authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }] dependencies = [ diff --git a/tests/test_variables.py b/tests/test_variables.py index beea44d..72eac81 100644 --- a/tests/test_variables.py +++ b/tests/test_variables.py @@ -12,7 +12,7 @@ }, "variable": { "environmentId": "123818231", - "secret": False, + "secrecy": "NONE", "valueType": { "kind": "primitive", "type": "string" From c3fd1b608992ebab4745c728d6e9d740dbd04467 Mon Sep 17 00:00:00 2001 From: Richard Dzurus Date: Wed, 7 May 2025 18:34:41 +0200 Subject: [PATCH 2/2] comment fixed --- polyapi/typedefs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polyapi/typedefs.py b/polyapi/typedefs.py index c036a1c..6d6ff18 100644 --- a/polyapi/typedefs.py +++ b/polyapi/typedefs.py @@ -40,7 +40,7 @@ class SpecificationDto(TypedDict): language: str -# New enum for variable secrecy levels +# Enum for variable secrecy levels Secrecy = Literal['SECRET', 'OBSCURED', 'NONE']