@@ -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
@@ -224,7 +246,31 @@ class ScalingOptions:
224246@dataclass_json (undefined = Undefined .EXCLUDE )
225247@dataclass
226248class Deployment :
249+ """Configuration for creating or updating a container deployment.
250+ This class uses Container instead of ContainerInfo to prevent name setting.
251+
252+ :param name: Name of the deployment
253+ :param container_registry_settings: Settings for accessing container registry
254+ :param containers: List of container specifications in the deployment
255+ :param compute: Compute resource configuration
256+ :param is_spot: Whether is spot deployment
257+ :param endpoint_base_url: Optional base URL for the deployment endpoint
258+ :param scaling: Optional scaling configuration
259+ """
260+ name : str
261+ container_registry_settings : ContainerRegistrySettings
262+ containers : List [Container ]
263+ compute : ComputeResource
264+ is_spot : bool = False
265+ endpoint_base_url : Optional [str ] = None
266+ scaling : Optional [ScalingOptions ] = None
267+
268+
269+ @dataclass_json (undefined = Undefined .EXCLUDE )
270+ @dataclass
271+ class DeploymentInfo :
227272 """Configuration for a container deployment.
273+ This class is read-only and includes system-managed fields.
228274
229275 :param name: Name of the deployment
230276 :param container_registry_settings: Settings for accessing container registry
@@ -237,7 +283,7 @@ class Deployment:
237283 """
238284 name : str
239285 container_registry_settings : ContainerRegistrySettings
240- containers : List [Container ]
286+ containers : List [ContainerInfo ]
241287 compute : ComputeResource
242288 is_spot : bool = False
243289 endpoint_base_url : Optional [str ] = None
@@ -359,59 +405,59 @@ def __init__(self, http_client) -> None:
359405 """
360406 self .client = http_client
361407
362- def get_deployments (self ) -> List [Deployment ]:
408+ def get_deployments (self ) -> List [DeploymentInfo ]:
363409 """Get all deployments
364410
365411 :return: list of deployments
366- :rtype: List[Deployment ]
412+ :rtype: List[DeploymentInfo ]
367413 """
368414 response = self .client .get (CONTAINER_DEPLOYMENTS_ENDPOINT )
369- return [Deployment .from_dict (deployment , infer_missing = True ) for deployment in response .json ()]
415+ return [DeploymentInfo .from_dict (deployment , infer_missing = True ) for deployment in response .json ()]
370416
371- def get_deployment_by_name (self , deployment_name : str ) -> Deployment :
417+ def get_deployment_by_name (self , deployment_name : str ) -> DeploymentInfo :
372418 """Get a deployment by name
373419
374420 :param deployment_name: name of the deployment
375421 :type deployment_name: str
376422 :return: deployment
377- :rtype: Deployment
423+ :rtype: DeploymentInfo
378424 """
379425 response = self .client .get (
380426 f"{ CONTAINER_DEPLOYMENTS_ENDPOINT } /{ deployment_name } " )
381- return Deployment .from_dict (response .json (), infer_missing = True )
427+ return DeploymentInfo .from_dict (response .json (), infer_missing = True )
382428
383429 def create_deployment (
384430 self ,
385431 deployment : Deployment
386- ) -> Deployment :
432+ ) -> DeploymentInfo :
387433 """Create a new deployment
388434
389435 :param deployment: deployment configuration
390436 :type deployment: Deployment
391437 :return: created deployment
392- :rtype: Deployment
438+ :rtype: DeploymentInfo
393439 """
394440 response = self .client .post (
395441 CONTAINER_DEPLOYMENTS_ENDPOINT ,
396442 deployment .to_dict ()
397443 )
398- return Deployment .from_dict (response .json (), infer_missing = True )
444+ return DeploymentInfo .from_dict (response .json (), infer_missing = True )
399445
400- def update_deployment (self , deployment_name : str , deployment : Deployment ) -> Deployment :
446+ def update_deployment (self , deployment_name : str , deployment : DeploymentInfo ) -> DeploymentInfo :
401447 """Update an existing deployment
402448
403449 :param deployment_name: name of the deployment to update
404450 :type deployment_name: str
405451 :param deployment: updated deployment
406- :type deployment: Deployment
452+ :type deployment: DeploymentInfo
407453 :return: updated deployment
408- :rtype: Deployment
454+ :rtype: DeploymentInfo
409455 """
410456 response = self .client .patch (
411457 f"{ CONTAINER_DEPLOYMENTS_ENDPOINT } /{ deployment_name } " ,
412458 deployment .to_dict ()
413459 )
414- return Deployment .from_dict (response .json (), infer_missing = True )
460+ return DeploymentInfo .from_dict (response .json (), infer_missing = True )
415461
416462 def delete_deployment (self , deployment_name : str ) -> None :
417463 """Delete a deployment
0 commit comments