@@ -97,9 +97,31 @@ class VolumeMount:
9797@dataclass_json
9898@dataclass
9999class Container :
100+ """Container configuration for deployment creation and updates.
101+ This class omits the name field which is managed by the system.
102+
103+ :param image: Container image to use
104+ :param exposed_port: Port to expose from the container
105+ :param healthcheck: Optional health check configuration
106+ :param entrypoint_overrides: Optional entrypoint override settings
107+ :param env: Optional list of environment variables
108+ :param volume_mounts: Optional list of volume mounts
109+ """
110+ image : str
111+ exposed_port : int
112+ healthcheck : Optional [HealthcheckSettings ] = None
113+ entrypoint_overrides : Optional [EntrypointOverridesSettings ] = None
114+ env : Optional [List [EnvVar ]] = None
115+ volume_mounts : Optional [List [VolumeMount ]] = None
116+
117+
118+ @dataclass_json
119+ @dataclass
120+ class ContainerInfo :
100121 """Container configuration for deployments.
122+ This class is read-only and includes the system-managed name field.
101123
102- :param name: Name of the container
124+ :param name: Name of the container (system-managed)
103125 :param image: Container image to use
104126 :param exposed_port: Port to expose from the container
105127 :param healthcheck: Optional health check configuration
@@ -115,6 +137,24 @@ class Container:
115137 env : Optional [List [EnvVar ]] = None
116138 volume_mounts : Optional [List [VolumeMount ]] = None
117139
140+ @classmethod
141+ def from_container (cls , name : str , container : Container ) -> 'ContainerInfo' :
142+ """Create a ContainerInfo from a Container and a name.
143+
144+ :param name: Name of the container
145+ :param container: Container specification
146+ :return: ContainerInfo instance
147+ """
148+ return cls (
149+ name = name ,
150+ image = container .image ,
151+ exposed_port = container .exposed_port ,
152+ healthcheck = container .healthcheck ,
153+ entrypoint_overrides = container .entrypoint_overrides ,
154+ env = container .env ,
155+ volume_mounts = container .volume_mounts
156+ )
157+
118158
119159@dataclass_json
120160@dataclass
@@ -224,7 +264,31 @@ class ScalingOptions:
224264@dataclass_json (undefined = Undefined .EXCLUDE )
225265@dataclass
226266class Deployment :
267+ """Configuration for creating or updating a container deployment.
268+ This class uses Container instead of ContainerInfo to prevent name setting.
269+
270+ :param name: Name of the deployment
271+ :param container_registry_settings: Settings for accessing container registry
272+ :param containers: List of container specifications in the deployment
273+ :param compute: Compute resource configuration
274+ :param is_spot: Whether is spot deployment
275+ :param endpoint_base_url: Optional base URL for the deployment endpoint
276+ :param scaling: Optional scaling configuration
277+ """
278+ name : str
279+ container_registry_settings : ContainerRegistrySettings
280+ containers : List [Container ]
281+ compute : ComputeResource
282+ is_spot : bool = False
283+ endpoint_base_url : Optional [str ] = None
284+ scaling : Optional [ScalingOptions ] = None
285+
286+
287+ @dataclass_json (undefined = Undefined .EXCLUDE )
288+ @dataclass
289+ class DeploymentInfo :
227290 """Configuration for a container deployment.
291+ This class is read-only and includes system-managed fields.
228292
229293 :param name: Name of the deployment
230294 :param container_registry_settings: Settings for accessing container registry
@@ -237,7 +301,7 @@ class Deployment:
237301 """
238302 name : str
239303 container_registry_settings : ContainerRegistrySettings
240- containers : List [Container ]
304+ containers : List [ContainerInfo ]
241305 compute : ComputeResource
242306 is_spot : bool = False
243307 endpoint_base_url : Optional [str ] = None
@@ -359,59 +423,59 @@ def __init__(self, http_client) -> None:
359423 """
360424 self .client = http_client
361425
362- def get_deployments (self ) -> List [Deployment ]:
426+ def get_deployments (self ) -> List [DeploymentInfo ]:
363427 """Get all deployments
364428
365429 :return: list of deployments
366- :rtype: List[Deployment ]
430+ :rtype: List[DeploymentInfo ]
367431 """
368432 response = self .client .get (CONTAINER_DEPLOYMENTS_ENDPOINT )
369- return [Deployment .from_dict (deployment , infer_missing = True ) for deployment in response .json ()]
433+ return [DeploymentInfo .from_dict (deployment , infer_missing = True ) for deployment in response .json ()]
370434
371- def get_deployment_by_name (self , deployment_name : str ) -> Deployment :
435+ def get_deployment_by_name (self , deployment_name : str ) -> DeploymentInfo :
372436 """Get a deployment by name
373437
374438 :param deployment_name: name of the deployment
375439 :type deployment_name: str
376440 :return: deployment
377- :rtype: Deployment
441+ :rtype: DeploymentInfo
378442 """
379443 response = self .client .get (
380444 f"{ CONTAINER_DEPLOYMENTS_ENDPOINT } /{ deployment_name } " )
381- return Deployment .from_dict (response .json (), infer_missing = True )
445+ return DeploymentInfo .from_dict (response .json (), infer_missing = True )
382446
383447 def create_deployment (
384448 self ,
385449 deployment : Deployment
386- ) -> Deployment :
450+ ) -> DeploymentInfo :
387451 """Create a new deployment
388452
389453 :param deployment: deployment configuration
390454 :type deployment: Deployment
391455 :return: created deployment
392- :rtype: Deployment
456+ :rtype: DeploymentInfo
393457 """
394458 response = self .client .post (
395459 CONTAINER_DEPLOYMENTS_ENDPOINT ,
396460 deployment .to_dict ()
397461 )
398- return Deployment .from_dict (response .json (), infer_missing = True )
462+ return DeploymentInfo .from_dict (response .json (), infer_missing = True )
399463
400- def update_deployment (self , deployment_name : str , deployment : Deployment ) -> Deployment :
464+ def update_deployment (self , deployment_name : str , deployment : DeploymentInfo ) -> DeploymentInfo :
401465 """Update an existing deployment
402466
403467 :param deployment_name: name of the deployment to update
404468 :type deployment_name: str
405469 :param deployment: updated deployment
406- :type deployment: Deployment
470+ :type deployment: DeploymentInfo
407471 :return: updated deployment
408- :rtype: Deployment
472+ :rtype: DeploymentInfo
409473 """
410474 response = self .client .patch (
411475 f"{ CONTAINER_DEPLOYMENTS_ENDPOINT } /{ deployment_name } " ,
412476 deployment .to_dict ()
413477 )
414- return Deployment .from_dict (response .json (), infer_missing = True )
478+ return DeploymentInfo .from_dict (response .json (), infer_missing = True )
415479
416480 def delete_deployment (self , deployment_name : str ) -> None :
417481 """Delete a deployment
0 commit comments