@@ -4405,7 +4405,6 @@ def update_user_role(self, email: str, new_role: str) -> dict:
44054405 self .log ('error' , f"Error updating role for { email } : { str (e )} " )
44064406 raise
44074407
4408- '''
44094408 def get_group_modem_upgrade_jobs (self , ** kwargs ):
44104409 """
44114410 Returns users with details.
@@ -4559,7 +4558,97 @@ def get_group_modem_upgrade_device_summary(self, **kwargs):
45594558 else :
45604559 params = self .__parse_kwargs (kwargs , allowed_params )
45614560 return self .__get_json (get_url , call_type , params = params )
4562- '''
4561+
4562+ def create_modem_upgrade (self , group_id : int , carrier : str , modem_type_name : str , operation : str , overwrite : bool = False , connection_states : list = None , ** kwargs ) -> dict :
4563+ """
4564+ Creates a new modem upgrade job.
4565+
4566+ :param group_id: ID of the group to target for the modem upgrade.
4567+ :type group_id: int
4568+ :param carrier: Targeted carrier (e.g., "att").
4569+ :type carrier: str
4570+ :param modem_type_name: Module name associated with module_id (e.g., "LP4").
4571+ :type modem_type_name: str
4572+ :param operation: Operation type [preview|upgrade|cancel].
4573+ :type operation: str
4574+ :param overwrite: Overwrite modem firmware if on the same version already. Defaults to False.
4575+ :type overwrite: bool
4576+ :param connection_states: The targeted net devices connection state. Optional.
4577+ :type connection_states: list, optional
4578+ :param kwargs: Additional optional parameters to include in the request.
4579+ :return: The created modem upgrade job data if successful, error message otherwise.
4580+ :raises TypeError: If the type of any parameter is incorrect.
4581+ :raises ValueError: If required parameters are missing or if an invalid parameter or value is provided.
4582+ """
4583+ call_type = 'Create Modem Upgrade'
4584+
4585+ # Type checking for required parameters
4586+ if not isinstance (group_id , int ):
4587+ raise TypeError ("group_id must be an integer" )
4588+ if not isinstance (carrier , str ):
4589+ raise TypeError ("carrier must be a string" )
4590+ if not isinstance (modem_type_name , str ):
4591+ raise TypeError ("modem_type_name must be a string" )
4592+ if not isinstance (operation , str ):
4593+ raise TypeError ("operation must be a string" )
4594+ if not isinstance (overwrite , bool ):
4595+ raise TypeError ("overwrite must be a boolean" )
4596+
4597+ # Validate operation value
4598+ valid_operations = ["preview" , "upgrade" , "cancel" ]
4599+ if operation not in valid_operations :
4600+ raise ValueError (f"operation must be one of: { valid_operations } " )
4601+
4602+ # Validate carrier and modem_type_name are not empty
4603+ if not carrier .strip ():
4604+ raise ValueError ("carrier cannot be empty" )
4605+ if not modem_type_name .strip ():
4606+ raise ValueError ("modem_type_name cannot be empty" )
4607+
4608+ post_url = f'{ self .base_url } /beta/modem_upgrades'
4609+
4610+ # Build attributes dictionary with required fields
4611+ attributes = {
4612+ 'carrier' : carrier ,
4613+ 'modem_type_name' : modem_type_name ,
4614+ 'operation' : operation ,
4615+ 'overwrite' : overwrite
4616+ }
4617+
4618+ # Add connection_states if provided
4619+ if connection_states is not None :
4620+ if not isinstance (connection_states , list ):
4621+ raise TypeError ("connection_states must be a list" )
4622+ if not all (isinstance (state , str ) for state in connection_states ):
4623+ raise TypeError ("All connection_states must be strings" )
4624+ attributes ['connection_states' ] = connection_states
4625+
4626+ # Add any additional parameters from kwargs directly to attributes
4627+ for key , value in kwargs .items ():
4628+ attributes [key ] = value
4629+
4630+ data = {
4631+ "data" : {
4632+ "type" : "modem_upgrades" ,
4633+ "attributes" : attributes ,
4634+ "relationships" : {
4635+ "group" : {
4636+ "data" : {
4637+ "type" : "groups" ,
4638+ "id" : group_id
4639+ }
4640+ }
4641+ }
4642+ }
4643+ }
4644+
4645+ ncm = self .session .post (post_url , data = json .dumps (data ))
4646+ result = self ._return_handler (ncm .status_code , ncm .json (), call_type )
4647+ if ncm .status_code == 201 :
4648+ return ncm .json ()['data' ]
4649+ else :
4650+ return result
4651+
45634652
45644653class NcmClientv2v3 :
45654654
0 commit comments