Skip to content

Commit 546c839

Browse files
4940 add visibility argument (#81)
* Added visibility argument * bumped version * bumped version
1 parent f40d530 commit 546c839

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

polyapi/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ def generate_command(args):
113113
fn_add_parser.add_argument("--execution-api-key", required=False, default="", help="API key for execution (for server functions only).")
114114
fn_add_parser.add_argument("--disable-ai", "--skip-generate", action="store_true", help="Pass --disable-ai skip AI generation of missing descriptions")
115115
fn_add_parser.add_argument("--generate-contexts", type=str, help="Server function only – only include certain contexts to speed up function execution")
116+
fn_add_parser.add_argument("--visiblity", type=str, help="Specifies the visibility of a function. Options: PUBLIC, TENANT, ENVIRONMENT. Case insensitive")
116117

117118
def add_function(args):
118119
initialize_config()
119120
logs_enabled = args.logs == "enabled" if args.logs else None
120121
err = ""
122+
visibility = args.visibility.upper()
121123
if args.server and args.client:
122124
err = "Specify either `--server` or `--client`. Found both."
123125
elif not args.server and not args.client:
@@ -126,6 +128,8 @@ def add_function(args):
126128
err = "Option `logs` is only for server functions (--server)."
127129
elif args.generate_contexts and not args.server:
128130
err = "Option `generate-contexts` is only for server functions (--server)."
131+
elif visibility not in ["PUBLIC", "TENANT", "ENVIRONMENT"]:
132+
err = "Invalid visiblity argument, visibility must be one of ['PUBLIC', 'TENANT', 'ENVIRONMENT']"
129133

130134
if err:
131135
print_red("ERROR")
@@ -142,7 +146,8 @@ def add_function(args):
142146
logs_enabled=logs_enabled,
143147
generate=not args.disable_ai,
144148
execution_api_key=args.execution_api_key,
145-
generate_contexts=args.generate_contexts
149+
generate_contexts=args.generate_contexts,
150+
visibility=visibility
146151
)
147152

148153
fn_add_parser.set_defaults(command=add_function)

polyapi/function_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def function_add_or_update(
2525
server: bool,
2626
logs_enabled: Optional[bool],
2727
generate_contexts: Optional[str],
28+
visibility: Optional[str],
2829
generate: bool = True,
2930
execution_api_key: str = ""
3031
):
@@ -55,6 +56,7 @@ def function_add_or_update(
5556
"description": description or parsed["types"]["description"],
5657
"code": code,
5758
"language": "python",
59+
"visibility": visibility or "ENVIRONMENT",
5860
"returnType": get_jsonschema_type(return_type),
5961
"arguments": [{**p, "key": p["name"], "type": get_jsonschema_type(p["type"])} for p in parsed["types"]["params"]],
6062
"logsEnabled": logs_enabled,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
33

44
[project]
55
name = "polyapi-python"
6-
version = "0.3.10.dev3"
6+
version = "0.3.10.dev4"
77
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
88
authors = [{ name = "Dan Fellin", email = "[email protected]" }]
99
dependencies = [

0 commit comments

Comments
 (0)