Previous topic

CertificateRequest

Next topic

Device

This Page

Command

@startuml

skinparam defaultFontName Courier

Class commands {
    INTEGER       ★ id                
    INTEGER       ☆ device_id         
    DATETIME      ⚪ acknowledged_at   
    DATETIME      ⚪ after             
    TEXT          ⚪ parameters        
    DATETIME      ⚪ queued_at         
    VARCHAR       ⚪ request_type      
    DATETIME      ⚪ sent_at           
    VARCHAR[1]    ⚪ status            
    INTEGER       ⚪ ttl               
    CHAR[32]      ⚪ uuid              
    INDEX[status] » ix_commands_status
    INDEX[uuid]   » ix_commands_uuid  
}

right footer generated by sadisplay v0.4.8

@enduml

class commandment.models.Command(**kwargs)[source]

The command model represents a single MDM command that should be, has been, or has failed to be delivered to a single enrolled device.

Table:commands
acknowledged_at

The datetime (utc) of when the Acknowledged, Error or NotNow response was returned.

Type:acknowledged_at (datetime.datetime)
after

If not null, the command must not be sent until this datetime is in the past.

Type:after (datetime.datetime)
device

The instance of the related device.

Type:device (Device)
device_id

The device ID on the devices table.

Type:device_id (int)
classmethod find_by_uuid(uuid: str)[source]

Find and return an instance of the Command model matching the given UUID string.

Parameters:uuid (str) – The command UUID
Returns:Instance of the command, if any
Return type:Command
classmethod from_model(cmd: commandment.mdm.commands.Command)[source]

This method turns a subclass of commands.Command into an SQLAlchemy model. The parameters of the command are encoded as a JSON dictionary inside the parameters column.

Parameters:cmd (commands.Command) – The command to be turned into a database model.
Returns:The database model, ready to be committed.
Return type:Command
id

ID

Type:id (int)
classmethod next_command(device: commandment.models.Device)[source]

Get the next available command in the queue for the specified device.

The next available command must match these predicates:

  • Assigned to this device.
  • The status is “Queued”.
  • The after field is in the past, or empty.
Parameters:device (Device) – The database model matching the device checking in.
Returns:The next command model to be processed.
Return type:Command
parameters

The parameters that were used when generating the command, serialized into JSON. Omitting the RequestType and CommandUUID attributes.

Type:parameters (str)
queued_at

The datetime (utc) of when the command was created. Defaults to UTC now

Type:queued_at (datetime.datetime)
request_type

The command RequestType attribute

Type:request_type (str)
sent_at

The datetime (utc) of when the command was delivered to the client.

Type:sent_at (datetime.datetime)
status

The status of the command.

Type:status (CommandStatus)
ttl

The number of retries remaining until the command will be dead/expired.

Type:ttl (int)
uuid

Globally unique command UUID

Type:uuid (GUID)
class commandment.models.CommandStatus[source]

CommandStatus describes all the possible states of a command in the device command queue.

The following statuses are based upon the return status of the MDM client:

  • Acknowledged
  • Error
  • CommandFormatError
  • NotNow

Additionally, there are statuses to explain the lifecycle of the command before and after the MDM client processes them:

  • Queued: The command was newly created and not yet sent to the device.
  • Sent: The command has been sent to the device, but no response has come back yet.
  • Expired: The command was never acknowledged, or the device was removed.