Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion polyapi/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ class SpecificationDto(TypedDict):
language: str


# 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):
Expand Down
7 changes: 4 additions & 3 deletions polyapi/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}:
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]

[project]
name = "polyapi-python"
version = "0.3.5.dev1"
version = "0.3.6.dev0"
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"variable": {
"environmentId": "123818231",
"secret": False,
"secrecy": "NONE",
"valueType": {
"kind": "primitive",
"type": "string"
Expand Down