Skip to content

How to use Py SDK Creating a Reserved Proxy Share #1003

@Vander-Bilt

Description

@Vander-Bilt
from zrok.proxy import ProxyShare
import zrok

# Load the user's zrok environment from ~/.zrok
zrok_env = zrok.environment.root.Load()


# Create a temporary proxy share (will be cleaned up on exit)
proxy = ProxyShare.create(root=zrok_env, target="http://127.0.0.1:3000", unique_name="abcdef")

print(f"Public URL: {proxy.endpoints}")
proxy.run()

Got the error:

ValidationError                           Traceback (most recent call last)
/tmp/ipykernel_152/1914439960.py in <cell line: 0>()
      9 
     10 # Create a temporary proxy share (will be cleaned up on exit)
---> 11 proxy = ProxyShare.create(root=zrok_env, target="http://127.0.0.1:3000/", unique_name="ty3tsc9dfxgr")
     12 
     13 print(f"Public URL: {proxy.endpoints}")

/usr/local/lib/python3.11/dist-packages/zrok/proxy.py in create(cls, root, target, share_mode, unique_name, frontends, verify_ssl)
     68         # First check if we have an existing reserved share with this name
     69         if unique_name:
---> 70             existing_share = cls._find_existing_share(root, unique_name)
     71             if existing_share:
     72                 logger.debug(f"Found existing share with token: {existing_share.Token}")

/usr/local/lib/python3.11/dist-packages/zrok/proxy.py in _find_existing_share(root, unique_name)
    121     def _find_existing_share(root: Root, unique_name: str) -> Optional[Share]:
    122         """Find an existing share with the given unique name."""
--> 123         overview = Overview.create(root=root)
    124         for env in overview.environments:
    125             if env.environment.z_id == root.env.ZitiIdentity:

/usr/local/lib/python3.11/dist-packages/zrok/overview.py in create(cls, root)
     69 
     70             # Create EnvironmentAndResources object
---> 71             env_resources = EnvironmentAndResources(
     72                 environment=environment,
     73                 shares=share_list,

/usr/local/lib/python3.11/dist-packages/pydantic/main.py in __init__(self, **data)
    251         # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    252         __tracebackhide__ = True
--> 253         validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    254         if self is not validated_self:
    255             warnings.warn(

ValidationError: 6 validation errors for EnvironmentAndResources
frontends.0
  Input should be a valid dictionary or instance of Frontend [type=model_type, input_value=('frontend_token', None), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
frontends.1
  Input should be a valid dictionary or instance of Frontend [type=model_type, input_value=('z_id', None), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
frontends.2
  Input should be a valid dictionary or instance of Frontend [type=model_type, input_value=('url_template', None), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
frontends.3
  Input should be a valid dictionary or instance of Frontend [type=model_type, input_value=('public_name', None), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
frontends.4
  Input should be a valid dictionary or instance of Frontend [type=model_type, input_value=('created_at', None), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type
frontends.5
  Input should be a valid dictionary or instance of Frontend [type=model_type, input_value=('updated_at', None), input_type=tuple]
    For further information visit https://errors.pydantic.dev/2.11/v/model_type

Metadata

Metadata

Assignees

Labels

defectSomething isn't workingevidenceSupporting evidence for a change

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions