otupy.core.command.Command

class Command(action: Actions, target: Target, args: Args = None, actuator: Actuator = None, command_id: str = None)

Bases: Content, Record

OpenC2 Command

This class defines the structure of the OpenC2 Command. The name, meaning, and restrictions for the fields are described in Sec. 3.3.1 of the Specification.

The target object is implicitely initialized by passing any valid Target.

Methods

fromdict

Builds instance from dictionary

getType

Returns the Content type

todict

Converts to dictionary

Attributes

actuator

args

command_id

msg_type

The type of Content (MessageType)

action

target

__init__(action: Actions, target: Target, args: Args = None, actuator: Actuator = None, command_id: str = None) None
classmethod fromdict(dic, e)

Builds instance from dictionary

It is used during deserialization to create an otupy instance from the text message. It takes an Encoder instance that is used to recursively build instances of the inner objects (the Encoder provides standard methods to create instances of base objects like strings, integers, boolean).

Parameters:
  • dic – The intermediary dictionary representation from which the object is built.

  • e – The Encoder that is being used.

Returns:

An instance of this class initialized from the dictionary values.

getType()

Returns the Content type

msg_type: MessageType = 1

The type of Content (MessageType)

todict(e)

Converts to dictionary

It is used to convert this object to an intermediary representation during serialization. It takes an Encoder argument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..

Parameters:

e – The Encoder that is being used.

Returns:

A dictionary compliants to the Language Specification’s serialization rules.